From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001
From: Daniel Baumann
Date: Sat, 27 Apr 2024 18:51:28 +0200
Subject: Adding upstream version 1:7.0.4.
Signed-off-by: Daniel Baumann
---
.../comphelper/AccessibleImplementationHelper.hxx | 48 ++
include/comphelper/ChainablePropertySet.hxx | 148 ++++++
include/comphelper/ChainablePropertySetInfo.hxx | 64 +++
include/comphelper/DirectoryHelper.hxx | 34 ++
include/comphelper/IdPropArrayHelper.hxx | 114 +++++
include/comphelper/MasterPropertySet.hxx | 135 ++++++
include/comphelper/MasterPropertySetInfo.hxx | 56 +++
include/comphelper/PropertyInfoHash.hxx | 52 ++
include/comphelper/SelectionMultiplex.hxx | 92 ++++
include/comphelper/SetFlagContextHelper.hxx | 63 +++
include/comphelper/accessiblecomponenthelper.hxx | 142 ++++++
include/comphelper/accessiblecontexthelper.hxx | 219 +++++++++
include/comphelper/accessibleeventnotifier.hxx | 116 +++++
include/comphelper/accessiblekeybindinghelper.hxx | 73 +++
include/comphelper/accessibleselectionhelper.hxx | 135 ++++++
include/comphelper/accessibletexthelper.hxx | 176 +++++++
include/comphelper/accessiblewrapper.hxx | 405 ++++++++++++++++
include/comphelper/accimplaccess.hxx | 75 +++
include/comphelper/anycompare.hxx | 218 +++++++++
include/comphelper/anytostring.hxx | 44 ++
include/comphelper/asyncnotification.hxx | 225 +++++++++
include/comphelper/asyncquithandler.hxx | 52 ++
include/comphelper/attributelist.hxx | 92 ++++
include/comphelper/automationinvokedzone.hxx | 39 ++
include/comphelper/backupfilehelper.hxx | 215 +++++++++
include/comphelper/base64.hxx | 55 +++
include/comphelper/basicio.hxx | 88 ++++
include/comphelper/broadcasthelper.hxx | 51 ++
include/comphelper/classids.hxx | 334 +++++++++++++
include/comphelper/comphelperdllapi.h | 33 ++
include/comphelper/componentbase.hxx | 139 ++++++
include/comphelper/componentguard.hxx | 58 +++
include/comphelper/componentmodule.hxx | 168 +++++++
include/comphelper/configuration.hxx | 352 ++++++++++++++
include/comphelper/configurationhelper.hxx | 239 ++++++++++
include/comphelper/configurationlistener.hxx | 116 +++++
include/comphelper/container.hxx | 77 +++
include/comphelper/containermultiplexer.hxx | 106 +++++
include/comphelper/crashzone.hxx | 72 +++
include/comphelper/debuggerinfo.hxx | 38 ++
include/comphelper/dispatchcommand.hxx | 43 ++
include/comphelper/docpasswordhelper.hxx | 428 +++++++++++++++++
include/comphelper/docpasswordrequest.hxx | 110 +++++
include/comphelper/documentconstants.hxx | 129 +++++
include/comphelper/documentinfo.hxx | 51 ++
include/comphelper/doublecheckedinit.hxx | 64 +++
include/comphelper/embeddedobjectcontainer.hxx | 192 ++++++++
include/comphelper/enumhelper.hxx | 121 +++++
include/comphelper/eventattachermgr.hxx | 48 ++
include/comphelper/evtlistenerhlp.hxx | 49 ++
include/comphelper/evtmethodhelper.hxx | 32 ++
include/comphelper/extract.hxx | 117 +++++
include/comphelper/fileformat.h | 34 ++
include/comphelper/fileurl.hxx | 37 ++
include/comphelper/flagguard.hxx | 80 ++++
include/comphelper/genericpropertyset.hxx | 36 ++
include/comphelper/getexpandeduri.hxx | 38 ++
include/comphelper/graphicmimetype.hxx | 62 +++
include/comphelper/guarding.hxx | 55 +++
include/comphelper/hash.hxx | 115 +++++
include/comphelper/interaction.hxx | 120 +++++
include/comphelper/interfacecontainer2.hxx | 285 +++++++++++
include/comphelper/interfacecontainer3.hxx | 356 ++++++++++++++
include/comphelper/listenernotification.hxx | 267 +++++++++++
include/comphelper/logging.hxx | 460 ++++++++++++++++++
include/comphelper/lok.hxx | 125 +++++
include/comphelper/make_shared_from_uno.hxx | 67 +++
include/comphelper/mimeconfighelper.hxx | 142 ++++++
include/comphelper/namecontainer.hxx | 37 ++
include/comphelper/namedvaluecollection.hxx | 353 ++++++++++++++
include/comphelper/newarray.hxx | 42 ++
include/comphelper/numberedcollection.hxx | 166 +++++++
include/comphelper/numbers.hxx | 56 +++
include/comphelper/ofopxmlhelper.hxx | 102 ++++
include/comphelper/oslfile2streamwrap.hxx | 78 +++
include/comphelper/parallelsort.hxx | 373 +++++++++++++++
include/comphelper/processfactory.hxx | 72 +++
include/comphelper/profilezone.hxx | 89 ++++
include/comphelper/propagg.hxx | 329 +++++++++++++
include/comphelper/proparrhlp.hxx | 141 ++++++
include/comphelper/property.hxx | 131 +++++
include/comphelper/propertybag.hxx | 228 +++++++++
include/comphelper/propertycontainer.hxx | 87 ++++
include/comphelper/propertycontainerhelper.hxx | 195 ++++++++
include/comphelper/propertysequence.hxx | 56 +++
include/comphelper/propertysethelper.hxx | 99 ++++
include/comphelper/propertysetinfo.hxx | 123 +++++
include/comphelper/propertystatecontainer.hxx | 110 +++++
include/comphelper/propertyvalue.hxx | 39 ++
include/comphelper/propmultiplex.hxx | 113 +++++
include/comphelper/propstate.hxx | 102 ++++
include/comphelper/proxyaggregation.hxx | 218 +++++++++
include/comphelper/random.hxx | 45 ++
include/comphelper/refcountedmutex.hxx | 43 ++
include/comphelper/scopeguard.hxx | 101 ++++
include/comphelper/seekableinput.hxx | 83 ++++
include/comphelper/seqstream.hxx | 126 +++++
include/comphelper/sequence.hxx | 317 +++++++++++++
include/comphelper/sequenceashashmap.hxx | 389 +++++++++++++++
include/comphelper/servicedecl.hxx | 337 +++++++++++++
include/comphelper/servicehelper.hxx | 117 +++++
include/comphelper/sharedmutex.hxx | 77 +++
include/comphelper/simplefileaccessinteraction.hxx | 52 ++
include/comphelper/solarmutex.hxx | 98 ++++
include/comphelper/stillreadwriteinteraction.hxx | 62 +++
include/comphelper/stl_types.hxx | 170 +++++++
include/comphelper/storagehelper.hxx | 205 ++++++++
include/comphelper/streamsection.hxx | 71 +++
include/comphelper/string.hxx | 382 +++++++++++++++
include/comphelper/synchronousdispatch.hxx | 64 +++
include/comphelper/syntaxhighlight.hxx | 84 ++++
include/comphelper/threadpool.hxx | 107 +++++
include/comphelper/types.hxx | 89 ++++
include/comphelper/unique_disposing_ptr.hxx | 186 ++++++++
include/comphelper/uno3.hxx | 182 +++++++
include/comphelper/unwrapargs.hxx | 123 +++++
include/comphelper/weak.hxx | 64 +++
include/comphelper/weakbag.hxx | 84 ++++
include/comphelper/weakeventlistener.hxx | 182 +++++++
include/comphelper/windowsStart.hxx | 27 ++
include/comphelper/windowsdebugoutput.hxx | 525 +++++++++++++++++++++
include/comphelper/windowserrorstring.hxx | 68 +++
include/comphelper/xmlsechelper.hxx | 48 ++
include/comphelper/xmltools.hxx | 28 ++
124 files changed, 16496 insertions(+)
create mode 100644 include/comphelper/AccessibleImplementationHelper.hxx
create mode 100644 include/comphelper/ChainablePropertySet.hxx
create mode 100644 include/comphelper/ChainablePropertySetInfo.hxx
create mode 100644 include/comphelper/DirectoryHelper.hxx
create mode 100644 include/comphelper/IdPropArrayHelper.hxx
create mode 100644 include/comphelper/MasterPropertySet.hxx
create mode 100644 include/comphelper/MasterPropertySetInfo.hxx
create mode 100644 include/comphelper/PropertyInfoHash.hxx
create mode 100644 include/comphelper/SelectionMultiplex.hxx
create mode 100644 include/comphelper/SetFlagContextHelper.hxx
create mode 100644 include/comphelper/accessiblecomponenthelper.hxx
create mode 100644 include/comphelper/accessiblecontexthelper.hxx
create mode 100644 include/comphelper/accessibleeventnotifier.hxx
create mode 100644 include/comphelper/accessiblekeybindinghelper.hxx
create mode 100644 include/comphelper/accessibleselectionhelper.hxx
create mode 100644 include/comphelper/accessibletexthelper.hxx
create mode 100644 include/comphelper/accessiblewrapper.hxx
create mode 100644 include/comphelper/accimplaccess.hxx
create mode 100644 include/comphelper/anycompare.hxx
create mode 100644 include/comphelper/anytostring.hxx
create mode 100644 include/comphelper/asyncnotification.hxx
create mode 100644 include/comphelper/asyncquithandler.hxx
create mode 100644 include/comphelper/attributelist.hxx
create mode 100644 include/comphelper/automationinvokedzone.hxx
create mode 100644 include/comphelper/backupfilehelper.hxx
create mode 100644 include/comphelper/base64.hxx
create mode 100644 include/comphelper/basicio.hxx
create mode 100644 include/comphelper/broadcasthelper.hxx
create mode 100644 include/comphelper/classids.hxx
create mode 100644 include/comphelper/comphelperdllapi.h
create mode 100644 include/comphelper/componentbase.hxx
create mode 100644 include/comphelper/componentguard.hxx
create mode 100644 include/comphelper/componentmodule.hxx
create mode 100644 include/comphelper/configuration.hxx
create mode 100644 include/comphelper/configurationhelper.hxx
create mode 100644 include/comphelper/configurationlistener.hxx
create mode 100644 include/comphelper/container.hxx
create mode 100644 include/comphelper/containermultiplexer.hxx
create mode 100644 include/comphelper/crashzone.hxx
create mode 100644 include/comphelper/debuggerinfo.hxx
create mode 100644 include/comphelper/dispatchcommand.hxx
create mode 100644 include/comphelper/docpasswordhelper.hxx
create mode 100644 include/comphelper/docpasswordrequest.hxx
create mode 100644 include/comphelper/documentconstants.hxx
create mode 100644 include/comphelper/documentinfo.hxx
create mode 100644 include/comphelper/doublecheckedinit.hxx
create mode 100644 include/comphelper/embeddedobjectcontainer.hxx
create mode 100644 include/comphelper/enumhelper.hxx
create mode 100644 include/comphelper/eventattachermgr.hxx
create mode 100644 include/comphelper/evtlistenerhlp.hxx
create mode 100644 include/comphelper/evtmethodhelper.hxx
create mode 100644 include/comphelper/extract.hxx
create mode 100644 include/comphelper/fileformat.h
create mode 100644 include/comphelper/fileurl.hxx
create mode 100644 include/comphelper/flagguard.hxx
create mode 100644 include/comphelper/genericpropertyset.hxx
create mode 100644 include/comphelper/getexpandeduri.hxx
create mode 100644 include/comphelper/graphicmimetype.hxx
create mode 100644 include/comphelper/guarding.hxx
create mode 100644 include/comphelper/hash.hxx
create mode 100644 include/comphelper/interaction.hxx
create mode 100644 include/comphelper/interfacecontainer2.hxx
create mode 100644 include/comphelper/interfacecontainer3.hxx
create mode 100644 include/comphelper/listenernotification.hxx
create mode 100644 include/comphelper/logging.hxx
create mode 100644 include/comphelper/lok.hxx
create mode 100644 include/comphelper/make_shared_from_uno.hxx
create mode 100644 include/comphelper/mimeconfighelper.hxx
create mode 100644 include/comphelper/namecontainer.hxx
create mode 100644 include/comphelper/namedvaluecollection.hxx
create mode 100644 include/comphelper/newarray.hxx
create mode 100644 include/comphelper/numberedcollection.hxx
create mode 100644 include/comphelper/numbers.hxx
create mode 100644 include/comphelper/ofopxmlhelper.hxx
create mode 100644 include/comphelper/oslfile2streamwrap.hxx
create mode 100644 include/comphelper/parallelsort.hxx
create mode 100644 include/comphelper/processfactory.hxx
create mode 100644 include/comphelper/profilezone.hxx
create mode 100644 include/comphelper/propagg.hxx
create mode 100644 include/comphelper/proparrhlp.hxx
create mode 100644 include/comphelper/property.hxx
create mode 100644 include/comphelper/propertybag.hxx
create mode 100644 include/comphelper/propertycontainer.hxx
create mode 100644 include/comphelper/propertycontainerhelper.hxx
create mode 100644 include/comphelper/propertysequence.hxx
create mode 100644 include/comphelper/propertysethelper.hxx
create mode 100644 include/comphelper/propertysetinfo.hxx
create mode 100644 include/comphelper/propertystatecontainer.hxx
create mode 100644 include/comphelper/propertyvalue.hxx
create mode 100644 include/comphelper/propmultiplex.hxx
create mode 100644 include/comphelper/propstate.hxx
create mode 100644 include/comphelper/proxyaggregation.hxx
create mode 100644 include/comphelper/random.hxx
create mode 100644 include/comphelper/refcountedmutex.hxx
create mode 100644 include/comphelper/scopeguard.hxx
create mode 100644 include/comphelper/seekableinput.hxx
create mode 100644 include/comphelper/seqstream.hxx
create mode 100644 include/comphelper/sequence.hxx
create mode 100644 include/comphelper/sequenceashashmap.hxx
create mode 100644 include/comphelper/servicedecl.hxx
create mode 100644 include/comphelper/servicehelper.hxx
create mode 100644 include/comphelper/sharedmutex.hxx
create mode 100644 include/comphelper/simplefileaccessinteraction.hxx
create mode 100644 include/comphelper/solarmutex.hxx
create mode 100644 include/comphelper/stillreadwriteinteraction.hxx
create mode 100644 include/comphelper/stl_types.hxx
create mode 100644 include/comphelper/storagehelper.hxx
create mode 100644 include/comphelper/streamsection.hxx
create mode 100644 include/comphelper/string.hxx
create mode 100644 include/comphelper/synchronousdispatch.hxx
create mode 100644 include/comphelper/syntaxhighlight.hxx
create mode 100644 include/comphelper/threadpool.hxx
create mode 100644 include/comphelper/types.hxx
create mode 100644 include/comphelper/unique_disposing_ptr.hxx
create mode 100644 include/comphelper/uno3.hxx
create mode 100644 include/comphelper/unwrapargs.hxx
create mode 100644 include/comphelper/weak.hxx
create mode 100644 include/comphelper/weakbag.hxx
create mode 100644 include/comphelper/weakeventlistener.hxx
create mode 100644 include/comphelper/windowsStart.hxx
create mode 100644 include/comphelper/windowsdebugoutput.hxx
create mode 100644 include/comphelper/windowserrorstring.hxx
create mode 100644 include/comphelper/xmlsechelper.hxx
create mode 100644 include/comphelper/xmltools.hxx
(limited to 'include/comphelper')
diff --git a/include/comphelper/AccessibleImplementationHelper.hxx b/include/comphelper/AccessibleImplementationHelper.hxx
new file mode 100644
index 000000000..742c56f19
--- /dev/null
+++ b/include/comphelper/AccessibleImplementationHelper.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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_COMPHELPER_ACESSIBLEIMPLEMENTATIONHELPER_HXX
+#define INCLUDED_COMPHELPER_ACESSIBLEIMPLEMENTATIONHELPER_HXX
+
+#include
+#include
+
+namespace com::sun::star::awt
+{
+struct KeyStroke;
+}
+namespace com::sun::star::uno
+{
+template class Sequence;
+}
+
+namespace comphelper
+{
+/**
+ * Helper function used for converting keybinding to string.
+ *
+ * @param keySet the key stroke sequence.
+ */
+COMPHELPER_DLLPUBLIC OUString
+GetkeyBindingStrByXkeyBinding(const css::uno::Sequence& keySet);
+}
+
+#endif // INCLUDED_COMPHELPER_ACESSIBLEIMPLEMENTATIONHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/comphelper/ChainablePropertySet.hxx b/include/comphelper/ChainablePropertySet.hxx
new file mode 100644
index 000000000..829b1a2d9
--- /dev/null
+++ b/include/comphelper/ChainablePropertySet.hxx
@@ -0,0 +1,148 @@
+/* -*- 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_COMPHELPER_CHAINABLEPROPERTYSET_HXX
+#define INCLUDED_COMPHELPER_CHAINABLEPROPERTYSET_HXX
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace comphelper { class SolarMutex; }
+namespace comphelper { struct PropertyInfo; }
+
+namespace comphelper
+{
+ class ChainablePropertySetInfo;
+}
+
+/*
+ * A ChainablePropertySet has the following features:
+ *
+ * 1. It implements both the PropertySet and MultiPropertySet interfaces.
+ * 2. It can be 'included' in a MasterPropertySet to seamlessly appear as if
+ * if it's properties were in the master.
+ *
+ * To be used as a base class for PropertySets, the subclass must implement
+ * the 6 protected pure virtual functions. If a mutex is passed to the
+ * constructor, this is locked before any call to _getSingleValue or
+ * _setSingleValue and released after all processing has completed
+ * (including _postSetValues or _postGetValues )
+ *
+ * Any MasterPropertySet implementations that can include an
+ * implementation of a given ChainablePropertySet must be
+ * declared as a 'friend' in the implementation of the ChainablePropertySet.
+ *
+ */
+
+namespace comphelper
+{
+ typedef cppu::WeakImplHelper
+ <
+ css::beans::XPropertySet,
+ css::beans::XMultiPropertySet,
+ css::lang::XServiceInfo
+ >
+ ChainablePropertySetBase;
+ class COMPHELPER_DLLPUBLIC ChainablePropertySet : public ChainablePropertySetBase,
+ public css::beans::XPropertyState
+ {
+ friend class MasterPropertySet;
+ protected:
+ SolarMutex* const mpMutex;
+ rtl::Reference < ChainablePropertySetInfo > mxInfo;
+
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ virtual void _preSetValues () = 0;
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ virtual void _setSingleValue(const comphelper::PropertyInfo & rInfo, const css::uno::Any &rValue) = 0;
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ virtual void _postSetValues () = 0;
+
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ virtual void _preGetValues () = 0;
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::lang::WrappedTargetException
+ /// @throws css::uno::RuntimeException
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, css::uno::Any & rValue ) = 0;
+ /// @throws css::beans::UnknownPropertyException
+ /// @throws css::beans::PropertyVetoException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::lang::WrappedTargetException
+ virtual void _postGetValues () = 0;
+
+ public:
+ ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, SolarMutex* pMutex )
+ throw();
+ virtual ~ChainablePropertySet()
+ throw() override;
+
+ css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override
+ { return ChainablePropertySetBase::queryInterface( aType ); }
+ void SAL_CALL acquire( ) throw () override
+ { ChainablePropertySetBase::acquire( ); }
+ void SAL_CALL release( ) throw () override
+ { ChainablePropertySetBase::release( ); }
+
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
+ virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
+ virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+ virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
+
+ // XMultiPropertySet
+ virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Sequence< css::uno::Any >& aValues ) override;
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
+ virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+ virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
+
+ // XPropertyState
+ virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
+ virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
+ virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
+ virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
+ };
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/ChainablePropertySetInfo.hxx b/include/comphelper/ChainablePropertySetInfo.hxx
new file mode 100644
index 000000000..e35c534e7
--- /dev/null
+++ b/include/comphelper/ChainablePropertySetInfo.hxx
@@ -0,0 +1,64 @@
+/* -*- 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_COMPHELPER_CHAINABLEPROPERTYSETINFO_HXX
+#define INCLUDED_COMPHELPER_CHAINABLEPROPERTYSETINFO_HXX
+
+#include
+#include
+#include
+#include
+
+/*
+ * A ChainablePropertySetInfo is usually initialised with a pointer to the first element
+ * of a null-terminated static table of PropertyInfo structs. This is placed in a hash_map
+ * for fast access
+ *
+ */
+namespace comphelper
+{
+ // workaround for incremental linking bugs in MSVC2015
+ class SAL_DLLPUBLIC_TEMPLATE ChainablePropertySetInfo_Base : public cppu::WeakImplHelper< css::beans::XPropertySetInfo > {};
+
+ class COMPHELPER_DLLPUBLIC ChainablePropertySetInfo final : public ChainablePropertySetInfo_Base
+ {
+ public:
+ ChainablePropertySetInfo( PropertyInfo const * pMap );
+
+ void remove( const OUString& aName );
+
+ private:
+ virtual ~ChainablePropertySetInfo()
+ throw() override;
+
+ // XPropertySetInfo
+ virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override;
+ virtual css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
+
+ PropertyInfoHash maMap;
+ css::uno::Sequence < css::beans::Property > maProperties;
+
+ friend class ChainablePropertySet;
+ friend class MasterPropertySet;
+ };
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/DirectoryHelper.hxx b/include/comphelper/DirectoryHelper.hxx
new file mode 100644
index 000000000..61b0287e9
--- /dev/null
+++ b/include/comphelper/DirectoryHelper.hxx
@@ -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/.
+ */
+
+#pragma once
+
+#include
+
+#include
+#include
+#include
+
+namespace comphelper
+{
+class COMPHELPER_DLLPUBLIC DirectoryHelper
+{
+public:
+ static OUString splitAtLastToken(const OUString& rSrc, sal_Unicode aToken, OUString& rRight);
+ static bool fileExists(const OUString& rBaseURL);
+ static bool dirExists(const OUString& rDirURL);
+ static void scanDirsAndFiles(const OUString& rDirURL, std::set& rDirs,
+ std::set>& rFiles);
+ static bool deleteDirRecursively(const OUString& rDirURL);
+ static bool moveDirContent(const OUString& rSourceDirURL, const OUString& rTargetDirURL,
+ const std::set& rExcludeList);
+};
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/IdPropArrayHelper.hxx b/include/comphelper/IdPropArrayHelper.hxx
new file mode 100644
index 000000000..34e403b3a
--- /dev/null
+++ b/include/comphelper/IdPropArrayHelper.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_COMPHELPER_IDPROPARRAYHELPER_HXX
+#define INCLUDED_COMPHELPER_IDPROPARRAYHELPER_HXX
+
+#include
+
+#include
+ */
+ class OContextEntryGuard : public ::osl::ClearableMutexGuard
+ {
+ public:
+ /** constructs the guard
+
+ The given context (it's mutex, respectively) is locked, and an exception is thrown if the context
+ is not alive anymore. In the latter case, of course, the mutex is freed, again.
+
+ @param _pContext
+ the context which shall be guarded
+ @precond _pContext != NULL
+ */
+ inline OContextEntryGuard( OAccessibleContextHelper* _pContext );
+ };
+
+
+ inline OContextEntryGuard::OContextEntryGuard( OAccessibleContextHelper* _pContext )
+ : ::osl::ClearableMutexGuard( _pContext->GetMutex() )
+ {
+ _pContext->ensureAlive();
+ }
+
+
+ //= OExternalLockGuard
+
+ class OExternalLockGuard
+ :public osl::Guard
+ ,public OContextEntryGuard
+ {
+ public:
+ inline OExternalLockGuard( OAccessibleContextHelper* _pContext );
+ };
+
+
+ inline OExternalLockGuard::OExternalLockGuard( OAccessibleContextHelper* _pContext )
+ :osl::Guard( SolarMutex::get() )
+ ,OContextEntryGuard( _pContext )
+ {
+ // Only lock the external mutex,
+ // release the ::osl::Mutex of the OAccessibleContextHelper instance.
+ // If you call into another UNO object with locked ::osl::Mutex,
+ // this may lead to dead locks.
+ clear();
+ }
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLECONTEXTHELPER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accessibleeventnotifier.hxx b/include/comphelper/accessibleeventnotifier.hxx
new file mode 100644
index 000000000..75828cda6
--- /dev/null
+++ b/include/comphelper/accessibleeventnotifier.hxx
@@ -0,0 +1,116 @@
+/* -*- 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_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
+#define INCLUDED_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
+
+#include
+
+namespace com::sun::star::uno { class XInterface; }
+namespace com::sun::star::uno { template class Reference; }
+namespace com::sun::star::accessibility { class XAccessibleEventListener; }
+namespace com::sun::star::accessibility { struct AccessibleEventObject; }
+
+namespace comphelper {
+
+class COMPHELPER_DLLPUBLIC AccessibleEventNotifier
+{
+public:
+ typedef sal_uInt32 TClientId;
+
+public:
+ AccessibleEventNotifier() = delete;
+ ~AccessibleEventNotifier() = delete;
+ AccessibleEventNotifier( const AccessibleEventNotifier& ) = delete;
+ AccessibleEventNotifier& operator=( const AccessibleEventNotifier& ) = delete;
+
+ /** registers a client of this class, means a broadcaster of AccessibleEvents
+
+ No precaution is taken to care for disposal of this component. When the component
+ dies, it must call revokeClient or revokeClientNotifyDisposing
+ explicitly itself.
+ */
+ static TClientId registerClient();
+
+ /** revokes a broadcaster of AccessibleEvents
+
+ Note that no disposing event is fired when you use this method, the client is simply revoked.
+ You can for instance revoke a client if the last listener for it is revoked, but the client
+ itself is not disposed.
+ When the client is disposed, you should prefer revokeClientNotifyDisposing
+
+ Any possibly pending events for this client are removed from the queue.
+
+ @seealso revokeClientNotifyDisposing
+ */
+ static void revokeClient( const TClientId _nClient );
+
+ /** revokes a client, with additionally notifying a disposing event to all listeners registered for
+ this client
+
+ Any other possibly pending events for this client are removed from the queue
+
+ @param _nClient
+ the id of the client which should be revoked
+ @param _rxEventSource
+ the source to be notified together with the XComponent::disposing
+ call.
+ */
+ static void revokeClientNotifyDisposing(
+ const TClientId _nClient,
+ const css::uno::Reference< css::uno::XInterface >& _rxEventSource );
+
+ /** registers a listener for the given client
+
+ @param _nClient
+ the id of the client for which a listener should be registered
+ @return
+ the number of event listeners currently registered for this client
+ */
+ static sal_Int32 addEventListener(
+ const TClientId _nClient,
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& _rxListener );
+
+ /** revokes a listener for the given client
+
+ @param _nClient
+ the id of the client for which a listener should be revoked
+ @return
+ the number of event listeners currently registered for this client
+ */
+ static sal_Int32 removeEventListener(
+ const TClientId _nClient,
+ const css::uno::Reference< css::accessibility::XAccessibleEventListener >& _rxListener );
+
+ /** adds an event, which is to be broadcasted, to the queue
+
+ @param _nClient
+ the id of the client which needs to broadcast the event
+ */
+ static void addEvent(
+ const TClientId _nClient,
+ const css::accessibility::AccessibleEventObject& _rEvent );
+
+};
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accessiblekeybindinghelper.hxx b/include/comphelper/accessiblekeybindinghelper.hxx
new file mode 100644
index 000000000..4de48bf3e
--- /dev/null
+++ b/include/comphelper/accessiblekeybindinghelper.hxx
@@ -0,0 +1,73 @@
+/* -*- 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_COMPHELPER_ACCESSIBLEKEYBINDINGHELPER_HXX
+#define INCLUDED_COMPHELPER_ACCESSIBLEKEYBINDINGHELPER_HXX
+
+#include
+#include
+#include
+
+#include
+
+#include
+
+
+namespace comphelper
+{
+
+
+ // OAccessibleKeyBindingHelper
+
+
+ typedef ::cppu::WeakImplHelper < css::accessibility::XAccessibleKeyBinding
+ > OAccessibleKeyBindingHelper_Base;
+
+ /** a helper class for implementing an accessible keybinding
+ */
+ class COMPHELPER_DLLPUBLIC OAccessibleKeyBindingHelper final : public OAccessibleKeyBindingHelper_Base
+ {
+ private:
+ typedef ::std::vector< css::uno::Sequence< css::awt::KeyStroke > > KeyBindings;
+ KeyBindings m_aKeyBindings;
+ ::osl::Mutex m_aMutex;
+
+ virtual ~OAccessibleKeyBindingHelper() override;
+
+ public:
+ OAccessibleKeyBindingHelper();
+ OAccessibleKeyBindingHelper( const OAccessibleKeyBindingHelper& rHelper );
+
+ /// @throws css::uno::RuntimeException
+ void AddKeyBinding( const css::uno::Sequence< css::awt::KeyStroke >& rKeyBinding );
+ /// @throws css::uno::RuntimeException
+ void AddKeyBinding( const css::awt::KeyStroke& rKeyStroke );
+
+ // XAccessibleKeyBinding
+ virtual sal_Int32 SAL_CALL getAccessibleKeyBindingCount() override;
+ virtual css::uno::Sequence< css::awt::KeyStroke > SAL_CALL getAccessibleKeyBinding( sal_Int32 nIndex ) override;
+ };
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLEKEYBINDINGHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accessibleselectionhelper.hxx b/include/comphelper/accessibleselectionhelper.hxx
new file mode 100644
index 000000000..3a49c1ffd
--- /dev/null
+++ b/include/comphelper/accessibleselectionhelper.hxx
@@ -0,0 +1,135 @@
+/* -*- 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_COMPHELPER_ACCESSIBLESELECTIONHELPER_HXX
+#define INCLUDED_COMPHELPER_ACCESSIBLESELECTIONHELPER_HXX
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define ACCESSIBLE_SELECTION_CHILD_ALL (sal_Int32(-1))
+#define ACCESSIBLE_SELECTION_CHILD_SELF ((sal_Int32)-2)
+
+
+namespace comphelper
+{
+
+
+ //= OCommonAccessibleSelection
+
+ /** base class encapsulating common functionality for the helper classes implementing
+ the XAccessibleSelection
+ */
+ class COMPHELPER_DLLPUBLIC OCommonAccessibleSelection
+ {
+ protected:
+
+ OCommonAccessibleSelection();
+
+ ~OCommonAccessibleSelection();
+
+ protected:
+
+ // access to context - still waiting to be overwritten
+ /// @throws css::uno::RuntimeException
+ virtual css::uno::Reference< css::accessibility::XAccessibleContext >
+ implGetAccessibleContext() = 0;
+
+ // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
+ /// @throws css::uno::RuntimeException
+ virtual bool
+ implIsSelected( sal_Int32 nAccessibleChildIndex ) = 0;
+
+ // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
+ /// @throws css::uno::RuntimeException
+ virtual void
+ implSelect( sal_Int32 nAccessibleChildIndex, bool bSelect ) = 0;
+
+ protected:
+
+ /** non-virtual versions of the methods which can be implemented using implIsSelected and implSelect
+
+ @throws css::lang::IndexOutOfBoundsException
+ @throws css::uno::RuntimeException
+ */
+ void selectAccessibleChild( sal_Int32 nChildIndex );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::uno::RuntimeException
+ bool isAccessibleChildSelected( sal_Int32 nChildIndex );
+ /// @throws css::uno::RuntimeException
+ void clearAccessibleSelection( );
+ /// @throws css::uno::RuntimeException
+ void selectAllAccessibleChildren( );
+ /// @throws css::uno::RuntimeException
+ sal_Int32 getSelectedAccessibleChildCount( );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::uno::RuntimeException
+ css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::uno::RuntimeException
+ void deselectAccessibleChild( sal_Int32 nSelectedChildIndex );
+ };
+
+
+ //= OAccessibleSelectionHelper
+
+
+ typedef ::cppu::ImplHelper1< css::accessibility::XAccessibleSelection > OAccessibleSelectionHelper_Base;
+
+ /** a helper class for implementing an AccessibleSelection which at the same time
+ supports an XAccessibleSelection interface.
+ */
+ class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OAccessibleSelectionHelper : public OAccessibleComponentHelper,
+ public OCommonAccessibleSelection,
+ public OAccessibleSelectionHelper_Base
+ {
+ protected:
+
+ OAccessibleSelectionHelper();
+
+ // return ourself here by default
+ virtual css::uno::Reference< css::accessibility::XAccessibleContext > implGetAccessibleContext() override;
+
+ public:
+
+ // XInterface
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleSelection - default implementations
+ virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
+ virtual void SAL_CALL clearAccessibleSelection( ) override;
+ virtual void SAL_CALL selectAllAccessibleChildren( ) override;
+ virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
+ virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
+ };
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLESELECTIONHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accessibletexthelper.hxx b/include/comphelper/accessibletexthelper.hxx
new file mode 100644
index 000000000..576cc89cf
--- /dev/null
+++ b/include/comphelper/accessibletexthelper.hxx
@@ -0,0 +1,176 @@
+/* -*- 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_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
+#define INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
+
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::i18n { class XBreakIterator; }
+namespace com::sun::star::i18n { class XCharacterClassification; }
+namespace com::sun::star::i18n { struct Boundary; }
+
+namespace comphelper
+{
+
+
+ // OCommonAccessibleText
+
+ /** base class encapsulating common functionality for the helper classes implementing
+ the XAccessibleText
+ */
+ class COMPHELPER_DLLPUBLIC OCommonAccessibleText
+ {
+ private:
+ css::uno::Reference < css::i18n::XBreakIterator > m_xBreakIter;
+ css::uno::Reference < css::i18n::XCharacterClassification > m_xCharClass;
+
+ protected:
+ OCommonAccessibleText();
+ virtual ~OCommonAccessibleText();
+
+ css::uno::Reference < css::i18n::XBreakIterator > const & implGetBreakIterator();
+ css::uno::Reference < css::i18n::XCharacterClassification > const & implGetCharacterClassification();
+ static bool implIsValidBoundary( css::i18n::Boundary const & rBoundary, sal_Int32 nLength );
+ static bool implIsValidIndex( sal_Int32 nIndex, sal_Int32 nLength );
+ static bool implIsValidRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex, sal_Int32 nLength );
+ static sal_Unicode implGetCharacter( const OUString& rText, sal_Int32 nIndex );
+ static OUString implGetTextRange( const OUString& rText, sal_Int32 nStartIndex, sal_Int32 nEndIndex );
+ virtual OUString implGetText() = 0;
+ virtual css::lang::Locale implGetLocale() = 0;
+ virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) = 0;
+ void implGetGlyphBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
+ bool implGetWordBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
+ void implGetSentenceBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
+ virtual void implGetParagraphBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
+ virtual void implGetLineBoundary( const OUString& rText, css::i18n::Boundary& rBoundary, sal_Int32 nIndex );
+
+ /** non-virtual versions of the methods
+
+ @throws css::lang::IndexOutOfBoundsException
+ @throws css::uno::RuntimeException
+ */
+ OUString getSelectedText();
+ /// @throws css::uno::RuntimeException
+ sal_Int32 getSelectionStart();
+ /// @throws css::uno::RuntimeException
+ sal_Int32 getSelectionEnd();
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::uno::RuntimeException
+ css::accessibility::TextSegment getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::uno::RuntimeException
+ css::accessibility::TextSegment getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::lang::IllegalArgumentException
+ /// @throws css::uno::RuntimeException
+ css::accessibility::TextSegment getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType );
+
+ public:
+
+ /** Helper method, that detects the difference between
+ two strings and returns the deleted selection and
+ the inserted selection if available.
+
+ @returns true if there are differences between the
+ two strings and false if both are equal
+
+ @see css::accessibility::AccessibleEventId
+ css::accessibility::TextSegment
+ */
+ static bool implInitTextChangedEvent(
+ const OUString& rOldString,
+ const OUString& rNewString,
+ /*out*/ css::uno::Any& rDeleted,
+ /*out*/ css::uno::Any& rInserted); // throw()
+ };
+
+
+ // OAccessibleTextHelper
+
+
+ typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleText
+ > OAccessibleTextHelper_Base;
+
+ /** a helper class for implementing an AccessibleExtendedComponent which at the same time
+ supports an XAccessibleText interface
+ */
+ class COMPHELPER_DLLPUBLIC OAccessibleTextHelper : public OAccessibleExtendedComponentHelper,
+ public OCommonAccessibleText,
+ public OAccessibleTextHelper_Base
+ {
+ protected:
+ OAccessibleTextHelper();
+
+ public:
+ // XInterface
+ DECLARE_XINTERFACE( )
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleText
+ virtual OUString SAL_CALL getSelectedText() override;
+ virtual sal_Int32 SAL_CALL getSelectionStart() override;
+ virtual sal_Int32 SAL_CALL getSelectionEnd() override;
+ virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
+ virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
+ virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
+ };
+
+
+} // namespace comphelper
+
+
+// OAccessibleTextHelper is a helper class for implementing the
+// XAccessibleText interface.
+
+// The following methods have a default implementation:
+
+// getCharacter
+// getSelectedText
+// getSelectionStart
+// getSelectionEnd
+// getTextRange
+// getTextAtIndex
+// getTextBeforeIndex
+// getTextBehindIndex
+
+// The following methods must be overridden by derived classes:
+
+// implGetText
+// implGetLocale
+// implGetSelection
+// getCaretPosition
+// setCaretPosition
+// getCharacterAttributes
+// getCharacterBounds
+// getIndexAtPoint
+// setSelection
+// copyText
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLETEXTHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accessiblewrapper.hxx b/include/comphelper/accessiblewrapper.hxx
new file mode 100644
index 000000000..dd7da31a0
--- /dev/null
+++ b/include/comphelper/accessiblewrapper.hxx
@@ -0,0 +1,405 @@
+/* -*- 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_COMPHELPER_ACCESSIBLEWRAPPER_HXX
+#define INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
+
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::uno { class XComponentContext; }
+
+namespace comphelper
+{
+
+
+ //= OAccessibleWrapper
+
+
+ class OAccessibleContextWrapper;
+ class OWrappedAccessibleChildrenManager;
+
+ struct OAccessibleWrapper_Base :
+ public ::cppu::ImplHelper1 < css::accessibility::XAccessible >
+ {
+ protected:
+ ~OAccessibleWrapper_Base() {}
+ };
+
+ /** a class which aggregates a proxy for an XAccessible, and wrapping the context returned by this
+ XAccessible.
+ */
+ class COMPHELPER_DLLPUBLIC OAccessibleWrapper:public OAccessibleWrapper_Base
+ ,public OComponentProxyAggregation
+
+ {
+ private:
+ css::uno::Reference< css::accessibility::XAccessible >
+ m_xParentAccessible;
+ css::uno::WeakReference< css::accessibility::XAccessibleContext >
+ m_aContext;
+
+ protected:
+ css::uno::Reference< css::accessibility::XAccessible >
+ m_xInnerAccessible;
+
+ public:
+ /** ctor
+ @param _rxContext
+ a service factory
+
+ @param _rxInnerAccessible
+ the object to wrap
+
+ @param _rxParentAccessible
+ The XAccessible which is our parent
+ */
+ OAccessibleWrapper(
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxInnerAccessible,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
+ );
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // returns the context without creating it
+ css::uno::Reference< css::accessibility::XAccessibleContext >
+ getContextNoCreate( ) const;
+
+ protected:
+ virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL
+ getAccessibleContext( ) override;
+
+ const css::uno::Reference< css::accessibility::XAccessible >&
+ getParent() const { return m_xParentAccessible; }
+
+ // own overridables
+ virtual OAccessibleContextWrapper* createAccessibleContext(
+ const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerContext
+ );
+
+ protected:
+ virtual ~OAccessibleWrapper( ) override;
+
+ private:
+ OAccessibleWrapper( const OAccessibleWrapper& ) = delete;
+ OAccessibleWrapper& operator=( const OAccessibleWrapper& ) = delete;
+ };
+
+
+ //= OAccessibleContextWrapperHelper
+
+
+ typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleEventListener
+ > OAccessibleContextWrapperHelper_Base;
+
+ /** Helper for wrapping an XAccessibleContext by aggregating a proxy for it.
+
+ This class does not have own ref counting. In addition, it does not implement
+ the XAccessibleContext interface, but provides all the methods from this interface
+ which must be implemented using the inner context (such as getAccessibleChild*).
+
+ Children of the aggregated XAccessibleContext are wrapped, too.
+
+ AccessibleEvents fired by the inner context are multiplexed, especially, any references to
+ children in such events are translated. This means that even in such events, no un-wrapped object
+ will ever leave this class - if the aggregated context notifies a child event, the child passed
+ to the event is wrapped
+
+ @seealso OAccessibleContextWrapper
+ */
+ class COMPHELPER_DLLPUBLIC OAccessibleContextWrapperHelper
+ :private OComponentProxyAggregationHelper
+ ,public OAccessibleContextWrapperHelper_Base
+ {
+ protected:
+ /// the context we're wrapping (properly typed, in opposite to OComponentProxyAggregationHelper::m_xInner)
+ css::uno::Reference< css::accessibility::XAccessibleContext >
+ m_xInnerContext;
+ /// the XAccessible which created this context
+ css::uno::Reference< css::accessibility::XAccessible >
+ m_xOwningAccessible;
+ /// the XAccessible which is to be returned in getAccessibleParent
+ css::uno::Reference< css::accessibility::XAccessible >
+ m_xParentAccessible;
+
+ rtl::Reference m_xChildMapper; // for mapping children from our inner context to our callers
+
+ protected:
+ /** ctor
+
+ @param _rxContext
+ a service factory
+
+ @param _rxInnerAccessibleContext
+ the object to wrap
+
+ @param _rxOwningAccessible
+ The XAccessible which created this object. This is necessary because children
+ of our wrapped context need to be wrapped, too, and if they're asked for a parent,
+ they of course should return the proper parent
+ The object will be held with a hard reference
+
+ @param _rxParentAccessible
+ The XAccessible to return in the getAccessibleParent call
+ */
+ OAccessibleContextWrapperHelper(
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
+ ::cppu::OBroadcastHelper& _rBHelper,
+ const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
+ );
+
+ /// to be called from within your ctor - does the aggregation of a proxy for m_xInnerContext
+ void aggregateProxy(
+ oslInterlockedCount& _rRefCount,
+ ::cppu::OWeakObject& _rDelegator
+ );
+
+ protected:
+ // XInterface
+ css::uno::Any SAL_CALL queryInterface( const css::uno::Type& _rType ) override;
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleContext
+ /// @throws css::uno::RuntimeException
+ sal_Int32 baseGetAccessibleChildCount( );
+ /// @throws css::lang::IndexOutOfBoundsException
+ /// @throws css::uno::RuntimeException
+ css::uno::Reference< css::accessibility::XAccessible > baseGetAccessibleChild( sal_Int32 i );
+ /// @throws css::uno::RuntimeException
+ css::uno::Reference< css::accessibility::XAccessibleRelationSet > baseGetAccessibleRelationSet( );
+
+ // XAccessibleEventListener
+ virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override;
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ // XComponent/OComponentProxyAggregationHelper
+ virtual void SAL_CALL dispose() override;
+
+ // own overridables
+ /** notify an accessible event which has been translated (if necessary)
+
+ Usually, you derive your class from both OAccessibleContextWrapperHelper and XAccessibleEventBroadcaster,
+ and simply call all your XAccessibleEventListener with the given event.
+
+ The mutex of the BroadcastHelper passed to the instance's ctor is not locked when calling
+ into this method
+
+ @throws css::uno::RuntimeException
+ */
+ virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) = 0;
+
+ protected:
+ virtual ~OAccessibleContextWrapperHelper( ) override;
+
+ OAccessibleContextWrapperHelper(const OAccessibleContextWrapperHelper&) = delete;
+ OAccessibleContextWrapperHelper& operator=(const OAccessibleContextWrapperHelper&) = delete;
+ };
+
+
+ //= OAccessibleContextWrapper
+
+ typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessibleEventBroadcaster
+ , css::accessibility::XAccessibleContext
+ > OAccessibleContextWrapper_CBase;
+
+ class COMPHELPER_DLLPUBLIC OAccessibleContextWrapper
+ :public cppu::BaseMutex
+ ,public OAccessibleContextWrapper_CBase
+ ,public OAccessibleContextWrapperHelper
+ {
+ private:
+ ::comphelper::AccessibleEventNotifier::TClientId m_nNotifierClient; // for notifying AccessibleEvents
+
+ public:
+ /** ctor
+
+ @param _rxContext
+ a service factory
+
+ @param _rxInnerAccessibleContext
+ the object to wrap
+
+ @param _rxOwningAccessible
+ The XAccessible which created this object. This is necessary because children
+ of our wrapped context need to be wrapped, too, and if they're asked for a parent,
+ they of course should return the proper parent
+ The object will be held with a hard reference
+
+ @param _rxParentAccessible
+ The XAccessible to return in the getAccessibleParent call
+ */
+ OAccessibleContextWrapper(
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
+ const css::uno::Reference< css::accessibility::XAccessibleContext >& _rxInnerAccessibleContext,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible,
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxParentAccessible
+ );
+
+ // XInterface
+ DECLARE_XINTERFACE( )
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
+ virtual OUString SAL_CALL getAccessibleDescription( ) override;
+ virtual OUString SAL_CALL getAccessibleName( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
+ virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
+ virtual css::lang::Locale SAL_CALL getLocale( ) override;
+
+ // XAccessibleEventBroadcaster
+ virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
+ virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
+
+ // OAccessibleContextWrapper
+ virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) override;
+
+ // OComponentHelper
+ using OAccessibleContextWrapperHelper::disposing;
+ virtual void SAL_CALL disposing() override;
+
+ protected:
+ virtual ~OAccessibleContextWrapper() override;
+
+ private:
+ OAccessibleContextWrapper( const OAccessibleContextWrapper& ) = delete;
+ OAccessibleContextWrapper& operator=( const OAccessibleContextWrapper& ) = delete;
+ };
+
+
+ //= OWrappedAccessibleChildrenManager
+
+
+ typedef ::std::map < css::uno::Reference< css::accessibility::XAccessible >
+ , css::uno::Reference< css::accessibility::XAccessible >
+ > AccessibleMap;
+ // TODO: think about if we should hold these objects weak
+
+ typedef ::cppu::WeakImplHelper< css::lang::XEventListener
+ > OWrappedAccessibleChildrenManager_Base;
+ /** manages wrapping XAccessible's to XAccessible's
+ */
+ class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OWrappedAccessibleChildrenManager : public OWrappedAccessibleChildrenManager_Base
+ {
+ protected:
+ css::uno::Reference< css::uno::XComponentContext >
+ m_xContext;
+ css::uno::WeakReference< css::accessibility::XAccessible >
+ m_aOwningAccessible; // the XAccessible which belongs to the XAccessibleContext which we work for
+ AccessibleMap m_aChildrenMap; // for caching children
+ bool m_bTransientChildren; // are we prohibited to cache our children?
+
+ public:
+ /// ctor
+ OWrappedAccessibleChildrenManager(
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext
+ );
+
+ /** specifies if the children are to be considered transient (i.e.: not cached)
+ to be called only once per lifetime
+ */
+ void setTransientChildren( bool _bSet );
+
+ /** sets the XAccessible which belongs to the XAccessibleContext which we work for
+ to be called only once per lifetime
+ */
+ void setOwningAccessible( const css::uno::Reference< css::accessibility::XAccessible >& _rxAcc );
+
+ /// retrieves a wrapper for the given accessible
+ css::uno::Reference< css::accessibility::XAccessible >
+ getAccessibleWrapperFor(
+ const css::uno::Reference< css::accessibility::XAccessible >& _rxKey
+ );
+
+ /// erases the given key from the map (if it is present there)
+ void removeFromCache( const css::uno::Reference< css::accessibility::XAccessible >& _rxKey );
+
+ /// invalidates (i.e. empties) the map
+ void invalidateAll( );
+
+ /** disposes (i.e. clears) the manager
+
+ Note that the XAccessibleContext's of the mapped XAccessible objects are disposed, too.
+ */
+ void dispose();
+
+ /** handles a notification as got from the parent of the children we're managing
+ This applies only to the notifications which have a direct impact on our map.
+ */
+ void handleChildNotification( const css::accessibility::AccessibleEventObject& _rEvent );
+
+ /** translates events as got from the parent of the children we're managing
+ This applies only to the notifications which deal with child objects which we manage.
+ */
+ void translateAccessibleEvent(
+ const css::accessibility::AccessibleEventObject& _rEvent,
+ css::accessibility::AccessibleEventObject& _rTranslatedEvent
+ );
+
+ protected:
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ protected:
+ void implTranslateChildEventValue( const css::uno::Any& _rInValue, css::uno::Any& _rOutValue );
+
+ protected:
+ virtual ~OWrappedAccessibleChildrenManager( ) override;
+
+ private:
+ OWrappedAccessibleChildrenManager( const OWrappedAccessibleChildrenManager& ) = delete;
+ OWrappedAccessibleChildrenManager& operator=( const OWrappedAccessibleChildrenManager& ) = delete;
+ };
+
+
+} // namespace accessibility
+
+
+#endif // INCLUDED_COMPHELPER_ACCESSIBLEWRAPPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/accimplaccess.hxx b/include/comphelper/accimplaccess.hxx
new file mode 100644
index 000000000..46cce628b
--- /dev/null
+++ b/include/comphelper/accimplaccess.hxx
@@ -0,0 +1,75 @@
+/* -*- 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_COMPHELPER_ACCIMPLACCESS_HXX
+#define INCLUDED_COMPHELPER_ACCIMPLACCESS_HXX
+
+#include
+#include
+#include
+
+namespace comphelper
+{
+ //= OAccessibleImplementationAccess
+
+ typedef ::cppu::ImplHelper1 < css::lang::XUnoTunnel
+ > OAccImpl_Base;
+
+ /** This is a helper class which allows accessing several aspects of the implementation
+ of an AccessibleContext.
+
+ For instance, when you want to implement a context which can be re-parented, you:
+
- derive your class from OAccessibleImplementationAccess
+ - use
setAccessibleParent( component, new_parent )
+
+
+
+ Another aspect which can be controlled from the outside are states. If you have a class which
+ has only partial control over it's states, you may consider deriving from OAccessibleImplementationAccess.
+ For instance, say you have an implementation (say component A) which is unable to know or to
+ determine if the represented object is selected, but another component (say B) which uses A (and integrates
+ it into a tree of accessibility components) is.
+ In this case, if A is derived from OAccessibleImplementationAccess, B can manipulate this
+ foreign-controlled state flag "SELECTED" by using the static helper methods on this class.
+
+ Please note that the support for foreign controlled states is rather restrictive: You can't have states
+ which may be controlled by a foreign instances. This is implied by the fact that a derived
+ class can ask for states which are set only, not for the ones which are reset currently.
+
+ */
+ class COMPHELPER_DLLPUBLIC OAccessibleImplementationAccess : public OAccImpl_Base
+ {
+ protected:
+ OAccessibleImplementationAccess( );
+ virtual ~OAccessibleImplementationAccess( );
+
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& _rIdentifier ) override;
+
+ public:
+
+ private:
+ COMPHELPER_DLLPRIVATE static css::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+ };
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_ACCIMPLACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/anycompare.hxx b/include/comphelper/anycompare.hxx
new file mode 100644
index 000000000..782c7f199
--- /dev/null
+++ b/include/comphelper/anycompare.hxx
@@ -0,0 +1,218 @@
+/* -*- 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_COMPHELPER_ANYCOMPARE_HXX
+#define INCLUDED_COMPHELPER_ANYCOMPARE_HXX
+
+#include
+
+#include
+#include
+
+#include
+
+#include
+
+
+namespace comphelper
+{
+
+
+ //= IKeyPredicateLess
+
+ class SAL_NO_VTABLE IKeyPredicateLess
+ {
+ public:
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const = 0;
+ virtual ~IKeyPredicateLess() {}
+ };
+
+
+ //= LessPredicateAdapter
+
+ struct LessPredicateAdapter
+ {
+ LessPredicateAdapter( const IKeyPredicateLess& _predicate )
+ :m_predicate( _predicate )
+ {
+ }
+
+ bool operator()( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const
+ {
+ return m_predicate.isLess( _lhs, _rhs );
+ }
+
+ private:
+ IKeyPredicateLess const & m_predicate;
+ };
+
+
+ //= ScalarPredicateLess
+
+ template< typename SCALAR >
+ class ScalarPredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ SCALAR lhs(0), rhs(0);
+ if ( !( _lhs >>= lhs )
+ || !( _rhs >>= rhs )
+ )
+ throw css::lang::IllegalArgumentException();
+ return lhs < rhs;
+ }
+ };
+
+
+ //= StringPredicateLess
+
+ class StringPredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ OUString lhs, rhs;
+ if ( !( _lhs >>= lhs )
+ || !( _rhs >>= rhs )
+ )
+ throw css::lang::IllegalArgumentException();
+ return lhs < rhs;
+ }
+ };
+
+
+ //= StringCollationPredicateLess
+
+ class StringCollationPredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ StringCollationPredicateLess( css::uno::Reference< css::i18n::XCollator > const & i_collator )
+ :m_collator( i_collator )
+ {
+ }
+
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ OUString lhs, rhs;
+ if ( !( _lhs >>= lhs )
+ || !( _rhs >>= rhs )
+ )
+ throw css::lang::IllegalArgumentException();
+ return m_collator->compareString( lhs, rhs ) < 0;
+ }
+
+ private:
+ css::uno::Reference< css::i18n::XCollator > const m_collator;
+ };
+
+
+ //= TypePredicateLess
+
+ class TypePredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ css::uno::Type lhs, rhs;
+ if ( !( _lhs >>= lhs )
+ || !( _rhs >>= rhs )
+ )
+ throw css::lang::IllegalArgumentException();
+ return lhs.getTypeName() < rhs.getTypeName();
+ }
+ };
+
+
+ //= EnumPredicateLess
+
+ class EnumPredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ EnumPredicateLess( css::uno::Type const & _enumType )
+ :m_enumType( _enumType )
+ {
+ }
+
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ sal_Int32 lhs(0), rhs(0);
+ if ( !::cppu::enum2int( lhs, _lhs )
+ || !::cppu::enum2int( rhs, _rhs )
+ || !_lhs.getValueType().equals( m_enumType )
+ || !_rhs.getValueType().equals( m_enumType )
+ )
+ throw css::lang::IllegalArgumentException();
+ return lhs < rhs;
+ }
+
+ private:
+ css::uno::Type const m_enumType;
+ };
+
+
+ //= InterfacePredicateLess
+
+ class InterfacePredicateLess final : public IKeyPredicateLess
+ {
+ public:
+ virtual bool isLess( css::uno::Any const & _lhs, css::uno::Any const & _rhs ) const override
+ {
+ if ( ( _lhs.getValueTypeClass() != css::uno::TypeClass_INTERFACE )
+ || ( _rhs.getValueTypeClass() != css::uno::TypeClass_INTERFACE )
+ )
+ throw css::lang::IllegalArgumentException();
+
+ css::uno::Reference< css::uno::XInterface > lhs( _lhs, css::uno::UNO_QUERY );
+ css::uno::Reference< css::uno::XInterface > rhs( _rhs, css::uno::UNO_QUERY );
+ return lhs.get() < rhs.get();
+ }
+ };
+
+
+ //= getStandardLessPredicate
+
+ /** creates a default IKeyPredicateLess instance for the given UNO type
+ @param i_type
+ the type for which a predicate instance should be created
+ @param i_collator
+ specifies a collator instance to use, or . If , strings will be compared using the <
+ operator, otherwise the collator will be used. The parameter is ignored if i_type does not specify
+ the string type.
+ @return
+ a default implementation of IKeyPredicateLess, which is able to compare values of the given type. If no
+ such default implementation is known for the given type, then is returned.
+ */
+ ::std::unique_ptr< IKeyPredicateLess > COMPHELPER_DLLPUBLIC
+ getStandardLessPredicate(
+ css::uno::Type const & i_type,
+ css::uno::Reference< css::i18n::XCollator > const & i_collator
+ );
+
+ /**
+ Compare two Anys.
+ */
+ bool COMPHELPER_DLLPUBLIC anyLess( css::uno::Any const & lhs, css::uno::Any const & rhs);
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_ANYCOMPARE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/anytostring.hxx b/include/comphelper/anytostring.hxx
new file mode 100644
index 000000000..21afda1a6
--- /dev/null
+++ b/include/comphelper/anytostring.hxx
@@ -0,0 +1,44 @@
+/* -*- 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_COMPHELPER_ANYTOSTRING_HXX
+#define INCLUDED_COMPHELPER_ANYTOSTRING_HXX
+
+#include
+#include
+
+namespace com::sun::star::uno { class Any; }
+
+namespace comphelper
+{
+
+/** Creates a STRING representation out of an ANY value.
+
+ @param value
+ ANY value
+ @return
+ STRING representation of given ANY value
+*/
+COMPHELPER_DLLPUBLIC OUString anyToString( css::uno::Any const & value );
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/asyncnotification.hxx b/include/comphelper/asyncnotification.hxx
new file mode 100644
index 000000000..2daac286b
--- /dev/null
+++ b/include/comphelper/asyncnotification.hxx
@@ -0,0 +1,225 @@
+/* -*- 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_COMPHELPER_ASYNCNOTIFICATION_HXX
+#define INCLUDED_COMPHELPER_ASYNCNOTIFICATION_HXX
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace comphelper
+{
+ //= AnyEvent
+
+ /** the very basic instance to hold a description of an event
+ */
+ class COMPHELPER_DLLPUBLIC AnyEvent : public salhelper::SimpleReferenceObject
+ {
+ public:
+ AnyEvent();
+
+ protected:
+ virtual ~AnyEvent() override;
+
+ private:
+ AnyEvent( AnyEvent const & ) = delete;
+ AnyEvent& operator=( AnyEvent const & ) = delete;
+ };
+
+
+ //= typedefs
+
+ typedef ::rtl::Reference< AnyEvent > AnyEventRef;
+
+
+ //= IEventProcessor
+
+ /** an event processor
+
+ @see AsyncEventNotifier
+ */
+ class SAL_NO_VTABLE IEventProcessor
+ {
+ public:
+ /** process a single event
+ */
+ virtual void processEvent( const AnyEvent& _rEvent ) = 0;
+
+ virtual void SAL_CALL acquire() throw () = 0;
+ virtual void SAL_CALL release() throw () = 0;
+
+ protected:
+ ~IEventProcessor() {}
+ };
+
+
+ //= AsyncEventNotifier
+
+ struct EventNotifierImpl;
+
+ /** a helper class for notifying events asynchronously
+
+ If you need to notify certain events to external components, you usually should
+ not do this while you have mutexes locked, to prevent multi-threading issues.
+
+ However, you do not always have complete control over all mutex guards on the stack.
+ If, in such a case, the listener notification is one-way, you can decide to do it
+ asynchronously.
+
+ The ->AsyncEventNotifier helps you to process such events asynchronously. Every
+ event is tied to an ->IEventProcessor which is responsible for processing it.
+
+ The AsyncEventNotifier is implemented as a thread itself, which sleeps as long as there are no
+ events in the queue. As soon as you add an event, the thread is woken up, processes the event,
+ and sleeps again.
+ */
+ class COMPHELPER_DLLPUBLIC AsyncEventNotifierBase
+ {
+ friend struct EventNotifierImpl;
+
+ protected:
+ std::unique_ptr m_xImpl;
+
+ SAL_DLLPRIVATE virtual ~AsyncEventNotifierBase();
+
+ // Thread
+ SAL_DLLPRIVATE virtual void execute();
+
+ public:
+ AsyncEventNotifierBase();
+
+ /** terminates the thread
+
+ Note that this is a cooperative termination - if you call this from a thread different
+ from the notification thread itself, then it will block until the notification thread
+ finished processing the current event. If you call it from the notification thread
+ itself, it will return immediately, and the thread will be terminated as soon as
+ the current notification is finished.
+ */
+ virtual void SAL_CALL terminate();
+
+ /** adds an event to the queue, together with the instance which is responsible for
+ processing it
+
+ @param _rEvent
+ the event to add to the queue
+ @param _xProcessor
+ the processor for the event.
+ Beware of life time issues here. If your event processor dies or becomes otherwise
+ nonfunctional, you are responsible for removing all respective events from the queue.
+ You can do this by calling ->removeEventsForProcessor
+ */
+ void addEvent( const AnyEventRef& _rEvent, const ::rtl::Reference< IEventProcessor >& _xProcessor );
+
+ /** removes all events for the given event processor from the queue
+ */
+ void removeEventsForProcessor( const ::rtl::Reference< IEventProcessor >& _xProcessor );
+ };
+
+ /** This class is usable with rtl::Reference.
+ As always, the thread must be joined somewhere.
+ */
+ class COMPHELPER_DLLPUBLIC AsyncEventNotifier final
+ : public AsyncEventNotifierBase
+ , public salhelper::Thread
+ {
+
+ private:
+ SAL_DLLPRIVATE virtual ~AsyncEventNotifier() override;
+
+ SAL_DLLPRIVATE virtual void execute() override;
+
+ public:
+ /** constructs a notifier thread
+
+ @param name the thread name, see ::osl_setThreadName; must not be
+ null
+ */
+ AsyncEventNotifier(char const* name);
+
+ virtual void SAL_CALL terminate() override;
+ };
+
+ /** This is a hack (when proper joining is not possible), use of which
+ should be avoided by good design.
+ */
+ class COMPHELPER_DLLPUBLIC AsyncEventNotifierAutoJoin final
+ : public AsyncEventNotifierBase
+ , private osl::Thread
+ {
+
+ private:
+ SAL_DLLPRIVATE AsyncEventNotifierAutoJoin(char const* name);
+
+ SAL_DLLPRIVATE virtual void SAL_CALL run() override;
+ SAL_DLLPRIVATE virtual void SAL_CALL onTerminated() override;
+
+ public:
+ // only public so shared_ptr finds it
+ SAL_DLLPRIVATE virtual ~AsyncEventNotifierAutoJoin() override;
+
+ static std::shared_ptr
+ newAsyncEventNotifierAutoJoin(char const* name);
+
+ virtual void SAL_CALL terminate() override;
+
+ using osl::Thread::join;
+ using osl::Thread::operator new;
+ using osl::Thread::operator delete; // clang really wants this?
+
+ static void launch(std::shared_ptr const&);
+ };
+
+
+ //= EventHolder
+
+ /** AnyEvent derivee holding a foreign event instance
+ */
+ template < typename EVENT_OBJECT >
+ class SAL_DLLPUBLIC_RTTI EventHolder final : public AnyEvent
+ {
+ public:
+ typedef EVENT_OBJECT EventObjectType;
+
+ private:
+ EventObjectType const m_aEvent;
+
+ public:
+ EventHolder( const EventObjectType& _rEvent )
+ :m_aEvent( _rEvent )
+ {
+ }
+
+ const EventObjectType& getEventObject() const { return m_aEvent; }
+ };
+
+ COMPHELPER_DLLPUBLIC void JoinAsyncEventNotifiers();
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_ASYNCNOTIFICATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/asyncquithandler.hxx b/include/comphelper/asyncquithandler.hxx
new file mode 100644
index 000000000..9d994d177
--- /dev/null
+++ b/include/comphelper/asyncquithandler.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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_COMPHELPER_ASYNCQUITHANDLER_HXX
+#define INCLUDED_COMPHELPER_ASYNCQUITHANDLER_HXX
+
+#include
+#include
+
+// Use: Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ) );
+
+class COMPHELPER_DLLPUBLIC AsyncQuitHandler
+{
+ AsyncQuitHandler();
+
+ bool mbForceQuit;
+
+public:
+ AsyncQuitHandler(const AsyncQuitHandler&) = delete;
+ const AsyncQuitHandler& operator=(const AsyncQuitHandler&) = delete;
+
+ static AsyncQuitHandler& instance();
+ static void QuitApplication();
+
+ // Hack for the TerminationVetoer in extensions/source/ole/unoobjw.cxx. When it is an Automation
+ // client itself that explicitly requests a quit (see VbaApplicationBase::Quit()), we do quit.
+ // The flag can only be set to true, not back to false.
+ void SetForceQuit();
+ bool IsForceQuit() const;
+
+ DECL_STATIC_LINK(AsyncQuitHandler, OnAsyncQuit, void*, void);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/attributelist.hxx b/include/comphelper/attributelist.hxx
new file mode 100644
index 000000000..0309ab608
--- /dev/null
+++ b/include/comphelper/attributelist.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_COMPHELPER_ATTRIBUTELIST_HXX
+#define INCLUDED_COMPHELPER_ATTRIBUTELIST_HXX
+
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+namespace comphelper
+{
+
+struct TagAttribute
+{
+ OUString sName;
+ OUString sType;
+ OUString sValue;
+};
+
+class COMPHELPER_DLLPUBLIC AttributeList final :
+ public ::cppu::WeakImplHelper
+{
+ std::vector mAttributes;
+public:
+ AttributeList();
+ AttributeList(const AttributeList &r);
+
+ virtual ~AttributeList() override;
+
+ // methods that are not contained in any interface
+ void AddAttribute(const OUString &sName , const OUString &sType , const OUString &sValue)
+ {
+ mAttributes.push_back({sName, sType, sValue});
+ }
+ void Clear()
+ {
+ mAttributes.clear();
+ }
+
+ // css::xml::sax::XAttributeList
+ virtual sal_Int16 SAL_CALL getLength() override
+ {
+ return static_cast(mAttributes.size());
+ }
+ virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) override
+ {
+ return mAttributes[i].sName;
+ }
+ virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) override
+ {
+ return mAttributes[i].sType;
+ }
+ virtual OUString SAL_CALL getTypeByName(const OUString& aName) override;
+ virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) override
+ {
+ return mAttributes[i].sValue;
+ }
+ virtual OUString SAL_CALL getValueByName(const OUString& aName) override;
+
+ // css::util::XCloneable
+ virtual css::uno::Reference< XCloneable > SAL_CALL
+ createClone() override;
+};
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_ATTRIBUTELIST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/automationinvokedzone.hxx b/include/comphelper/automationinvokedzone.hxx
new file mode 100644
index 000000000..13b674efa
--- /dev/null
+++ b/include/comphelper/automationinvokedzone.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_AUTOMATIONINVOKEDZONE_HXX
+#define INCLUDED_COMPHELPER_AUTOMATIONINVOKEDZONE_HXX
+
+#include
+
+// Helpers for use when calling into LO from an Automation (OLE
+// Automation) client.
+
+namespace comphelper
+{
+namespace Automation
+{
+// Create an object of this class at the start of a function directly invoked from an Automation
+// client.
+
+class COMPHELPER_DLLPUBLIC AutomationInvokedZone
+{
+public:
+ AutomationInvokedZone();
+
+ ~AutomationInvokedZone();
+
+ static bool isActive();
+};
+}
+}
+
+#endif // INCLUDED_COMPHELPER_AUTOMATIONINVOKEDZONE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/backupfilehelper.hxx b/include/comphelper/backupfilehelper.hxx
new file mode 100644
index 000000000..e0a2ca244
--- /dev/null
+++ b/include/comphelper/backupfilehelper.hxx
@@ -0,0 +1,215 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_BACKUPFILEHELPER_HXX
+#define INCLUDED_COMPHELPER_BACKUPFILEHELPER_HXX
+
+#include
+
+#include
+#include
+#include
+#include
+
+namespace comphelper
+{
+ /** Helper class to backup/restore a single file
+ *
+ * This is a general class to manage backups/restore of the file
+ * given by the URL. The container holding the backups is created
+ * aside the original file, e.g for 'test.txt' a container
+ * called '.test.pack' will be used. If it was not yet backed-up
+ * this container file will be created at the 1st backup and deleted
+ * when the last gets removed. The container holds a stack with a
+ * maximum given number (in the constructor) of copies, these are by
+ * default compressed, but don't have to be (see tryPush).
+ *
+ * Due to being on a low system level here, no UNO API and not much
+ * other tooling can be used, as a consequence for the container a
+ * own simple format is used and e.g. the zip lib directly.
+ *
+ * You need to hand over the URL of the file to look at and
+ * a maximum number of allowed copies. That number is internally
+ * limited to an absolute max of 10 (see implementation). The number
+ * of allowed copies is limited to [1..max].
+ *
+ * Calling tryPush() will check if there is no backup yet or if
+ * there is one that the file has changed. If yes, a new copy is
+ * created on a kind of 'stack' of copies. The return value can
+ * be used to see if a backup was indeed created.
+ *
+ * Calling tryPop() will do the opposite: if a backup is available,
+ * delete the orig file and re-instantiate the backup. The backup
+ * is taken off the 'stack' of copies. The return value can be
+ * used to check if this was done.
+ *
+ * isPopPossible can be called to see if there is a backup available
+ * before calling tryPop().
+ *
+ * The 'stack' of copies works by using the same path, filename
+ * and extension, but adding a '_1' -> '_(num_of_copy)' to it.
+ */
+ class COMPHELPER_DLLPUBLIC BackupFileHelper
+ {
+ private:
+ // internal data
+ std::set< OUString > maDirs;
+ std::set< std::pair< OUString, OUString > > maFiles;
+
+ sal_uInt16 mnNumBackups;
+ sal_uInt16 mnMode;
+
+ bool mbActive;
+ bool mbExtensions;
+ bool mbCompress;
+
+ // internal flag if _exit() was called already - a hint to evtl.
+ // not create copies of potentially not well-defined data. This
+ // may be used in destructors of static instances - which unfortunately
+ // get called on WNT but not on linux. Thus I thought about encapsulating
+ // in some '#ifdefs', but it's just more safe to always do it and
+ // allows to add a SAL_WARN when one of these destructors is called
+ // after _exit()
+ static bool mbExitWasCalled;
+
+ // internal detector if SafeModeName dir exists
+ static bool mbSafeModeDirExists;
+
+ // internal upper limit (max) of allowed backups
+ static sal_uInt16 mnMaxAllowedBackups;
+
+ // path to User's configuration directory and derived strings
+ static OUString maInitialBaseURL;
+ static OUString maUserConfigBaseURL;
+ static OUString maUserConfigWorkURL;
+ static OUString maRegModName;
+ static OUString maExt;
+
+ // get path to User's configuration directory (created on-demand)
+ static const OUString& getInitialBaseURL();
+
+ // the name of the SafeMode directory for temporary processing
+ static const OUString& getSafeModeName();
+
+ public:
+ /** Constructor to handle Backups of the given file, will internally
+ * detect configuration values and URL to initial registrymodifications
+ * and thus the User configuration directory
+ */
+ BackupFileHelper();
+
+ // allow to set static global flag when app had to call _exit()
+ static void setExitWasCalled();
+ static bool getExitWasCalled();
+
+ // This call initializes the state of the UserDirectory as needed, it may
+ // initialize to SafeMode configuration or return from it by moving files
+ // in that directory
+ static void reactOnSafeMode(bool bSafeMode);
+
+ /** tries to create a new backup, if there is none yet, or if the
+ * last differs from the base file. It will then put a new version
+ * on the 'stack' of copies and evtl. delete the oldest backup.
+ * Also may cleanup older backups when NumBackups given in the
+ * constructor has changed.
+ *
+ * tryPushExtensionInfo is the specialized version for ExtensionInfo
+ */
+ void tryPush();
+ void tryPushExtensionInfo();
+
+ /** finds out if a restore is possible
+ *
+ * @return bool
+ * returns true if a restore to an older backup is possible
+ *
+ * isPopPossibleExtensionInfo is the specialized version for ExtensionInfo
+ */
+ bool isPopPossible();
+ bool isPopPossibleExtensionInfo() const;
+
+ /** tries to execute a restore. Will overwrite the base file
+ * in that case and take one version off the 'stack' of copies.
+ * Also may cleanup older backups when NumBackups given in the
+ * constructor has changed.
+ *
+ * tryPopExtensionInfo is the specialized version for ExtensionInfo
+ */
+ void tryPop();
+ void tryPopExtensionInfo();
+
+ /** tries to iterate the extensions and to disable all of them
+ */
+ static bool isTryDisableAllExtensionsPossible();
+ static void tryDisableAllExtensions();
+
+ /** Deinstall all User Extensions (installed for User only)
+ */
+ static bool isTryDeinstallUserExtensionsPossible();
+ static void tryDeinstallUserExtensions();
+
+ /** Reset shared Extensions
+ */
+ static bool isTryResetSharedExtensionsPossible();
+ static void tryResetSharedExtensions();
+
+ /** Reset bundled Extensions
+ */
+ static bool isTryResetBundledExtensionsPossible();
+ static void tryResetBundledExtensions();
+
+ /// Disables OpenGL and OpenCL
+ static void tryDisableHWAcceleration();
+
+ /** resets User-Customizations like Settings and UserInterface modifications
+ */
+ static bool isTryResetCustomizationsPossible();
+ static void tryResetCustomizations();
+
+ /** resets the whole UserProfile
+ */
+ static void tryResetUserProfile();
+
+ /** Return the profile url */
+ static const OUString& getUserProfileURL();
+
+ /** Return the url of the backed up profile (when in safe mode) */
+ static const OUString& getUserProfileWorkURL();
+
+ private:
+ // internal helper methods
+ static OUString getPackURL();
+ static const std::vector< OUString >& getCustomizationDirNames();
+ static const std::vector< OUString >& getCustomizationFileNames();
+
+ // file push helpers
+ bool tryPush_Files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
+ bool tryPush_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
+
+ // file pop possibilities helper
+ bool isPopPossible_files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
+ static bool isPopPossible_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
+
+ // file pop helpers
+ bool tryPop_files(const std::set< OUString >& rDirs, const std::set< std::pair< OUString, OUString > >& rFiles, const OUString& rSourceURL, const OUString& rTargetURL);
+ bool tryPop_file(const OUString& rSourceURL, const OUString& rTargetURL, const OUString& rName, const OUString& rExt);
+
+ // ExtensionInfo helpers
+ bool tryPush_extensionInfo(const OUString& rTargetURL);
+ static bool isPopPossible_extensionInfo(const OUString& rTargetURL);
+ bool tryPop_extensionInfo(const OUString& rTargetURL);
+
+ // FileDirInfo helpers
+ void fillDirFileInfo();
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/base64.hxx b/include/comphelper/base64.hxx
new file mode 100644
index 000000000..d962aabac
--- /dev/null
+++ b/include/comphelper/base64.hxx
@@ -0,0 +1,55 @@
+/* -*- 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_COMPHELPER_BASE64_HXX
+#define INCLUDED_COMPHELPER_BASE64_HXX
+
+#include
+
+#include
+#include
+#include
+
+namespace com::sun::star::uno { template class Sequence; }
+
+namespace comphelper {
+
+class COMPHELPER_DLLPUBLIC Base64
+{
+public:
+ /** encodes the given byte sequence into Base64 */
+ static void encode(OUStringBuffer& aStrBuffer, const css::uno::Sequence& aPass);
+
+ static void encode(OStringBuffer& aStrBuffer, const css::uno::Sequence& aPass);
+
+ // Decode a base 64 encoded string into a sequence of bytes. The first
+ // version can be used for attribute values only, because it does not
+ // return any chars left from conversion.
+ // For text submitted through the SAX characters call, the later method
+ // must be used!
+ static void decode(css::uno::Sequence& aPass, const OUString& sBuffer);
+
+ static sal_Int32 decodeSomeChars(css::uno::Sequence& aPass, const OUString& sBuffer);
+};
+
+}
+
+#endif // INCLUDED_COMPHELPER_BASE64_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/basicio.hxx b/include/comphelper/basicio.hxx
new file mode 100644
index 000000000..96e185d78
--- /dev/null
+++ b/include/comphelper/basicio.hxx
@@ -0,0 +1,88 @@
+/* -*- 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_COMPHELPER_BASICIO_HXX
+#define INCLUDED_COMPHELPER_BASICIO_HXX
+
+#include
+#include
+#include
+
+namespace com::sun::star::awt { struct FontDescriptor; }
+
+namespace comphelper
+{
+
+// bool
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, bool& _rVal);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, bool _bVal);
+void operator <<(
+ css::uno::Reference const &, sal_Bool)
+ = delete;
+
+// OUString
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, OUString& _rStr);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, const OUString& _rStr);
+
+// sal_Int16
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, sal_Int16& _rValue);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, sal_Int16 _nValue);
+
+// sal_uInt16
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, sal_uInt16& _rValue);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, sal_uInt16 _nValue);
+
+// sal_uInt32
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, sal_uInt32& _rValue);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, sal_uInt32 _nValue);
+
+// sal_Int16
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, sal_Int32& _rValue);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, sal_Int32 _nValue);
+
+// FontDescriptor
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator >> (const css::uno::Reference& InStream, css::awt::FontDescriptor& rVal);
+COMPHELPER_DLLPUBLIC const css::uno::Reference& operator << (const css::uno::Reference& OutStream, const css::awt::FontDescriptor& rVal);
+
+// sequences
+template
+const css::uno::Reference& operator >> (const css::uno::Reference& _rxInStream, css::uno::Sequence& _rSeq)
+{
+ _rSeq.realloc(_rxInStream->readLong());
+ for (ELEMENT& rElement : _rSeq)
+ _rxInStream >> rElement;
+ return _rxInStream;
+}
+
+template
+const css::uno::Reference& operator << (const css::uno::Reference& _rxOutStream, const css::uno::Sequence& _rSeq)
+{
+ _rxOutStream->writeLong(_rSeq.getLength());
+ for (const ELEMENT& rElement : _rSeq)
+ _rxOutStream << rElement;
+ return _rxOutStream;
+}
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_BASICIO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/broadcasthelper.hxx b/include/comphelper/broadcasthelper.hxx
new file mode 100644
index 000000000..65fa6d315
--- /dev/null
+++ b/include/comphelper/broadcasthelper.hxx
@@ -0,0 +1,51 @@
+/* -*- 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_COMPHELPER_BROADCASTHELPER_HXX
+#define INCLUDED_COMPHELPER_BROADCASTHELPER_HXX
+
+#include
+#include
+
+namespace comphelper
+{
+ // OMutexAndBroadcastHelper - a class which holds a Mutex and an OBroadcastHelper;
+ // needed because when deriving from OPropertySetHelper,
+ // the OBroadcastHelper has to be initialized before
+ // the OPropertySetHelper
+
+ class OMutexAndBroadcastHelper
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ ::cppu::OBroadcastHelper m_aBHelper;
+
+ public:
+ OMutexAndBroadcastHelper() : m_aBHelper( m_aMutex ) { }
+
+ ::osl::Mutex& GetMutex() { return m_aMutex; }
+ ::cppu::OBroadcastHelper& GetBroadcastHelper() { return m_aBHelper; }
+ const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return m_aBHelper; }
+
+ };
+}
+
+#endif // INCLUDED_COMPHELPER_BROADCASTHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/classids.hxx b/include/comphelper/classids.hxx
new file mode 100644
index 000000000..4c345b84b
--- /dev/null
+++ b/include/comphelper/classids.hxx
@@ -0,0 +1,334 @@
+/* -*- 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_COMPHELPER_CLASSIDS_HXX
+#define INCLUDED_COMPHELPER_CLASSIDS_HXX
+
+/*
+ * StarWriter
+ */
+
+/* 3.0 */
+
+#define SO3_SW_CLASSID_30 \
+ 0xDC5C7E40L, 0xB35C, 0x101B, 0x99, 0x61, 0x04, \
+ 0x02, 0x1C, 0x00, 0x70, 0x02
+
+/* 4.0 */
+
+#define SO3_SW_CLASSID_40 \
+ 0x8b04e9b0, 0x420e, 0x11d0, 0xa4, 0x5e, 0x0, \
+ 0xa0, 0x24, 0x9d, 0x57, 0xb1
+
+/* 5.0 */
+
+#define SO3_SW_CLASSID_50 \
+ 0xc20cf9d1, 0x85ae, 0x11d1, 0xaa, 0xb4, 0x0, \
+ 0x60, 0x97, 0xda, 0x56, 0x1a
+
+ /* 6.0, 7, 8 */
+
+#define SO3_SW_CLASSID_60 \
+ 0x8BC6B165, 0xB1B2, 0x4EDD, 0xAA, 0x47, 0xDA, \
+ 0xE2, 0xEE, 0x68, 0x9D, 0xD6
+
+ /* ole embed 6.0, 7 */
+
+#define SO3_SW_OLE_EMBED_CLASSID_60 \
+ 0x30a2652a, 0xddf7, 0x45e7, 0xac, 0xa6, 0x3e, \
+ 0xab, 0x26, 0xfc, 0x8a, 0x4e
+
+ /* ole embed 8 */
+
+#define SO3_SW_OLE_EMBED_CLASSID_8 \
+ 0xf616b81f, 0x7bb8, 0x4f22, 0xb8, 0xa5, 0x47, \
+ 0x42, 0x8d, 0x59, 0xf8, 0xad
+
+/* current */
+
+#define SO3_SW_CLASSID SO3_SW_CLASSID_60
+
+/*
+ * StarWriter/Web
+ */
+
+/* 6.0, 7, 8 */
+
+#define SO3_SWWEB_CLASSID_60 \
+ 0xA8BBA60C, 0x7C60, 0x4550, 0x91, 0xCE, 0x39, \
+ 0xC3, 0x90, 0x3F, 0xAC, 0x5E
+
+/* current */
+
+#define SO3_SWWEB_CLASSID SO3_SWWEB_CLASSID_60
+
+/*
+ * Globaldokument
+ */
+
+/* 6.0, 7, 8 */
+
+#define SO3_SWGLOB_CLASSID_60 \
+ 0xB21A0A7C, 0xE403, 0x41FE, 0x95, 0x62, 0xBD, \
+ 0x13, 0xEA, 0x6F, 0x15, 0xA0
+
+/* current */
+
+#define SO3_SWGLOB_CLASSID SO3_SWGLOB_CLASSID_60
+
+
+/*
+ * StarCalc
+ */
+
+/* 3.0 */
+
+#define SO3_SC_CLASSID_30 \
+ 0x3F543FA0L, 0xB6A6, 0x101B, 0x99, 0x61, 0x04, \
+ 0x02, 0x1C, 0x00, 0x70, 0x02
+
+/* 4.0 */
+
+#define SO3_SC_CLASSID_40 \
+ 0x6361d441L, 0x4235, 0x11d0, 0x89, 0xcb, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 5.0 */
+
+#define SO3_SC_CLASSID_50 \
+ 0xc6a5b861L, 0x85d6, 0x11d1, 0x89, 0xcb, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 6.0 */
+
+#define SO3_SC_CLASSID_60 \
+ 0x47BBB4CB, 0xCE4C, 0x4E80, 0xA5, 0x91, 0x42, \
+ 0xD9, 0xAE, 0x74, 0x95, 0x0F
+
+/* ole embed 6.0, 7 */
+
+#define SO3_SC_OLE_EMBED_CLASSID_60 \
+ 0x7b342dc4, 0x139a, 0x4a46, 0x8a, 0x93, 0xdb, \
+ 0x8, 0x27, 0xcc, 0xee, 0x9c
+
+/* ole embed 8 */
+
+#define SO3_SC_OLE_EMBED_CLASSID_8 \
+ 0x7fa8ae11, 0xb3e3, 0x4d88, 0xaa, 0xbf, 0x25, \
+ 0x55, 0x26, 0xcd, 0x1c, 0xe8
+
+/* current */
+
+#define SO3_SC_CLASSID SO3_SC_CLASSID_60
+
+/****************************************************
+* StarImpress
+****************************************************/
+
+/* 3.0 */
+
+#define SO3_SIMPRESS_CLASSID_30 \
+ 0xAF10AAE0L, 0xB36D, 0x101B, 0x99, 0x61, 0x04, \
+ 0x02, 0x1C, 0x00, 0x70, 0x02
+
+/* 4.0 */
+
+#define SO3_SIMPRESS_CLASSID_40 \
+ 0x12d3cc0L, 0x4216, 0x11d0, 0x89, 0xcb, 0x0, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 5.0 */
+
+#define SO3_SIMPRESS_CLASSID_50 \
+ 0x565c7221L, 0x85bc, 0x11d1, 0x89, 0xd0, 0x0, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 6.0 */
+
+#define SO3_SIMPRESS_CLASSID_60 \
+ 0x9176E48A, 0x637A, 0x4D1F, 0x80, 0x3B, 0x99, \
+ 0xD9, 0xBF, 0xAC, 0x10, 0x47
+
+/* ole embed 6.0, 7 */
+
+#define SO3_SIMPRESS_OLE_EMBED_CLASSID_60 \
+ 0xe5a0b632, 0xdfba, 0x4549, 0x93, 0x46, 0xe4, \
+ 0x14, 0xda, 0x6, 0xe6, 0xf8
+
+/* ole embed 8 */
+
+#define SO3_SIMPRESS_OLE_EMBED_CLASSID_8 \
+ 0xee5d1ea4, 0xd445, 0x4289, 0xb2, 0xfc, 0x55, \
+ 0xfc, 0x93, 0x69, 0x39, 0x17
+
+/* current */
+
+#define SO3_SIMPRESS_CLASSID SO3_SIMPRESS_CLASSID_60
+
+/****************************************************
+* StarDraw
+****************************************************/
+
+/* 5.0 */
+
+#define SO3_SDRAW_CLASSID_50 \
+ 0x2e8905a0L, 0x85bd, 0x11d1, 0x89, 0xd0, 0x0, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 6.0 */
+#define SO3_SDRAW_CLASSID_60 \
+ 0x4BAB8970, 0x8A3B, 0x45B3, 0x99, 0x1C, 0xCB, \
+ 0xEE, 0xAC, 0x6B, 0xD5, 0xE3
+
+/* ole embed 6.0, 7 */
+
+#define SO3_SDRAW_OLE_EMBED_CLASSID_60 \
+ 0x41662fc2, 0xd57, 0x4aff, 0xab, 0x27, 0xad, \
+ 0x2e, 0x12, 0xe7, 0xc2, 0x73
+
+/* ole embed 8 */
+
+#define SO3_SDRAW_OLE_EMBED_CLASSID_8 \
+ 0x448bb771, 0xcfe2, 0x47c4, 0xbc, 0xdf, 0x1f, \
+ 0xbf, 0x37, 0x8e, 0x20, 0x2c
+
+/* current */
+
+#define SO3_SDRAW_CLASSID SO3_SDRAW_CLASSID_60
+
+/****************************************************
+* StarChart
+****************************************************/
+
+/* 3.0 */
+
+#define SO3_SCH_CLASSID_30 \
+ 0xFB9C99E0L, 0x2C6D, 0x101C, 0x8E, 0x2C, 0x00, \
+ 0x00, 0x1B, 0x4C, 0xC7, 0x11
+
+/* 4.0 */
+
+#define SO3_SCH_CLASSID_40 \
+ 0x2b3b7e0L, 0x4225, 0x11d0, 0x89, 0xca, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 5.0 */
+
+#define SO3_SCH_CLASSID_50 \
+ 0xbf884321L, 0x85dd, 0x11d1, 0x89, 0xd0, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 6.0 */
+
+#define SO3_SCH_CLASSID_60 \
+ 0x12DCAE26, 0x281F, 0x416F, 0xA2, 0x34, 0xC3, \
+ 0x08, 0x61, 0x27, 0x38, 0x2E
+
+/* ole embed 6.0, 7 */
+
+#define SO3_SCH_OLE_EMBED_CLASSID_60 \
+ 0xd415cd93, 0x35c4, 0x4c6f, 0x81, 0x9d, 0xa6, \
+ 0x64, 0xa1, 0xc8, 0x13, 0xae
+
+/* ole embed 8 */
+
+#define SO3_SCH_OLE_EMBED_CLASSID_8 \
+ 0xdd0a57f, 0xcf3b, 0x4fd2, 0xbd, 0xa4, 0x94, \
+ 0x42, 0x71, 0x9b, 0x2a, 0x73
+
+/* current */
+
+#define SO3_SCH_CLASSID SO3_SCH_CLASSID_60
+
+// Report chart
+
+#define SO3_RPTCH_CLASSID \
+ 0x80243D39, 0x6741, 0x46C5, 0x92, 0x6E, 0x06, \
+ 0x91, 0x64, 0xFF, 0x87, 0xBB
+
+/***************************************************
+* StarMath
+***************************************************/
+
+/* 3.0 */
+
+#define SO3_SM_CLASSID_30 \
+ 0xD4590460L, 0x35FD, 0x101C, 0xB1, 0x2A, 0x04, \
+ 0x02, 0x1C, 0x00, 0x70, 0x02
+
+/* 4.0 */
+
+#define SO3_SM_CLASSID_40 \
+ 0x2b3b7e1L, 0x4225, 0x11d0, 0x89, 0xca, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 5.0 */
+
+#define SO3_SM_CLASSID_50 \
+ 0xffb5e640L, 0x85de, 0x11d1, 0x89, 0xd0, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+/* 6.0, 7, 8 */
+
+#define SO3_SM_CLASSID_60 \
+ 0x078B7ABA, 0x54FC, 0x457F, 0x85, 0x51, 0x61, \
+ 0x47, 0xE7, 0x76, 0xA9, 0x97
+
+/* ole embed 6.0, 7 */
+
+#define SO3_SM_OLE_EMBED_CLASSID_60 \
+ 0xd0484de6, 0xaaee, 0x468a, 0x99, 0x1f, 0x8d, \
+ 0x4b, 0x7, 0x37, 0xb5, 0x7a
+
+/* ole embed 8 */
+
+#define SO3_SM_OLE_EMBED_CLASSID_8 \
+ 0xd2d59cd1, 0xa6a, 0x4d36, 0xae, 0x20, 0x47, \
+ 0x81, 0x70, 0x77, 0xd5, 0x7c
+
+/* current */
+
+#define SO3_SM_CLASSID SO3_SM_CLASSID_60
+
+#define SO3_OUT_CLASSID \
+ 0x970b1e82, 0xcf2d, 0x11cf, 0x89, 0xca, 0x00, \
+ 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+#define SO3_DUMMY_CLASSID \
+ 0x970b1fff, 0xcf2d, 0x11cf, \
+ 0x89,0xca,0x00,0x80,0x29,0xe4,0xb0,0xb1
+
+#define SO3_APPLET_CLASSID \
+ 0x970b1e81, 0xcf2d, 0x11cf, \
+ 0x89,0xca,0x00,0x80,0x29,0xe4,0xb0,0xb1
+
+#define SO3_PLUGIN_CLASSID \
+ 0x4caa7761, 0x6b8b, 0x11cf, \
+ 0x89,0xca,0x0,0x80,0x29,0xe4,0xb0,0xb1
+
+#define SO3_IFRAME_CLASSID \
+ 0x1a8a6701, 0xde58, 0x11cf, \
+ 0x89, 0xca, 0x0, 0x80, 0x29, 0xe4, 0xb0, 0xb1
+
+#define SO3_RPT_CLASSID_90 \
+ 0xd7896d52, 0xb7af, 0x4820, \
+ 0x9d, 0xfe, 0xd4, 0x04, 0xd0, 0x15, 0x96, 0x0f
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/comphelperdllapi.h b/include/comphelper/comphelperdllapi.h
new file mode 100644
index 000000000..3416513b9
--- /dev/null
+++ b/include/comphelper/comphelperdllapi.h
@@ -0,0 +1,33 @@
+/* -*- 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_COMPHELPER_COMPHELPERDLLAPI_H
+#define INCLUDED_COMPHELPER_COMPHELPERDLLAPI_H
+
+#include
+
+#if defined(COMPHELPER_DLLIMPLEMENTATION)
+#define COMPHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define COMPHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define COMPHELPER_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif // INCLUDED_COMPHELPER_COMPHELPERDLLAPI_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/componentbase.hxx b/include/comphelper/componentbase.hxx
new file mode 100644
index 000000000..ce6353be4
--- /dev/null
+++ b/include/comphelper/componentbase.hxx
@@ -0,0 +1,139 @@
+/* -*- 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_COMPHELPER_COMPONENTBASE_HXX
+#define INCLUDED_COMPHELPER_COMPONENTBASE_HXX
+
+#include
+#include
+
+
+namespace comphelper
+{
+
+
+ //= ComponentBase
+
+ class COMPHELPER_DLLPUBLIC ComponentBase
+ {
+ protected:
+ /** creates a ComponentBase instance
+
+ The instance is not initialized. As a consequence, every ComponentMethodGuard instantiated for
+ this component will throw a css::lang::NotInitializedException,
+ until ->setInitialized() is called.
+ */
+ ComponentBase( ::cppu::OBroadcastHelper& _rBHelper )
+ :m_rBHelper( _rBHelper )
+ ,m_bInitialized( false )
+ {
+ }
+
+ struct NoInitializationNeeded { };
+
+ /** creates a ComponentBase instance
+
+ The instance is already initialized, so there's no need to call setInitialized later on. Use this
+ constructor for component implementations which do not require explicit initialization.
+ */
+ ComponentBase( ::cppu::OBroadcastHelper& _rBHelper, NoInitializationNeeded )
+ :m_rBHelper( _rBHelper )
+ ,m_bInitialized( true )
+ {
+ }
+
+ ~ComponentBase() COVERITY_NOEXCEPT_FALSE {}
+
+ /** marks the instance as initialized
+
+ Subsequent instantiations of a ComponentMethodGuard won't throw the NotInitializedException now.
+ */
+ void setInitialized() { m_bInitialized = true; }
+
+ public:
+ /// helper struct to grant access to selected public methods to the ComponentMethodGuard class
+ struct GuardAccess { friend class ComponentMethodGuard; private: GuardAccess() { } };
+
+ /// retrieves the component's mutex
+ ::osl::Mutex& getMutex( GuardAccess ) { return getMutex(); }
+ /// checks whether the component is already disposed, throws a DisposedException if so.
+ void checkDisposed( GuardAccess ) const;
+ /// checks whether the component is already initialized, throws a NotInitializedException if not.
+ void checkInitialized( GuardAccess ) const;
+
+ protected:
+ /// retrieves the component's broadcast helper
+ ::cppu::OBroadcastHelper& getBroadcastHelper() { return m_rBHelper; }
+ /// retrieves the component's mutex
+ ::osl::Mutex& getMutex() { return m_rBHelper.rMutex; }
+ /// determines whether the instance is already disposed
+ bool impl_isDisposed() const { return m_rBHelper.bDisposed; }
+
+ /// determines whether the component is already initialized
+ bool
+ impl_isInitialized_nothrow() const { return m_bInitialized; }
+
+ /** returns the context to be used when throwing exceptions
+
+ The default implementation returns .
+ */
+ static css::uno::Reference< css::uno::XInterface >
+ getComponent();
+
+ private:
+ ::cppu::OBroadcastHelper& m_rBHelper;
+ bool m_bInitialized;
+ };
+
+ class ComponentMethodGuard
+ {
+ public:
+ enum class MethodType
+ {
+ /// allow the method to be called only when being initialized and not being disposed
+ Default,
+ /// allow the method to be called without being initialized
+ WithoutInit
+
+ };
+
+ ComponentMethodGuard( ComponentBase& _rComponent, const MethodType _eType = MethodType::Default )
+ :m_aMutexGuard( _rComponent.getMutex( ComponentBase::GuardAccess() ) )
+ {
+ if ( _eType != MethodType::WithoutInit )
+ _rComponent.checkInitialized( ComponentBase::GuardAccess() );
+ _rComponent.checkDisposed( ComponentBase::GuardAccess() );
+ }
+
+ void clear()
+ {
+ m_aMutexGuard.clear();
+ }
+
+ private:
+ osl::ClearableMutexGuard m_aMutexGuard;
+ };
+
+
+} // namespace ComponentBase
+
+
+#endif // INCLUDED_COMPHELPER_COMPONENTBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/componentguard.hxx b/include/comphelper/componentguard.hxx
new file mode 100644
index 000000000..f3cf1bd5e
--- /dev/null
+++ b/include/comphelper/componentguard.hxx
@@ -0,0 +1,58 @@
+/* -*- 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_COMPHELPER_COMPONENTGUARD_HXX
+#define INCLUDED_COMPHELPER_COMPONENTGUARD_HXX
+
+#include
+
+#include
+#include
+
+
+namespace comphelper
+{
+
+
+ //= ComponentGuard
+
+ class ComponentGuard
+ {
+ public:
+ ComponentGuard( ::cppu::OWeakObject& i_component, ::cppu::OBroadcastHelper & i_broadcastHelper )
+ :m_aGuard( i_broadcastHelper.rMutex )
+ {
+ if ( i_broadcastHelper.bDisposed )
+ throw css::lang::DisposedException( OUString(), &i_component );
+ }
+
+ void clear() { m_aGuard.clear(); }
+ void reset() { m_aGuard.reset(); }
+
+ private:
+ ::osl::ResettableMutexGuard m_aGuard;
+ };
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_COMPONENTGUARD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/componentmodule.hxx b/include/comphelper/componentmodule.hxx
new file mode 100644
index 000000000..cfffcb39b
--- /dev/null
+++ b/include/comphelper/componentmodule.hxx
@@ -0,0 +1,168 @@
+/* -*- 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_COMPHELPER_COMPONENTMODULE_HXX
+#define INCLUDED_COMPHELPER_COMPONENTMODULE_HXX
+
+#include
+
+#include
+
+#include
+
+#include
+
+#include
+
+
+namespace comphelper
+{
+
+
+ /** factory declaration
+ */
+ typedef css::uno::Reference< css::lang::XSingleComponentFactory > (*FactoryInstantiation)
+ (
+ ::cppu::ComponentFactoryFunc _pFactoryFunc,
+ OUString const& _rComponentName,
+ css::uno::Sequence< OUString > const & _rServiceNames,
+ rtl_ModuleCount*
+ );
+
+
+ //= ComponentDescription
+
+ struct COMPHELPER_DLLPUBLIC ComponentDescription
+ {
+ /// the implementation name of the component
+ OUString const sImplementationName;
+ /// the services supported by the component implementation
+ css::uno::Sequence< OUString > const aSupportedServices;
+ /// the function to create an instance of the component
+ ::cppu::ComponentFactoryFunc const pComponentCreationFunc;
+ /// the function to create a factory for the component (usually ::cppu::createSingleComponentFactory
)
+ FactoryInstantiation const pFactoryCreationFunc;
+
+ ComponentDescription(
+ const OUString& _rImplementationName,
+ const css::uno::Sequence< OUString >& _rSupportedServices,
+ ::cppu::ComponentFactoryFunc _pComponentCreationFunc,
+ FactoryInstantiation _pFactoryCreationFunc
+ )
+ :sImplementationName( _rImplementationName )
+ ,aSupportedServices( _rSupportedServices )
+ ,pComponentCreationFunc( _pComponentCreationFunc )
+ ,pFactoryCreationFunc( _pFactoryCreationFunc )
+ {
+ }
+ };
+
+
+ //= OModule
+
+ class OModuleImpl;
+ class COMPHELPER_DLLPUBLIC OModule
+ {
+ private:
+ std::unique_ptr m_pImpl; /// impl class. lives as long as at least one client for the module is registered
+
+ protected:
+ mutable ::osl::Mutex m_aMutex; /// access safety
+
+ public:
+ OModule();
+
+ virtual ~OModule();
+
+ /** register a component implementing a service with the given data.
+ @param _rImplementationName
+ the implementation name of the component
+ @param _rServiceNames
+ the services the component supports
+ @param _pCreateFunction
+ a function for creating an instance of the component
+ @param _pFactoryFunction
+ a function for creating a factory for that component
+ */
+ void registerImplementation(
+ const OUString& _rImplementationName,
+ const css::uno::Sequence< OUString >& _rServiceNames,
+ ::cppu::ComponentFactoryFunc _pCreateFunction );
+
+ /** registers a component given by ComponentDescription
+ */
+ void registerImplementation( const ComponentDescription& _rComp );
+
+ /** creates a Factory for the component with the given implementation name.
+ Usually used from within component_getFactory.
+ @param _pImplementationName
+ the implementation name of the component
+ @return
+ the XInterface access to a factory for the component
+ */
+ css::uno::Reference< css::uno::XInterface > getComponentFactory(
+ const OUString& _rImplementationName );
+
+ /** version of getComponentFactory which directly takes the char argument you got in your component_getFactory call
+ */
+ void* getComponentFactory( const char* _pImplementationName );
+
+ private:
+ OModule( const OModule& ) = delete;
+ OModule& operator=( const OModule& ) = delete;
+ };
+
+
+ //= OAutoRegistration
+
+ template
+ class OAutoRegistration
+ {
+ public:
+ /** automatically provides all component information to an OModule instance
+ Assumed that the template argument has the three methods
+
+ static OUString getImplementationName_static()
+ static css::uno::Sequence< OUString > getSupportedServiceNames_static()
+ static css::uno::Reference< css::uno::XInterface >
+ Create(const css::uno::Reference< css::lang::XMultiServiceFactory >&)
+
+
+ the instantiation of this object will automatically register the class via OModule::registerImplementation.
+
+ The factory creation function used is ::cppu::createSingleComponentFactory
.
+ */
+ OAutoRegistration( OModule& _rModule );
+ };
+
+ template
+ OAutoRegistration::OAutoRegistration( OModule& _rModule )
+ {
+ _rModule.registerImplementation(
+ TYPE::getImplementationName_static(),
+ TYPE::getSupportedServiceNames_static(),
+ TYPE::Create
+ );
+ }
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_COMPONENTMODULE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/configuration.hxx b/include/comphelper/configuration.hxx
new file mode 100644
index 000000000..e56951281
--- /dev/null
+++ b/include/comphelper/configuration.hxx
@@ -0,0 +1,352 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_CONFIGURATION_HXX
+#define INCLUDED_COMPHELPER_CONFIGURATION_HXX
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star {
+ namespace configuration { class XReadWriteAccess; }
+ namespace container {
+ class XHierarchicalNameAccess;
+ class XHierarchicalNameReplace;
+ class XNameAccess;
+ class XNameContainer;
+ }
+ namespace uno { class XComponentContext; }
+}
+
+namespace comphelper {
+
+namespace detail { class ConfigurationWrapper; }
+
+/// A batch of configuration changes that is committed as a whole.
+///
+/// Client code needs to call commit explicitly; otherwise the changes are lost
+/// when the instance is destroyed.
+///
+/// This is the only class from this header file that client code should use
+/// directly.
+class COMPHELPER_DLLPUBLIC ConfigurationChanges {
+public:
+ static std::shared_ptr create(
+ css::uno::Reference< css::uno::XComponentContext >
+ const & context = comphelper::getProcessComponentContext());
+
+ ~ConfigurationChanges();
+
+ void commit() const;
+
+private:
+ ConfigurationChanges(const ConfigurationChanges&) = delete;
+ ConfigurationChanges& operator=(const ConfigurationChanges&) = delete;
+
+ SAL_DLLPRIVATE ConfigurationChanges(
+ css::uno::Reference< css::uno::XComponentContext >
+ const & context);
+
+ SAL_DLLPRIVATE void setPropertyValue(
+ OUString const & path, css::uno::Any const & value)
+ const;
+
+ SAL_DLLPRIVATE css::uno::Reference<
+ css::container::XHierarchicalNameReplace >
+ getGroup(OUString const & path) const;
+
+ SAL_DLLPRIVATE
+ css::uno::Reference< css::container::XNameContainer >
+ getSet(OUString const & path) const;
+
+ css::uno::Reference<
+ css::configuration::XReadWriteAccess > access_;
+
+ friend class detail::ConfigurationWrapper;
+};
+
+namespace detail {
+
+/// @internal
+class COMPHELPER_DLLPUBLIC ConfigurationWrapper {
+public:
+ static ConfigurationWrapper const & get(
+ css::uno::Reference< css::uno::XComponentContext >
+ const & context);
+
+ SAL_DLLPRIVATE explicit ConfigurationWrapper(
+ css::uno::Reference< css::uno::XComponentContext >
+ const & context);
+
+ SAL_DLLPRIVATE ~ConfigurationWrapper();
+
+ bool isReadOnly(OUString const & path) const;
+
+ css::uno::Any getPropertyValue(OUString const & path) const;
+
+ static void setPropertyValue(
+ std::shared_ptr< ConfigurationChanges > const & batch,
+ OUString const & path, css::uno::Any const & value);
+
+ css::uno::Any getLocalizedPropertyValue(
+ OUString const & path) const;
+
+ static void setLocalizedPropertyValue(
+ std::shared_ptr< ConfigurationChanges > const & batch,
+ OUString const & path, css::uno::Any const & value);
+
+ css::uno::Reference<
+ css::container::XHierarchicalNameAccess >
+ getGroupReadOnly(OUString const & path) const;
+
+ static css::uno::Reference<
+ css::container::XHierarchicalNameReplace >
+ getGroupReadWrite(
+ std::shared_ptr< ConfigurationChanges > const & batch,
+ OUString const & path);
+
+ css::uno::Reference< css::container::XNameAccess >
+ getSetReadOnly(OUString const & path) const;
+
+ static css::uno::Reference< css::container::XNameContainer >
+ getSetReadWrite(
+ std::shared_ptr< ConfigurationChanges > const & batch,
+ OUString const & path);
+
+ std::shared_ptr< ConfigurationChanges > createChanges() const;
+
+private:
+ ConfigurationWrapper(const ConfigurationWrapper&) = delete;
+ ConfigurationWrapper& operator=(const ConfigurationWrapper&) = delete;
+
+ css::uno::Reference< css::uno::XComponentContext > context_;
+
+ css::uno::Reference< css::configuration::XReadWriteAccess > access_;
+ // should really be a css.configuration.ReadOnlyAccess (with added
+ // css.beans.XHierarchicalPropertySetInfo), but then
+ // configmgr::Access::asProperty() would report all properties as
+ // READONLY, so isReadOnly() would not work
+};
+
+/// @internal
+template< typename T > struct Convert {
+ static css::uno::Any toAny(T const & value)
+ { return css::uno::makeAny(value); }
+
+ static T fromAny(css::uno::Any const & value)
+ { return value.get< T >(); }
+
+private:
+ Convert(const Convert&) = delete;
+ Convert& operator=(const Convert&) = delete;
+
+ Convert() = delete;
+ ~Convert() = delete;
+};
+
+/// @internal
+template< typename T > struct Convert< std::optional< T > >
+{
+ static css::uno::Any toAny(std::optional< T > const & value) {
+ return value
+ ? css::uno::makeAny(*value)
+ : css::uno::Any();
+ }
+
+ static std::optional< T > fromAny(css::uno::Any const & value)
+ {
+ return value.hasValue()
+ ? std::optional< T >(value.get< T >()) : std::optional< T >();
+ }
+
+private:
+ Convert(const Convert&) = delete;
+ Convert& operator=(const Convert&) = delete;
+
+ Convert() = delete;
+ ~Convert() = delete;
+};
+
+}
+
+/// A type-safe wrapper around a (non-localized) configuration property.
+///
+/// Automatically generated headers for the various configuration properties
+/// derive from this template and make available its member functions to access
+/// each given configuration property.
+template< typename T, typename U > struct ConfigurationProperty
+{
+ /// Get the read-only status of the given (non-localized) configuration
+ /// property.
+ static bool isReadOnly(
+ css::uno::Reference const & context
+ = comphelper::getProcessComponentContext())
+ {
+ return detail::ConfigurationWrapper::get(context).isReadOnly(T::path());
+ }
+
+ /// Get the value of the given (non-localized) configuration property.
+ ///
+ /// For nillable properties, U is of type std::optional.
+ static U get(
+ css::uno::Reference< css::uno::XComponentContext >
+ const & context = comphelper::getProcessComponentContext())
+ {
+ // Folding this into one statement causes a bogus error at least with
+ // Red Hat GCC 4.6.2-1:
+ css::uno::Any a(
+ detail::ConfigurationWrapper::get(context).getPropertyValue(
+ T::path()));
+ return detail::Convert< U >::fromAny(a);
+ }
+
+ /// Set the value of the given (non-localized) configuration property, via a
+ /// given changes batch.
+ ///
+ /// For nillable properties, U is of type std::optional.
+ static void set(
+ U const & value,
+ std::shared_ptr< ConfigurationChanges > const & batch)
+ {
+ comphelper::detail::ConfigurationWrapper::setPropertyValue(
+ batch, T::path(), detail::Convert< U >::toAny(value));
+ }
+
+private:
+ ConfigurationProperty(const ConfigurationProperty&) = delete;
+ ConfigurationProperty& operator=(const ConfigurationProperty&) = delete;
+
+ ConfigurationProperty() = delete;
+ ~ConfigurationProperty() = delete;
+};
+
+/// A type-safe wrapper around a localized configuration property.
+///
+/// Automatically generated headers for the various localized configuration
+/// properties derive from this template and make available its member functions
+/// to access each given localized configuration property.
+template< typename T, typename U > struct ConfigurationLocalizedProperty
+{
+ /// Get the value of the given localized configuration property, for the
+ /// locale currently set at the
+ /// com.sun.star.configuration.theDefaultProvider.
+ ///
+ /// For nillable properties, U is of type std::optional.
+ static U get(css::uno::Reference< css::uno::XComponentContext > const & context)
+ {
+ // Folding this into one statement causes a bogus error at least with
+ // Red Hat GCC 4.6.2-1:
+ css::uno::Any a(
+ detail::ConfigurationWrapper::get(context).
+ getLocalizedPropertyValue(T::path()));
+ return detail::Convert< U >::fromAny(a);
+ }
+
+ /// Set the value of the given localized configuration property, for the
+ /// locale currently set at the
+ /// com.sun.star.configuration.theDefaultProvider, via a given changes
+ /// batch.
+ ///
+ /// For nillable properties, U is of type std::optional.
+ static void set(
+ U const & value,
+ std::shared_ptr< ConfigurationChanges > const & batch)
+ {
+ comphelper::detail::ConfigurationWrapper::setLocalizedPropertyValue(
+ batch, T::path(), detail::Convert< U >::toAny(value));
+ }
+
+private:
+ ConfigurationLocalizedProperty(const ConfigurationLocalizedProperty&) = delete;
+ ConfigurationLocalizedProperty& operator=(const ConfigurationLocalizedProperty&) = delete;
+
+ ConfigurationLocalizedProperty() = delete;
+ ~ConfigurationLocalizedProperty() = delete;
+};
+
+/// A type-safe wrapper around a configuration group.
+///
+/// Automatically generated headers for the various configuration groups derive
+/// from this template and make available its member functions to access each
+/// given configuration group.
+template< typename T > struct ConfigurationGroup {
+ /// Get read-only access to the given configuration group.
+ static css::uno::Reference<
+ css::container::XHierarchicalNameAccess >
+ get(css::uno::Reference< css::uno::XComponentContext >
+ const & context = comphelper::getProcessComponentContext())
+ {
+ return detail::ConfigurationWrapper::get(context).getGroupReadOnly(
+ T::path());
+ }
+
+ /// Get read/write access to the given configuration group, storing any
+ /// modifications via the given changes batch.
+ static css::uno::Reference<
+ css::container::XHierarchicalNameReplace >
+ get(std::shared_ptr< ConfigurationChanges > const & batch)
+ {
+ return comphelper::detail::ConfigurationWrapper::getGroupReadWrite(
+ batch, T::path());
+ }
+
+private:
+ ConfigurationGroup(const ConfigurationGroup&) = delete;
+ ConfigurationGroup& operator=(const ConfigurationGroup&) = delete;
+
+ ConfigurationGroup() = delete;
+ ~ConfigurationGroup() = delete;
+};
+
+/// A type-safe wrapper around a configuration set.
+///
+/// Automatically generated headers for the various configuration sets derive
+/// from this template and make available its member functions to access each
+/// given configuration set.
+template< typename T > struct ConfigurationSet {
+ /// Get read-only access to the given configuration set.
+ static
+ css::uno::Reference< css::container::XNameAccess >
+ get(css::uno::Reference< css::uno::XComponentContext >
+ const & context = comphelper::getProcessComponentContext())
+ {
+ return detail::ConfigurationWrapper::get(context).getSetReadOnly(
+ T::path());
+ }
+
+ /// Get read/write access to the given configuration set, storing any
+ /// modifications via the given changes batch.
+ static
+ css::uno::Reference< css::container::XNameContainer >
+ get(std::shared_ptr< ConfigurationChanges > const & batch)
+ {
+ return comphelper::detail::ConfigurationWrapper::getSetReadWrite(
+ batch, T::path());
+ }
+
+private:
+ ConfigurationSet(const ConfigurationSet&) = delete;
+ ConfigurationSet& operator=(const ConfigurationSet&) = delete;
+
+ ConfigurationSet() = delete;
+ ~ConfigurationSet() = delete;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/configurationhelper.hxx b/include/comphelper/configurationhelper.hxx
new file mode 100644
index 000000000..162319316
--- /dev/null
+++ b/include/comphelper/configurationhelper.hxx
@@ -0,0 +1,239 @@
+/* -*- 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_COMPHELPER_CONFIGURATIONHELPER_HXX
+#define INCLUDED_COMPHELPER_CONFIGURATIONHELPER_HXX
+
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::uno { class XComponentContext; }
+namespace com::sun::star::uno { class XInterface; }
+
+namespace comphelper
+{
+ /** specify all possible modes, which can be used to open a configuration access.
+ *
+ * @see openConfig()
+ * @see readDirectKey()
+ * @see writeDirectKey()
+ */
+ enum class EConfigurationModes
+ {
+ /// opens configuration in read/write mode (without LAZY writing!)
+ Standard = 0,
+ /// configuration will be opened readonly
+ ReadOnly = 1,
+ /// all localized nodes will be interpreted as XInterface instead of interpreting it as atomic value nodes
+ AllLocales = 2
+ };
+
+
+}
+
+namespace o3tl
+{
+ template<> struct typed_flags : is_typed_flags {};
+}
+
+namespace comphelper
+{
+
+class COMPHELPER_DLLPUBLIC ConfigurationHelper
+{
+public:
+ /** returns access to the specified configuration package.
+ *
+ * This method should be used, if e.g. more than one request to the same
+ * configuration package is needed. The configuration access can be cached
+ * outside and used inbetween.
+ *
+ * @param rxContext
+ * the uno service manager, which should be used to create the
+ * configuration access.
+ *
+ * @param sPackage
+ * the name of the configuration package.
+ * e.g.
+ * - org.openoffice.Office.Common
+ * - org.openoffice.Office.Common/Menu
+ *
+ *
+ * @param eMode
+ * specify the open mode for the returned configuration access.
+ * It's interpreted as a flag field and can be any useful combination
+ * of values of EConfigurationModes.
+ *
+ * @throw Any exceptions the underlying configuration can throw.
+ * E.g. css::uno::Exception if the configuration could not be opened.
+ */
+ static css::uno::Reference< css::uno::XInterface > openConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sPackage,
+ EConfigurationModes eMode );
+
+
+ /** reads the value of an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relative to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relative path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should read the value.
+ *
+ * @return [css.uno.Any]
+ * the value of sKey.
+ *
+ * @throw Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists.
+ */
+ static css::uno::Any readRelativeKey(const css::uno::Reference< css::uno::XInterface >& xCFG ,
+ const OUString& sRelPath,
+ const OUString& sKey );
+
+
+ /** writes a new value for an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relative to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relative path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should write the new value.
+ *
+ * @param aValue
+ * the new value for sKey.
+ *
+ * @throw Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists or css::uno::Exception if the provided configuration
+ * access does not allow writing for this key.
+ */
+ static void writeRelativeKey(const css::uno::Reference< css::uno::XInterface >& xCFG ,
+ const OUString& sRelPath,
+ const OUString& sKey ,
+ const css::uno::Any& aValue );
+
+
+ /** it checks if the specified set node exists ... or create an empty one
+ * otherwise.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relative to this access point.
+ *
+ * Further this method must be used only with configuration set's.
+ * Atomic keys can't be "created"... they "exist every time".
+ *
+ * @param xCFG
+ * the configuration root, where sRelPathToSet should be interpreted
+ * as relative path.
+ *
+ * @param sRelPathToSet
+ * path relative to xCFG parameter.
+ *
+ * @param sSetNode
+ * the set node, which should be checked if its exists ...
+ * or which should be created with default values.
+ *
+ * @return A reference to the found (or new created) set node.
+ * Can't be NULL .. in such case an exception occurs!
+ *
+ * @throw Any exceptions the underlying configuration can throw.
+ * E.g. css::uno::Exception if the provided configuration
+ * access does not allow writing for this set.
+ */
+ static css::uno::Reference< css::uno::XInterface > makeSureSetNodeExists(const css::uno::Reference< css::uno::XInterface >& xCFG ,
+ const OUString& sRelPathToSet,
+ const OUString& sSetNode );
+
+
+ /** commit all changes made on the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here.
+ *
+ * @param xCFG
+ * the configuration root, where changes should be committed.
+ *
+ * @throw Any exceptions the underlying configuration can throw.
+ * E.g. css::uno::Exception if the provided configuration
+ * access does not allow writing for this set.
+ */
+ static void flush(const css::uno::Reference< css::uno::XInterface >& xCFG);
+
+
+ /** does the same then openConfig() & readRelativeKey() together.
+ *
+ * This method should be used for reading one key at one code place only.
+ * Because it opens the specified configuration package, reads the key and
+ * closes the configuration again.
+ *
+ * So it's not very useful to use this method for reading multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static css::uno::Any readDirectKey(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey ,
+ EConfigurationModes eMode );
+
+
+ /** does the same then openConfig() / writeRelativeKey() & flush() together.
+ *
+ * This method should be used for writing one key at one code place only.
+ * Because it opens the specified configuration package, writes the key, flush
+ * all changes and closes the configuration again.
+ *
+ * So it's not very useful to use this method for writing multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static void writeDirectKey(const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey ,
+ const css::uno::Any& aValue ,
+ EConfigurationModes eMode );
+};
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_CONFIGURATIONHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/configurationlistener.hxx b/include/comphelper/configurationlistener.hxx
new file mode 100644
index 000000000..29a2b578b
--- /dev/null
+++ b/include/comphelper/configurationlistener.hxx
@@ -0,0 +1,116 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_CONFIGURATIONLISTENER_HXX
+#define INCLUDED_COMPHELPER_CONFIGURATIONLISTENER_HXX
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::beans { struct PropertyChangeEvent; }
+namespace com::sun::star::uno { class XComponentContext; }
+
+namespace comphelper {
+
+class ConfigurationListener;
+
+class COMPHELPER_DLLPUBLIC ConfigurationListenerPropertyBase {
+public:
+ OUString maName;
+ rtl::Reference mxListener;
+
+ virtual ~ConfigurationListenerPropertyBase() {}
+ virtual void setProperty(const css::uno::Any &aProperty) = 0;
+ void dispose() { mxListener.clear(); }
+};
+
+/// Access to this class must be protected by the SolarMutex
+template< typename uno_type > class ConfigurationListenerProperty : public ConfigurationListenerPropertyBase
+{
+ uno_type maValue;
+protected:
+ virtual void setProperty(const css::uno::Any &aProperty) override
+ {
+ aProperty >>= maValue;
+ }
+public:
+ /**
+ * Provide a mirror of the configmgr's version of this property
+ * for the lifecycle of this property. The property value tracks
+ * the same value in the configuration.
+ */
+ inline ConfigurationListenerProperty(const rtl::Reference< ConfigurationListener > &xListener,
+ const OUString &rProp );
+
+ virtual inline ~ConfigurationListenerProperty() override;
+
+ uno_type get() const { return maValue; }
+};
+
+class COMPHELPER_DLLPUBLIC ConfigurationListener :
+ public cppu::WeakImplHelper< css::beans::XPropertyChangeListener >
+{
+ css::uno::Reference< css::beans::XPropertySet > mxConfig;
+ std::vector< ConfigurationListenerPropertyBase * > maListeners;
+public:
+ /// Public health warning, you -must- dispose this if you use it.
+ ConfigurationListener(const OUString &rPath,
+ css::uno::Reference< css::uno::XComponentContext >
+ const & xContext = comphelper::getProcessComponentContext())
+ : mxConfig( ConfigurationHelper::openConfig( xContext, rPath, EConfigurationModes::ReadOnly ),
+ css::uno::UNO_QUERY_THROW )
+ { }
+
+ virtual ~ConfigurationListener() override
+ {
+ dispose();
+ }
+
+ /// Listen for the specific property denoted by the listener
+ void addListener(ConfigurationListenerPropertyBase *pListener);
+
+ /// Stop listening.
+ void removeListener(ConfigurationListenerPropertyBase *pListener);
+
+ /// Release various circular references
+ void dispose();
+
+ // XPropertyChangeListener implementation
+ virtual void SAL_CALL disposing(css::lang::EventObject const &) override;
+
+ /// Notify of the property change
+ virtual void SAL_CALL propertyChange(
+ css::beans::PropertyChangeEvent const &rEvt ) override;
+};
+
+template< typename uno_type > ConfigurationListenerProperty< uno_type >::ConfigurationListenerProperty(const rtl::Reference< ConfigurationListener > &xListener, const OUString &rProp )
+ : maValue()
+{
+ maName = rProp;
+ mxListener = xListener;
+ mxListener->addListener(this);
+}
+
+template< typename uno_type > ConfigurationListenerProperty< uno_type >::~ConfigurationListenerProperty()
+{
+ if (mxListener.is())
+ mxListener->removeListener(this);
+}
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_CONFIGURATIONLISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/container.hxx b/include/comphelper/container.hxx
new file mode 100644
index 000000000..549469834
--- /dev/null
+++ b/include/comphelper/container.hxx
@@ -0,0 +1,77 @@
+/* -*- 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_COMPHELPER_CONTAINER_HXX
+#define INCLUDED_COMPHELPER_CONTAINER_HXX
+
+#include
+#include
+#include
+#include
+
+
+namespace comphelper
+{
+
+
+//= IndexAccessIterator
+
+/** an iterator that iterates through all elements, starting from an XIndexAccess (pre-order)
+*/
+class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) IndexAccessIterator
+{
+protected:
+ css::uno::Reference< css::uno::XInterface> m_xStartingPoint;
+
+ css::uno::Reference< css::uno::XInterface> m_xCurrentObject;
+ // The current object
+ ::std::vector m_arrChildIndizies;
+
+ // I'm moving through a tree, but its elements have no GetNextSibling,
+ // so I have to remember where each child is in relation to its parent.
+ // That is the path from the root node to m_xCurrentObject
+
+public:
+ IndexAccessIterator(css::uno::Reference< css::uno::XInterface> const & xStartingPoint);
+
+ virtual ~IndexAccessIterator();
+
+ css::uno::Reference< css::uno::XInterface> const & Next();
+
+ virtual void Invalidate() { m_xCurrentObject = nullptr; }
+
+protected:
+ virtual bool ShouldHandleElement(const css::uno::Reference< css::uno::XInterface>& /*rElement*/) { return true; }
+
+ // This can be used to exclude certain elements; elements for which
+ // this function returns sal_True will be simply skipped.
+ // If this element is returned from Next(), then one can get
+ // here get a little more information on the element.
+ // That's why this method is not const.
+ virtual bool ShouldStepInto(const css::uno::Reference< css::uno::XInterface>& /*xContainer*/) const { return true; }
+};
+
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_CONTAINER_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/containermultiplexer.hxx b/include/comphelper/containermultiplexer.hxx
new file mode 100644
index 000000000..b1c4f9dad
--- /dev/null
+++ b/include/comphelper/containermultiplexer.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_COMPHELPER_CONTAINERMULTIPLEXER_HXX
+#define INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
+
+#include
+#include
+#include
+#include
+
+namespace osl { class Mutex; }
+namespace com::sun::star::container { class XContainer; }
+
+
+namespace comphelper
+{
+
+
+ class OContainerListenerAdapter;
+
+ //= OContainerListener
+
+ /** a non-UNO container listener
+ Useful if you have a non-refcountable class which should act as container listener.
+ In this case, derive this class from OContainerListener, and create an adapter
+ OContainerListenerAdapter which multiplexes the changes.
+ */
+ class COMPHELPER_DLLPUBLIC OContainerListener
+ {
+ friend class OContainerListenerAdapter;
+ protected:
+ rtl::Reference m_xAdapter;
+ ::osl::Mutex& m_rMutex;
+
+ public:
+ OContainerListener(::osl::Mutex& _rMutex);
+ virtual ~OContainerListener();
+
+ /// @throws css::uno::RuntimeException
+ virtual void _elementInserted( const css::container::ContainerEvent& _rEvent );
+ /// @throws css::uno::RuntimeException
+ virtual void _elementRemoved( const css::container::ContainerEvent& _rEvent );
+ /// @throws css::uno::RuntimeException
+ virtual void _elementReplaced( const css::container::ContainerEvent& _rEvent );
+ /// @throws css::uno::RuntimeException
+ virtual void _disposing(const css::lang::EventObject& _rSource);
+
+ protected:
+ void setAdapter(OContainerListenerAdapter* _pAdapter);
+ };
+
+ // workaround for incremental linking bugs in MSVC2015
+ class SAL_DLLPUBLIC_TEMPLATE OContainerListenerAdapter_Base : public cppu::WeakImplHelper< css::container::XContainerListener > {};
+
+ class COMPHELPER_DLLPUBLIC OContainerListenerAdapter : public OContainerListenerAdapter_Base
+ {
+ friend class OContainerListener;
+
+ private:
+ css::uno::Reference< css::container::XContainer >
+ m_xContainer;
+ OContainerListener* m_pListener;
+
+ virtual ~OContainerListenerAdapter() override;
+
+ public:
+ OContainerListenerAdapter(OContainerListener* _pListener,
+ const css::uno::Reference< css::container::XContainer >& _rxContainer);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override;
+ virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override;
+ virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override;
+
+ /// dispose the object. No multiplexing anymore
+ void dispose();
+
+ };
+
+
+} // namespace dbaui
+
+
+#endif // INCLUDED_COMPHELPER_CONTAINERMULTIPLEXER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/crashzone.hxx b/include/comphelper/crashzone.hxx
new file mode 100644
index 000000000..6cbbe718f
--- /dev/null
+++ b/include/comphelper/crashzone.hxx
@@ -0,0 +1,72 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_CRASHZONE_H
+#define INCLUDED_COMPHELPER_CRASHZONE_H
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+struct CrashWatchdogTimingsValues
+{
+ /// delays to take various actions in 1/4 of a second increments.
+ int mnDisableEntries;
+ int const mnAbortAfter;
+};
+
+/**
+ * A generic class for detecting if a given crash or a lock-up came from a specific
+ * area of code (such as OpenGL).
+ * Use this helper to track that.
+ * The class is a template so that there can be multiple instances of static variables.
+ */
+template class CrashZone
+{
+// gnEnterCount and gnLeaveCount are accessed both from multiple threads (cf.
+// WatchdogThread::execute; so need to be of atomic type) and from signal handlers (cf.
+// VCLExceptionSignal_impl; so need to be of lock-free atomic type). sig_atomic_t is chosen as
+// the underlying type under the assumption that it is most likely to lead to an atomic type
+// that is actually lock-free. However, gnEnterCount and gnLeaveCount are both monotonically
+// increasing, so will eventually overflow, so the underlying type better be unsigned, which
+// sig_atomic_t is not guaranteed to be:
+#if !defined ARM32 || (defined ARM32 && defined __ARM_PCS_VFP)
+ using AtomicCounter = std::atomic>;
+ static_assert(AtomicCounter::is_always_lock_free);
+#else
+ using AtomicCounter = volatile std::make_unsigned_t;
+#endif
+
+ /// how many times have we entered a zone
+ static inline AtomicCounter gnEnterCount = 0;
+ /// how many times have we left a new zone
+ static inline AtomicCounter gnLeaveCount = 0;
+
+public:
+ CrashZone() { enter(); }
+ ~CrashZone() { leave(); }
+ static bool isInZone() { return gnEnterCount != gnLeaveCount; }
+ static const AtomicCounter& enterCount() { return gnEnterCount; }
+ // prefer creating instances to manually calling enter()/leave()
+ static void enter() { gnEnterCount++; }
+ static void leave() { gnLeaveCount++; }
+ // these should be implemented for each specific zone if needed
+ // static void hardDisable();
+ // static const CrashWatchdogTimingsValues& getCrashWatchdogTimingsValues();
+ // static void checkDebug(int nUnchanged, const CrashWatchdogTimingsValues& aTimingValues);
+ // static const char* name();
+};
+
+#endif // INCLUDED_COMPHELPER_CRASHZONE_H
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/debuggerinfo.hxx b/include/comphelper/debuggerinfo.hxx
new file mode 100644
index 000000000..8c4c0a4cb
--- /dev/null
+++ b/include/comphelper/debuggerinfo.hxx
@@ -0,0 +1,38 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_DEBUGINFO_HXX
+#define INCLUDED_COMPHELPER_DEBUGINFO_HXX
+
+#include
+
+namespace comphelper
+{
+#if defined DBG_UTIL
+/// Returns true if the process is running with a debugger attached.
+///
+/// This is useful to disable watchdogs or increase timeouts if they trigger
+/// too soon while using a debugger.
+COMPHELPER_DLLPUBLIC bool isDebuggerAttached();
+#endif
+
+// For detecting whether Valgrind is used, add valgrind to gb_Library_use_externals
+// and then in code use:
+// #if defined HAVE_VALGRIND_HEADERS
+// #include
+// #endif
+// ...
+// #if defined HAVE_VALGRIND_HEADERS
+// if( RUNNING_ON_VALGRIND )
+
+} // namespace comphelper
+
+#endif // INCLUDED_COMPHELPER_DEBUGINFO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/dispatchcommand.hxx b/include/comphelper/dispatchcommand.hxx
new file mode 100644
index 000000000..384536952
--- /dev/null
+++ b/include/comphelper/dispatchcommand.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/.
+ */
+
+#ifndef INCLUDED_COMPHELPER_DISPATCHCOMMAND_HXX
+#define INCLUDED_COMPHELPER_DISPATCHCOMMAND_HXX
+
+#include
+#include
+#include
+
+namespace com::sun::star::beans { struct PropertyValue; }
+namespace com::sun::star::frame { class XDispatchResultListener; class XFrame; }
+namespace com::sun::star::uno { template class Sequence; }
+
+namespace comphelper
+{
+
+/** Dispatch the given UNO command in the active frame.
+
+ @param rCommand the command to dispatch, like ".uno:Bold".
+
+ @return true on success.
+*/
+COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
+ const css::uno::Sequence& rArguments,
+ const css::uno::Reference& rListener = css::uno::Reference());
+
+COMPHELPER_DLLPUBLIC bool dispatchCommand(const OUString& rCommand,
+ const css::uno::Reference& rFrame,
+ const css::uno::Sequence& rArguments,
+ const css::uno::Reference& rListener = css::uno::Reference());
+
+}
+
+#endif // INCLUDED_COMPHELPER_DISPATCHCOMMAND_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/docpasswordhelper.hxx b/include/comphelper/docpasswordhelper.hxx
new file mode 100644
index 000000000..7505e3bdf
--- /dev/null
+++ b/include/comphelper/docpasswordhelper.hxx
@@ -0,0 +1,428 @@
+/* -*- 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_COMPHELPER_DOCPASSWORDHELPER_HXX
+#define INCLUDED_COMPHELPER_DOCPASSWORDHELPER_HXX
+
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::task { class XInteractionHandler; }
+namespace com::sun::star::beans { struct PropertyValue; }
+namespace com::sun::star::beans { struct NamedValue; }
+
+namespace comphelper {
+
+enum class DocPasswordVerifierResult
+{
+ OK,
+ WrongPassword,
+ Abort
+};
+
+
+/** Base class for a password verifier used by the DocPasswordHelper class
+ below.
+
+ Users have to implement the virtual functions and pass an instance of the
+ verifier to one of the password request functions.
+ */
+class COMPHELPER_DLLPUBLIC IDocPasswordVerifier
+{
+public:
+ virtual ~IDocPasswordVerifier();
+
+ /** Will be called every time a password needs to be verified.
+
+ @param rPassword
+ The password to be verified
+
+ @param o_rEncryptionData
+ Output parameter, that is filled with the EncryptionData generated
+ from the password. The data is filled only if the validation was
+ successful.
+
+ @return The result of the verification.
+ - DocPasswordVerifierResult_OK, if and only if the passed password
+ is valid and can be used to process the related document.
+ - DocPasswordVerifierResult_WRONG_PASSWORD, if the password is
+ wrong. The user may be asked again for a new password.
+ - DocPasswordVerifierResult_ABORT, if an unrecoverable error
+ occurred while password verification. The password request loop
+ will be aborted.
+ */
+ virtual DocPasswordVerifierResult verifyPassword( const OUString& rPassword, css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData ) = 0;
+
+ /** Will be called every time an encryption data needs to be verified.
+
+ @param rEncryptionData
+ The data will be validated
+
+ @return The result of the verification.
+ - DocPasswordVerifierResult_OK, if and only if the passed encryption data
+ is valid and can be used to process the related document.
+ - DocPasswordVerifierResult_WRONG_PASSWORD, if the encryption data is
+ wrong.
+ - DocPasswordVerifierResult_ABORT, if an unrecoverable error
+ occurred while data verification. The password request loop
+ will be aborted.
+ */
+ virtual DocPasswordVerifierResult verifyEncryptionData( const css::uno::Sequence< css::beans::NamedValue >& o_rEncryptionData ) = 0;
+
+};
+
+
+/** Helper that asks for a document password and checks its validity.
+ */
+class COMPHELPER_DLLPUBLIC DocPasswordHelper
+{
+public:
+
+
+ /** This helper function generates the information related
+ to "Password to modify" provided by user. The result
+ sequence contains the hash and the algorithm-related
+ info.
+
+ @param aString
+ The string for which the info should be generated
+
+ @return
+ The sequence containing the hash and the algorithm-related info
+ */
+
+ static css::uno::Sequence< css::beans::PropertyValue >
+ GenerateNewModifyPasswordInfo( const OUString& aPassword );
+
+
+ /** This helper function allows to check whether
+ the "Password to modify" provided by user is the correct one.
+
+ @param aString
+ The string containing the provided password
+
+ @param aInfo
+ The sequence containing the hash and the algorithm-info
+
+ @return
+ if the password is correct one
+ otherwise
+ */
+
+ static bool IsModifyPasswordCorrect(
+ const OUString& aPassword,
+ const css::uno::Sequence< css::beans::PropertyValue >& aInfo );
+
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" feature of Word.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @return
+ The hash represented by sal_uInt32
+ */
+
+ static sal_uInt32 GetWordHashAsUINT32(
+ const OUString& aString );
+
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" and passwords related to
+ table protection of Excel.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @param nEnc
+ The encoding that should be used to generate the 8-bit string
+ before the hash is generated
+
+ @return
+ The hash represented by sal_uInt16
+ */
+
+ static sal_uInt16 GetXLHashAsUINT16(
+ const OUString& aString,
+ rtl_TextEncoding nEnc = RTL_TEXTENCODING_UTF8 );
+
+
+ /** This helper function generates the hash code based on the algorithm
+ specified by MS for "Password to modify" and passwords related to
+ table protection.
+
+ @param aString
+ The string for which the hash should be calculated
+
+ @return
+ The hash represented by sequence of bytes in BigEndian form
+ */
+
+ static css::uno::Sequence< sal_Int8 > GetXLHashAsSequence(
+ const OUString& aString );
+
+
+ /** Convenience function to calculate a salted hash with iterations as
+ specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
+
+ @param rPassword
+ UTF-16 encoded string without leading BOM character
+
+ @param rSaltValue
+ Base64 encoded salt that will be decoded and prepended to password
+ data.
+
+ @param nSpinCount
+ If >0 the number of repeated iterations.
+
+ @param eIterCount
+ If Hash::IterCount::APPEND, append iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If Hash::IterCount::PREPEND, prepend iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+ If Hash::IterCount::NONE, do not add the iteration count to hash
+ iterations.
+
+ @param rAlgorithmName
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
+ https://msdn.microsoft.com/en-us/library/dd920692
+ or "SHA512", "SHA256", ... as listed for HashAlgorithm in
+ https://msdn.microsoft.com/en-us/library/dd925810
+ that have a valid match in comphelper::HashType. If not, an
+ empty sequence is returned. Not all algorithm names are
+ supported.
+
+ @return the raw hash value as sal_Int8 sequence.
+ */
+ static css::uno::Sequence GetOoxHashAsSequence(
+ const OUString& rPassword,
+ const OUString& rSaltValue,
+ sal_uInt32 nSpinCount,
+ comphelper::Hash::IterCount eIterCount,
+ const OUString& rAlgorithmName);
+
+
+ /** Convenience function to calculate a salted hash with iterations as
+ specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
+
+ @param rPassword
+ UTF-16 encoded string without leading BOM character
+
+ @param rSaltValue
+ Base64 encoded salt that will be decoded and prepended to password
+ data.
+
+ @param nSpinCount
+ If >0 the number of repeated iterations.
+
+ @param eIterCount
+ If Hash::IterCount::APPEND, append iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If Hash::IterCount::PREPEND, prepend iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+ If Hash::IterCount::NONE, do not add the iteration count to hash
+ iterations.
+
+ @param rAlgorithmName
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
+ https://msdn.microsoft.com/en-us/library/dd920692
+ or "SHA512", "SHA256", ... as listed for HashAlgorithm in
+ https://msdn.microsoft.com/en-us/library/dd925810
+ that have a valid match in comphelper::HashType. If not, an
+ empty sequence is returned. Not all algorithm names are
+ supported.
+
+ @return the base64 encoded string of the hash value, that can be
+ compared against a stored base64 encoded hash value.
+ */
+ static OUString GetOoxHashAsBase64(
+ const OUString& rPassword,
+ const OUString& rSaltValue,
+ sal_uInt32 nSpinCount,
+ comphelper::Hash::IterCount eIterCount,
+ const OUString& rAlgorithmName);
+
+
+ /** Convenience function to calculate a salted hash with iterations as
+ specified in https://msdn.microsoft.com/en-us/library/dd920692 for the
+ OOXML sheetProtection and fileSharing elements, or
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430 for Standard and
+ Agile Encryption.
+
+ @param rPassword
+ UTF-16 encoded string without leading BOM character
+
+ @param rSaltValue
+ A raw salt that will be prepended to password data.
+
+ @param nSpinCount
+ If >0 the number of repeated iterations.
+
+ @param eIterCount
+ If Hash::IterCount::APPEND, append iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd920692
+ If Hash::IterCount::PREPEND, prepend iteration count as per
+ https://msdn.microsoft.com/en-us/library/dd924776 and
+ https://msdn.microsoft.com/en-us/library/dd925430
+ If Hash::IterCount::NONE, do not add the iteration count to hash
+ iterations.
+
+ @param rAlgorithmName
+ One of "SHA-512", "SHA-256", ... as listed for AlgorithmName in
+ https://msdn.microsoft.com/en-us/library/dd920692
+ or "SHA512", "SHA256", ... as listed for HashAlgorithm in
+ https://msdn.microsoft.com/en-us/library/dd925810
+ that have a valid match in comphelper::HashType. If not, an
+ empty sequence is returned. Not all algorithm names are
+ supported.
+
+ @return the raw the hash value.
+ */
+ static std::vector GetOoxHashAsVector(
+ const OUString& rPassword,
+ const std::vector& rSaltValue,
+ sal_uInt32 nSpinCount,
+ comphelper::Hash::IterCount eIterCount,
+ const OUString& rAlgorithmName);
+
+
+ /** This helper function generates a random sequence of bytes of
+ requested length.
+ */
+
+ static css::uno::Sequence< sal_Int8 > GenerateRandomByteSequence(
+ sal_Int32 nLength );
+
+
+ /** This helper function generates a byte sequence representing the
+ key digest value used by MSCodec_Std97 codec.
+ */
+
+ static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
+ const OUString& aPassword,
+ const css::uno::Sequence< sal_Int8 >& aDocId );
+
+
+ /** This helper function generates a byte sequence representing the
+ key digest value used by MSCodec_Std97 codec.
+ */
+
+ static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
+ const sal_uInt16 pPassData[16],
+ const css::uno::Sequence< sal_Int8 >& aDocId );
+
+ /** This helper function generates a byte sequence representing the
+ key digest value used by MSCodec_Std97 codec.
+ */
+
+ static css::uno::Sequence< sal_Int8 > GenerateStd97Key(
+ const sal_uInt16 pPassData[16],
+ const sal_uInt8 pDocId[16] );
+
+
+ /** This helper function tries to request and verify a password to load a
+ protected document.
+
+ First, the list of default passwords will be tried if provided. This is
+ needed by import filters for external file formats that have to check a
+ predefined password in some cases without asking the user for a
+ password. Every password is checked using the passed password verifier.
+
+ If not successful, the passed password of a medium is tried, that has
+ been set e.g. by an API call to load a document. If existing, the
+ password is checked using the passed password verifier.
+
+ If still not successful, the passed interaction handler is used to
+ request a password from the user. This will be repeated until the
+ passed password verifier validates the entered password, or if the user
+ chooses to cancel password input.
+
+ @param rVerifier
+ The password verifier used to check every processed password.
+
+ @param rMediaPassword
+ If not empty, will be passed to the password validator before
+ requesting a password from the user. This password usually should
+ be querried from a media descriptor.
+
+ @param rxInteractHandler
+ The interaction handler that will be used to request a password
+ from the user, e.g. by showing a password input dialog.
+
+ @param rDocumentUrl
+ The URL of the related document that will be shown in the password
+ input dialog.
+
+ @param eRequestType
+ The password request type that will be passed to the
+ DocPasswordRequest object created internally. See
+ docpasswordrequest.hxx for more details.
+
+ @param pDefaultPasswords
+ If not null, contains default passwords that will be tried before a
+ password will be requested from the media descriptor or the user.
+
+ @param pbIsDefaultPassword
+ (output parameter) If not null, the type of the found password will
+ be returned. True means the password has been found in the passed
+ list of default passwords. False means the password has been taken
+ from the rMediaPassword parameter or has been entered by the user.
+
+ @return
+ If not empty, contains the password that has been validated by the
+ passed password verifier. If empty, no valid password has been
+ found, or the user has chosen to cancel password input.
+ */
+ static css::uno::Sequence< css::beans::NamedValue > requestAndVerifyDocPassword(
+ IDocPasswordVerifier& rVerifier,
+ const css::uno::Sequence< css::beans::NamedValue >& rMediaEncData,
+ const OUString& rMediaPassword,
+ const css::uno::Reference< css::task::XInteractionHandler >& rxInteractHandler,
+ const OUString& rDocumentUrl,
+ DocPasswordRequestType eRequestType,
+ const ::std::vector< OUString >* pDefaultPasswords = nullptr,
+ bool* pbIsDefaultPassword = nullptr );
+
+ static css::uno::Sequence< css::beans::NamedValue > decryptGpgSession(
+ const css::uno::Sequence< css::uno::Sequence< css::beans::NamedValue > >& rGpgProperties);
+
+private:
+ ~DocPasswordHelper();
+};
+
+
+} // namespace comphelper
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/docpasswordrequest.hxx b/include/comphelper/docpasswordrequest.hxx
new file mode 100644
index 000000000..a4e8704eb
--- /dev/null
+++ b/include/comphelper/docpasswordrequest.hxx
@@ -0,0 +1,110 @@
+/* -*- 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_COMPHELPER_DOCPASSWORDREQUEST_HXX
+#define INCLUDED_COMPHELPER_DOCPASSWORDREQUEST_HXX
+
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::task { class XInteractionAbort; }
+
+namespace comphelper {
+
+class PasswordContinuation;
+
+
+/** Selects which UNO document password request type to use. */
+enum class DocPasswordRequestType
+{
+ Standard, /// Uses the standard com.sun.star.task.DocumentPasswordRequest request.
+ MS /// Uses the com.sun.star.task.DocumentMSPasswordRequest request.
+};
+
+
+class COMPHELPER_DLLPUBLIC SimplePasswordRequest final :
+ public cppu::WeakImplHelper
+{
+public:
+ explicit SimplePasswordRequest();
+ virtual ~SimplePasswordRequest() override;
+
+ bool isPassword() const;
+
+ OUString getPassword() const;
+
+private:
+ SimplePasswordRequest(SimplePasswordRequest const&) = delete;
+ SimplePasswordRequest& operator=(SimplePasswordRequest const&) = delete;
+
+ // XInteractionRequest
+ virtual css::uno::Any SAL_CALL getRequest() override;
+ virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() override;
+
+private:
+ css::uno::Any maRequest;
+ css::uno::Reference mxAbort;
+ rtl::Reference mxPassword;
+};
+
+
+/** Implements the task.XInteractionRequest interface for requesting a password
+ string for a document.
+ */
+class COMPHELPER_DLLPUBLIC DocPasswordRequest final :
+ public cppu::WeakImplHelper
+{
+public:
+ explicit DocPasswordRequest(
+ DocPasswordRequestType eType,
+ css::task::PasswordRequestMode eMode,
+ const OUString& rDocumentUrl,
+ bool bPasswordToModify = false );
+ virtual ~DocPasswordRequest() override;
+
+ bool isPassword() const;
+
+ OUString getPassword() const;
+
+ OUString getPasswordToModify() const;
+ bool getRecommendReadOnly() const;
+
+private:
+ DocPasswordRequest(DocPasswordRequest const&) = delete;
+ DocPasswordRequest& operator=(DocPasswordRequest const&) = delete;
+
+ // XInteractionRequest
+ virtual css::uno::Any SAL_CALL getRequest() override;
+ virtual css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > SAL_CALL getContinuations() override;
+
+private:
+ css::uno::Any maRequest;
+ css::uno::Reference mxAbort;
+ rtl::Reference mxPassword;
+};
+
+
+} // namespace comphelper
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/documentconstants.hxx b/include/comphelper/documentconstants.hxx
new file mode 100644
index 000000000..87d45852c
--- /dev/null
+++ b/include/comphelper/documentconstants.hxx
@@ -0,0 +1,129 @@
+/* -*- 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_COMPHELPER_DOCUMENTCONSTANTS_HXX
+#define INCLUDED_COMPHELPER_DOCUMENTCONSTANTS_HXX
+
+#include
+
+// formats of SO6/7
+#define MIMETYPE_VND_SUN_XML_WRITER_ASCII "application/vnd.sun.xml.writer"
+#define MIMETYPE_VND_SUN_XML_WRITER_WEB_ASCII "application/vnd.sun.xml.writer.web"
+#define MIMETYPE_VND_SUN_XML_WRITER_GLOBAL_ASCII "application/vnd.sun.xml.writer.global"
+#define MIMETYPE_VND_SUN_XML_DRAW_ASCII "application/vnd.sun.xml.draw"
+#define MIMETYPE_VND_SUN_XML_IMPRESS_ASCII "application/vnd.sun.xml.impress"
+#define MIMETYPE_VND_SUN_XML_CALC_ASCII "application/vnd.sun.xml.calc"
+#define MIMETYPE_VND_SUN_XML_CHART_ASCII "application/vnd.sun.xml.chart"
+#define MIMETYPE_VND_SUN_XML_MATH_ASCII "application/vnd.sun.xml.math"
+#define MIMETYPE_VND_SUN_XML_BASE_ASCII "application/vnd.sun.xml.base"
+
+// template formats of SO6/7
+#define MIMETYPE_VND_SUN_XML_WRITER_TEMPLATE_ASCII "application/vnd.sun.xml.writer.template"
+#define MIMETYPE_VND_SUN_XML_DRAW_TEMPLATE_ASCII "application/vnd.sun.xml.draw.template"
+#define MIMETYPE_VND_SUN_XML_IMPRESS_TEMPLATE_ASCII "application/vnd.sun.xml.impress.template"
+#define MIMETYPE_VND_SUN_XML_CALC_TEMPLATE_ASCII "application/vnd.sun.xml.calc.template"
+
+// formats of SO8
+#define MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII "application/vnd.oasis.opendocument.text"
+#define MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII "application/vnd.oasis.opendocument.text-web"
+#define MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII "application/vnd.oasis.opendocument.text-master"
+#define MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII "application/vnd.oasis.opendocument.graphics"
+#define MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII "application/vnd.oasis.opendocument.presentation"
+#define MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII "application/vnd.oasis.opendocument.spreadsheet"
+#define MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII "application/vnd.oasis.opendocument.chart"
+#define MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII "application/vnd.oasis.opendocument.formula"
+#define MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII "application/vnd.oasis.opendocument.base"
+#define MIMETYPE_OASIS_OPENDOCUMENT_REPORT_ASCII "application/vnd.sun.xml.report"
+#define MIMETYPE_OASIS_OPENDOCUMENT_REPORT_CHART_ASCII "application/vnd.sun.xml.report.chart"
+
+// template formats of SO8
+#define MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII "application/vnd.oasis.opendocument.text-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_TEMPLATE_ASCII "application/vnd.oasis.opendocument.text-master-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII "application/vnd.oasis.opendocument.graphics-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII "application/vnd.oasis.opendocument.presentation-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII "application/vnd.oasis.opendocument.spreadsheet-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_CHART_TEMPLATE_ASCII "application/vnd.oasis.opendocument.chart-template"
+#define MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII "application/vnd.oasis.opendocument.formula-template"
+
+
+// ODF versions
+#define ODFVER_010_TEXT "1.0"
+#define ODFVER_011_TEXT "1.1"
+#define ODFVER_012_TEXT "1.2"
+#define ODFVER_013_TEXT "1.3"
+
+// filter flags
+// TODO/LATER: The flags should be part of the UNO specification
+//
+// http://www.mail-archive.com/dev@openoffice.org/msg05047.html says:
+//
+// I can just sum up what comes into my mind, hope I don't miss one:
+//
+// Import - should be self explaining
+// Export - should be self explaining
+// Template - deprecated
+// TemplatePath - filter for a documenttemplate
+// Own - one of the OOo file formats
+// Alien - no zip container based format
+// Preferred - preferred filter for a particular type
+// 3rdPartyFilter - implemented as a UNO component
+// Default - default filter for this document type
+// Exotic - an unusual/legacy file-format, we don't normally see
+//
+// (The 3rdPartyFilter flag is here called StarONE)
+//
+enum class SfxFilterFlags
+{
+ NONE = 0,
+ IMPORT = 0x00000001L,
+ EXPORT = 0x00000002L,
+ TEMPLATE = 0x00000004L,
+ INTERNAL = 0x00000008L,
+ TEMPLATEPATH = 0x00000010L,
+ OWN = 0x00000020L,
+ ALIEN = 0x00000040L,
+
+ DEFAULT = 0x00000100L,
+ SUPPORTSSELECTION = 0x00000400L,
+ NOTINFILEDLG = 0x00001000L,
+
+ OPENREADONLY = 0x00010000L,
+ MUSTINSTALL = 0x00020000L,
+ CONSULTSERVICE = 0x00040000L,
+ STARONEFILTER = 0x00080000L,
+ PACKED = 0x00100000L,
+ EXOTIC = 0x00200000L,
+ COMBINED = 0x00800000L,
+
+ ENCRYPTION = 0x01000000L,
+ PASSWORDTOMODIFY = 0x02000000L,
+ GPGENCRYPTION = 0x04000000L,
+ PREFERED = 0x10000000L,
+ STARTPRESENTATION = 0x20000000L,
+ SUPPORTSSIGNING = 0x40000000L,
+};
+
+namespace o3tl
+{
+ template<> struct typed_flags : is_typed_flags {};
+}
+
+#define SFX_FILTER_NOTINSTALLED (SfxFilterFlags::MUSTINSTALL | SfxFilterFlags::CONSULTSERVICE)
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/documentinfo.hxx b/include/comphelper/documentinfo.hxx
new file mode 100644
index 000000000..a7002120a
--- /dev/null
+++ b/include/comphelper/documentinfo.hxx
@@ -0,0 +1,51 @@
+/* -*- 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_COMPHELPER_DOCUMENTINFO_HXX
+#define INCLUDED_COMPHELPER_DOCUMENTINFO_HXX
+
+#include
+#include
+
+namespace com::sun::star::frame { class XModel; }
+namespace com::sun::star::uno { template class Reference; }
+
+
+namespace comphelper {
+
+
+ //= DocumentInfo
+
+ namespace DocumentInfo
+ {
+ /** retrieves the UI title of the given document
+ */
+ COMPHELPER_DLLPUBLIC OUString getDocumentTitle( const css::uno::Reference< css::frame::XModel >& _rxDocument );
+
+ /** notify that this document contains a macro event handler
+ */
+ COMPHELPER_DLLPUBLIC void notifyMacroEventRead( const css::uno::Reference< css::frame::XModel >& _rxDocument );
+ }
+
+} // namespace comphelper
+
+
+#endif // INCLUDED_COMPHELPER_DOCUMENTINFO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/doublecheckedinit.hxx b/include/comphelper/doublecheckedinit.hxx
new file mode 100644
index 000000000..200a9c88c
--- /dev/null
+++ b/include/comphelper/doublecheckedinit.hxx
@@ -0,0 +1,64 @@
+/* -*- 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_COMPHELPER_DOUBLECHECKEDINIT_HXX
+#define INCLUDED_COMPHELPER_DOUBLECHECKEDINIT_HXX
+
+#include
+
+#include
+// HACK: includes , which in some Clang versions does '#define bool bool',
+// which confuses clang plugins.
+#undef bool
+#include
+
+namespace comphelper
+{
+/**
+ * Thread-safe singleton creation.
+ *
+ * It is normally sufficient to create singletons using static variables in a function.
+ * This function is only for use cases that have a more complex lifetime of the object,
+ * such as when the object may require specific cleanup or may be created more times
+ * (e.g. when there is a "singleton" per each instance of another object).
+ */
+template ,
+ typename Guard = osl::MutexGuard, typename GuardCtor = osl::GetGlobalMutex>
+static inline Type* doubleCheckedInit(std::atomic& pointer, Function function,
+ GuardCtor guardCtor = osl::GetGlobalMutex())
+{
+ Type* p = pointer.load(std::memory_order_acquire);
+ if (!p)
+ {
+ Guard guard(guardCtor());
+ p = pointer.load(std::memory_order_relaxed);
+ if (!p)
+ {
+ p = function();
+ pointer.store(p, std::memory_order_release);
+ }
+ }
+ return p;
+}
+
+} // namespace
+
+#endif // INCLUDED_COMPHELPER_DOUBLECHECKEDINIT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/embeddedobjectcontainer.hxx b/include/comphelper/embeddedobjectcontainer.hxx
new file mode 100644
index 000000000..130a6a1ad
--- /dev/null
+++ b/include/comphelper/embeddedobjectcontainer.hxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
+#define INCLUDED_COMPHELPER_EMBEDDEDOBJECTCONTAINER_HXX
+
+#include
+#include
+#include
+
+#include
+#include
+
+namespace com::sun::star::beans { struct PropertyValue; }
+namespace com::sun::star::embed { class XEmbeddedObject; }
+namespace com::sun::star::embed { class XStorage; }
+namespace com::sun::star::io { class XInputStream; }
+namespace com::sun::star::task { class XInteractionHandler; }
+namespace com::sun::star::uno { class XInterface; }
+
+namespace comphelper
+{
+ class EmbeddedObjectContainer;
+ /** Helper interface to give access to some common object which replace the SfxObjectShell
+ */
+ class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI IEmbeddedHelper
+ {
+ public:
+ virtual EmbeddedObjectContainer& getEmbeddedObjectContainer() const = 0;
+ virtual css::uno::Reference < css::embed::XStorage > getStorage() const = 0;
+ virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const = 0;
+ virtual bool isEnableSetModified() const = 0;
+ virtual OUString getDocumentBaseURL() const = 0;
+
+ protected:
+ ~IEmbeddedHelper() {}
+ };
+
+struct EmbedImpl;
+class COMPHELPER_DLLPUBLIC EmbeddedObjectContainer
+{
+ std::unique_ptr pImpl;
+
+ css::uno::Reference < css::embed::XEmbeddedObject > Get_Impl( const OUString&,
+ const css::uno::Reference < css::embed::XEmbeddedObject >& xCopy,
+ OUString const* pBaseURL);
+
+public:
+ // add an embedded object to the container storage
+ bool StoreEmbeddedObject(
+ const css::uno::Reference& xObj, OUString& rName, bool bCopy,
+ const OUString& rSrcShellID, const OUString& rDestShellID );
+
+ // add an embedded object that has been imported from the container storage - should only be called by filters!
+ void AddEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, const OUString& );
+
+ EmbeddedObjectContainer();
+ EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >& );
+ EmbeddedObjectContainer( const css::uno::Reference < css::embed::XStorage >&,
+ const css::uno::Reference < css::uno::XInterface >& );
+ ~EmbeddedObjectContainer();
+
+ void SwitchPersistence( const css::uno::Reference < css::embed::XStorage >& );
+ bool CommitImageSubStorage();
+ void ReleaseImageSubStorage();
+
+ OUString CreateUniqueObjectName();
+
+ // get a list of object names that have been added so far
+ css::uno::Sequence < OUString > GetObjectNames() const;
+
+ // check for existence of objects at all
+ bool HasEmbeddedObjects() const;
+
+ // check existence of an object - either by identity or by name
+ bool HasEmbeddedObject( const OUString& );
+ bool HasEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
+ bool HasInstantiatedEmbeddedObject( const OUString& );
+
+ // get the object name of an object - this is the persist name if the object has persistence
+ OUString GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& ) const;
+
+ // retrieve an embedded object by name that either has been added already or is available in the container storage
+ css::uno::Reference GetEmbeddedObject(const OUString&, OUString const* pBaseURL = nullptr);
+
+ // create an object from a ClassId
+ css::uno::Reference < css::embed::XEmbeddedObject >
+ CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&, OUString&,
+ OUString const* pBaseURL = nullptr );
+
+ css::uno::Reference < css::embed::XEmbeddedObject >
+ CreateEmbeddedObject( const css::uno::Sequence < sal_Int8 >&,
+ const css::uno::Sequence < css::beans::PropertyValue >&, OUString&,
+ OUString const* pBaseURL = nullptr );
+
+ // insert an embedded object into the container - objects persistent representation will be added to the storage
+ bool InsertEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString& );
+
+ // load an embedded object from a MediaDescriptor and insert it into the container
+ // a new object will be created from the new content and returned
+ css::uno::Reference < css::embed::XEmbeddedObject >
+ InsertEmbeddedObject( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& rName, OUString const* pBaseURL = nullptr);
+
+ // create an embedded link based on a MediaDescriptor and insert it into the container
+ // a new object will be created from the new content and returned
+ css::uno::Reference < css::embed::XEmbeddedObject >
+ InsertEmbeddedLink( const css::uno::Sequence < css::beans::PropertyValue >&, OUString& );
+
+ // create an object from a stream that contains its persistent representation and insert it as usual (usually called from clipboard)
+ // a new object will be created from the new content and returned
+ css::uno::Reference < css::embed::XEmbeddedObject >
+ InsertEmbeddedObject( const css::uno::Reference < css::io::XInputStream >&, OUString& );
+
+ // copy an embedded object into the storage, open the new copy and return it
+ css::uno::Reference CopyAndGetEmbeddedObject(
+ EmbeddedObjectContainer& rSrc, const css::uno::Reference & xObj, OUString& rName,
+ const OUString& rSrcShellID, const OUString& rDestShellID );
+
+ // remove an embedded object from the container and from the storage; if object can't be closed
+ // #i119941, bKeepToTempStorage: use to specify whether store the removed object to temporary storage+
+ void RemoveEmbeddedObject( const OUString& rName, bool bKeepToTempStorage = true);
+ bool RemoveEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >&, bool bKeepToTempStorage = true);
+
+ // close and remove an embedded object from the container without removing it from the storage
+ void CloseEmbeddedObject( const css::uno::Reference < css::embed::XEmbeddedObject >& );
+
+ // move an embedded object to another container (keep the persistent name)
+ bool MoveEmbeddedObject( const OUString& rName, EmbeddedObjectContainer& );
+
+ // get the stored graphical representation for the object
+ css::uno::Reference < css::io::XInputStream > GetGraphicStream( const css::uno::Reference < css::embed::XEmbeddedObject >&, OUString* pMediaType=nullptr );
+
+ // get the stored graphical representation by the object name
+ css::uno::Reference < css::io::XInputStream > GetGraphicStream( const OUString& aName, OUString* pMediaType=nullptr );
+
+ // add a graphical representation for an object
+ bool InsertGraphicStream( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
+
+ // try to add a graphical representation for an object in optimized way ( might fail )
+ bool InsertGraphicStreamDirectly( const css::uno::Reference < css::io::XInputStream >& rStream, const OUString& rObjectName, const OUString& rMediaType );
+
+ // remove a graphical representation for an object
+ void RemoveGraphicStream( const OUString& rObjectName );
+
+ // copy the graphical representation from different container
+ bool TryToCopyGraphReplacement( EmbeddedObjectContainer& rSrc,
+ const OUString& aOrigName,
+ const OUString& aTargetName );
+
+ void CloseEmbeddedObjects();
+ bool StoreChildren(bool _bOasisFormat,bool _bObjectsOnly);
+ bool StoreAsChildren( bool _bOasisFormat
+ ,bool _bCreateEmbedded
+ ,const css::uno::Reference < css::embed::XStorage >& _xStorage);
+
+ static css::uno::Reference< css::io::XInputStream > GetGraphicReplacementStream(
+ sal_Int64 nViewAspect,
+ const css::uno::Reference < css::embed::XEmbeddedObject >&,
+ OUString* pMediaType );
+
+ /** call setPersistentEntry for each embedded object in the container
+ *
+ * \param _xStorage The storage where to store the objects.
+ * \param _bClearModifedFlag If then the modified flag will be set to otherwise nothing happen.
+ * \return if no error occurred, otherwise .
+ */
+ bool SetPersistentEntries(const css::uno::Reference< css::embed::XStorage >& _xStorage,bool _bClearModifedFlag = true);
+
+ bool getUserAllowsLinkUpdate() const;
+ void setUserAllowsLinkUpdate(bool bNew);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/enumhelper.hxx b/include/comphelper/enumhelper.hxx
new file mode 100644
index 000000000..16d95b76e
--- /dev/null
+++ b/include/comphelper/enumhelper.hxx
@@ -0,0 +1,121 @@
+/* -*- 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_COMPHELPER_ENUMHELPER_HXX
+#define INCLUDED_COMPHELPER_ENUMHELPER_HXX
+
+#include
+#include
+#include
+#include
+#include
+
+namespace com::sun::star::container { class XIndexAccess; }
+namespace com::sun::star::container { class XNameAccess; }
+
+namespace comphelper
+{
+
+struct OEnumerationLock
+{
+ public:
+ ::osl::Mutex m_aLock;
+};
+
+/** provides a com.sun.star.container::XEnumeration access based
+ on an object implementing the com.sun.star.container::XNameAccess interface
+*/
+class COMPHELPER_DLLPUBLIC OEnumerationByName final : private OEnumerationLock
+ , public ::cppu::WeakImplHelper< css::container::XEnumeration ,
+ css::lang::XEventListener >
+{
+ css::uno::Sequence< OUString > const m_aNames;
+ sal_Int32 m_nPos;
+ css::uno::Reference< css::container::XNameAccess > m_xAccess;
+ bool m_bListening;
+
+public:
+ OEnumerationByName(const css::uno::Reference< css::container::XNameAccess >& _rxAccess);
+ OEnumerationByName(const css::uno::Reference< css::container::XNameAccess >& _rxAccess,
+ const css::uno::Sequence< OUString >& _aNames );
+ virtual ~OEnumerationByName() override;
+
+ virtual sal_Bool SAL_CALL hasMoreElements( ) override;
+ virtual css::uno::Any SAL_CALL nextElement( ) override;
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+
+private:
+ COMPHELPER_DLLPRIVATE void impl_startDisposeListening();
+ COMPHELPER_DLLPRIVATE void impl_stopDisposeListening();
+};
+
+/** provides a com.sun.star.container::XEnumeration access based
+ on an object implementing the com.sun.star.container::XNameAccess interface
+*/
+class COMPHELPER_DLLPUBLIC OEnumerationByIndex final : private OEnumerationLock
+ , public ::cppu::WeakImplHelper< css::container::XEnumeration ,
+ css::lang::XEventListener >
+{
+ css::uno::Reference< css::container::XIndexAccess > m_xAccess;
+ sal_Int32 m_nPos;
+ bool m_bListening;
+
+public:
+ OEnumerationByIndex(const css::uno::Reference< css::container::XIndexAccess >& _rxAccess);
+ virtual ~OEnumerationByIndex() override;
+
+ virtual sal_Bool SAL_CALL hasMoreElements( ) override;
+ virtual css::uno::Any SAL_CALL nextElement( ) override;
+
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
+
+private:
+ COMPHELPER_DLLPRIVATE void impl_startDisposeListening();
+ COMPHELPER_DLLPRIVATE void impl_stopDisposeListening();
+};
+
+// this is the way that works for ENABLE_LTO with MSVC 2013
+class SAL_DLLPUBLIC_TEMPLATE OAnyEnumeration_BASE
+ : public ::cppu::WeakImplHelper {};
+
+/** provides a com.sun.star.container::XEnumeration
+ for an outside set vector of Any's.
+
+*/
+class COMPHELPER_DLLPUBLIC OAnyEnumeration final : private OEnumerationLock
+ , public OAnyEnumeration_BASE
+{
+ sal_Int32 m_nPos;
+ css::uno::Sequence< css::uno::Any > m_lItems;
+
+public:
+ OAnyEnumeration(const css::uno::Sequence< css::uno::Any >& lItems);
+ virtual ~OAnyEnumeration() override;
+
+ virtual sal_Bool SAL_CALL hasMoreElements( ) override;
+ virtual css::uno::Any SAL_CALL nextElement( ) override;
+
+};
+
+}
+
+#endif // INCLUDED_COMPHELPER_ENUMHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/eventattachermgr.hxx b/include/comphelper/eventattachermgr.hxx
new file mode 100644
index 000000000..4a2a99909
--- /dev/null
+++ b/include/comphelper/eventattachermgr.hxx
@@ -0,0 +1,48 @@
+/* -*- 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_COMPHELPER_EVENTATTACHERMGR_HXX
+#define INCLUDED_COMPHELPER_EVENTATTACHERMGR_HXX
+
+#include
+#include