diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/unotools | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/unotools')
69 files changed, 9320 insertions, 0 deletions
diff --git a/include/unotools/accessiblerelationsethelper.hxx b/include/unotools/accessiblerelationsethelper.hxx new file mode 100644 index 000000000000..18e9a80a639a --- /dev/null +++ b/include/unotools/accessiblerelationsethelper.hxx @@ -0,0 +1,153 @@ +/* -*- 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 _UTL_ACCESSIBLERELATIONSETHELPER_HXX_ +#define _UTL_ACCESSIBLERELATIONSETHELPER_HXX_ + +#include "unotools/unotoolsdllapi.h" + +#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <osl/mutex.hxx> +#include <cppuhelper/implbase1.hxx> +#include <comphelper/servicehelper.hxx> + +class AccessibleRelationSetHelperImpl; + +//========================================================================= +//= XAccessibleRelationSet helper classes +//========================================================================= + +//... namespace utl ....................................................... +namespace utl +{ +//......................................................................... + +/** @descr + This base class provides an implementation of the + <code>AccessibleRelationSet</code> service. +*/ +class UNOTOOLS_DLLPUBLIC AccessibleRelationSetHelper + : public cppu::WeakImplHelper1< + ::com::sun::star::accessibility::XAccessibleRelationSet + > +{ +public: + //===== internal ======================================================== + AccessibleRelationSetHelper (); + AccessibleRelationSetHelper (const AccessibleRelationSetHelper& rHelper); +protected: + virtual ~AccessibleRelationSetHelper (void); +public: + + //===== XAccessibleRelationSet ========================================== + + /** Returns the number of relations in this relation set. + + @return + Returns the number of relations or zero if there are none. + */ + virtual sal_Int32 SAL_CALL getRelationCount( ) + throw (::com::sun::star::uno::RuntimeException); + + /** Returns the relation of this relation set that is specified by + the given index. + + @param nIndex + This index specifies the relatio to return. + + @return + For a valid index, i.e. inside the range 0 to the number of + relations minus one, the returned value is the requested + relation. If the index is invalid then the returned relation + has the type INVALID. + + */ + virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL + getRelation( sal_Int32 nIndex ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + /** Tests whether the relation set contains a relation matching the + specified key. + + @param aRelationType + The type of relation to look for in this set of relations. This + has to be one of the constants of + <type>AccessibleRelationType</type>. + + @return + Returns <TRUE/> if there is a (at least one) relation of the + given type and <FALSE/> if there is no such relation in the set. + */ + virtual sal_Bool SAL_CALL containsRelation( sal_Int16 aRelationType ) + throw (::com::sun::star::uno::RuntimeException); + + /** Retrieve and return the relation with the given relation type. + + @param aRelationType + The type of the relation to return. This has to be one of the + constants of <type>AccessibleRelationType</type>. + + @return + If a relation with the given type could be found than (a copy + of) this relation is returned. Otherwise a relation with the + type INVALID is returned. + */ + virtual ::com::sun::star::accessibility::AccessibleRelation SAL_CALL + getRelationByType( sal_Int16 aRelationType ) + throw (::com::sun::star::uno::RuntimeException); + + void AddRelation( + const ::com::sun::star::accessibility::AccessibleRelation& rRelation) + throw (::com::sun::star::uno::RuntimeException); + + //===== XTypeProvider =================================================== + + /** Returns a sequence of all supported interfaces. + */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL + getTypes (void) + throw (::com::sun::star::uno::RuntimeException); + + /** Returns a implementation id. + */ + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId (void) + throw (::com::sun::star::uno::RuntimeException); + +protected: + /// Mutex guarding this object. + ::osl::Mutex maMutex; + +private: + /// The implementation of this helper interface. + AccessibleRelationSetHelperImpl* mpHelperImpl; +}; + +//......................................................................... +} +//... namespace utl ....................................................... +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/accessiblestatesethelper.hxx b/include/unotools/accessiblestatesethelper.hxx new file mode 100644 index 000000000000..7652a03cc47c --- /dev/null +++ b/include/unotools/accessiblestatesethelper.hxx @@ -0,0 +1,161 @@ +/* -*- 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 _UTL_ACCESSIBLESTATESETHELPER_HXX_ +#define _UTL_ACCESSIBLESTATESETHELPER_HXX_ + +#include "unotools/unotoolsdllapi.h" + +#include <com/sun/star/accessibility/XAccessibleStateSet.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XServiceName.hpp> +#include <osl/mutex.hxx> +#include <cppuhelper/implbase1.hxx> +#include <comphelper/servicehelper.hxx> + +class AccessibleStateSetHelperImpl; + +//========================================================================= +//= XAccessibleStateSet helper classes +//========================================================================= + +//... namespace utl ....................................................... +namespace utl +{ +//......................................................................... + +/** @descr + This base class provides an implementation of the + <code>AccessibleStateSet</code> service. +*/ +class UNOTOOLS_DLLPUBLIC AccessibleStateSetHelper + : public cppu::WeakImplHelper1< + ::com::sun::star::accessibility::XAccessibleStateSet + > +{ +public: + //===== internal ======================================================== + + AccessibleStateSetHelper (); + /** constructs an object with some states initially set + + <p>This ctor is compatible with + <method scope="comphelper">OAccessibleImplementationAccess::implGetForeignControlledStates</method></p> + + @param _nInitialStates + is a bit mask. Every bit 2^n means that the state number n (as got from the + AccessibleStateType constants) should be set initially. + */ + AccessibleStateSetHelper ( const sal_Int64 _nInitialStates ); + + AccessibleStateSetHelper ( const AccessibleStateSetHelper& rHelper ); +protected: + virtual ~AccessibleStateSetHelper (void); +public: + + //===== XAccessibleStateSet ============================================== + + /** Checks whether the current state set is empty. + + @return + Returns <TRUE/> if there is no state in this state set and + <FALSE/> if there is at least one state set in it. + */ + virtual sal_Bool SAL_CALL isEmpty () + throw (::com::sun::star::uno::RuntimeException); + + /** Checks if the given state is a member of the state set of this + object. + + @param aState + The state for which to check membership. This has to be one of + the constants of <type>AccessibleStateType</type>. + + @return + Returns <TRUE/> if the given state is a member of this object's + state set and <FALSE/> otherwise. + */ + virtual sal_Bool SAL_CALL contains (sal_Int16 aState) + throw (::com::sun::star::uno::RuntimeException); + + /** Checks if all of the given states are in this object's state + set. + + @param aStateSet + This sequence of states is interpreted as set and every of its + members, duplicates are ignored, is checked for membership in + this object's state set. Each state has to be one of the + constants of <type>AccessibleStateType</type>. + + @return + Returns <TRUE/> if all states of the given state set are members + of this object's state set. <FALSE/> is returned if at least + one of the states in the given state is not a member of this + object's state set. + */ + virtual sal_Bool SAL_CALL containsAll ( + const ::com::sun::star::uno::Sequence<sal_Int16>& rStateSet) + throw (::com::sun::star::uno::RuntimeException); + + /** Returns a sequence of all states. + */ + virtual com::sun::star::uno::Sequence<sal_Int16> SAL_CALL getStates() + throw (::com::sun::star::uno::RuntimeException); + + /** Adds a state to the set. + */ + void AddState(sal_Int16 aState) + throw (::com::sun::star::uno::RuntimeException); + + /** Removes a state from the set if the set contains the state, otherwise nothing is done. + */ + void RemoveState(sal_Int16 aState) + throw (::com::sun::star::uno::RuntimeException); + + //===== XTypeProvider =================================================== + + /** Returns a sequence of all supported interfaces. + */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL + getTypes (void) + throw (::com::sun::star::uno::RuntimeException); + + /** Returns a implementation id. + */ + virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL + getImplementationId (void) + throw (::com::sun::star::uno::RuntimeException); + +protected: + /// Mutex guarding this object. + ::osl::Mutex maMutex; + +private: + /// The implementation of this helper interface. + AccessibleStateSetHelperImpl* mpHelperImpl; +}; + +//......................................................................... +} +//... namespace utl ....................................................... +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/atom.hxx b/include/unotools/atom.hxx new file mode 100644 index 000000000000..5b8f193d604f --- /dev/null +++ b/include/unotools/atom.hxx @@ -0,0 +1,70 @@ +/* -*- 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 _UTL_ATOM_HXX_ +#define _UTL_ATOM_HXX_ + +#include "unotools/unotoolsdllapi.h" +#include <rtl/ustring.hxx> +#include <osl/mutex.hxx> +#include <cppuhelper/implbase1.hxx> + +#include <boost/unordered_map.hpp> +#include <list> +#include <com/sun/star/util/XAtomServer.hpp> + +#define INVALID_ATOM 0 + +namespace utl { + + struct AtomDescription + { + int atom; + OUString description; + }; + + class AtomProvider + { + int m_nAtoms; + ::boost::unordered_map< int, OUString, ::boost::hash< int > > m_aStringMap; + ::boost::unordered_map< OUString, int, OUStringHash > m_aAtomMap; + public: + AtomProvider(); + ~AtomProvider(); + + int getAtom( const OUString&, sal_Bool bCreate = sal_False ); + const OUString& getString( int ) const; + }; + + + class UNOTOOLS_DLLPUBLIC MultiAtomProvider + { + ::boost::unordered_map< int, AtomProvider*, ::boost::hash< int > > m_aAtomLists; + public: + MultiAtomProvider(); + ~MultiAtomProvider(); + + int getAtom( int atomClass, const OUString& rString, sal_Bool bCreate = sal_False ); + + const OUString& getString( int atomClass, int atom ) const; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/bootstrap.hxx b/include/unotools/bootstrap.hxx new file mode 100644 index 000000000000..530fa3173b73 --- /dev/null +++ b/include/unotools/bootstrap.hxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UTL_BOOTSTRAP_HXX +#define _UTL_BOOTSTRAP_HXX + +#include <rtl/ustring.hxx> + +namespace utl +{ +//----------------------------------------------------------------------------- + /** provides configuration information needed for application startup. + <p>This class handles the startup information for the office application. + It encapsulates knowledge of how to retriev such information and how + to diagnose failures to retriev required data. + </p> + */ + class UNOTOOLS_DLLPUBLIC Bootstrap + { + // the static interface + public: // some common information items + + /// retrieve the product key; defaults to executable name (without extension) + static OUString getProductKey(); + + /// retrieve the product key; uses the given default, if not found + static OUString getProductKey(OUString const& _sDefault); + + /// retrieve the BUILDID information item; uses the given default, if not found + static OUString getBuildIdData(OUString const& _sDefault); + + /// retrieve the BuildVersion information item; uses the given default, if not found + static OUString getBuildVersion(OUString const& _sDefault); + + /// reload cached data + static void reloadData(); + + public: // retrieve path information about the installaton location + enum PathStatus + { + PATH_EXISTS, // Success: Found a path to an existing file or directory + PATH_VALID, // Found a valid path, but the file or directory does not exist + DATA_INVALID, // Retrieved a string for this path, that is not a valid file url or system path + DATA_MISSING, // Could not retrieve any data for this path + DATA_UNKNOWN // No attempt to retrieve data for this path was made + }; + + /// get a file URL to the common base installation [${insturl}] + static PathStatus locateBaseInstallation(OUString& _rURL); + + /// get a file URL to the user installation [${userurl}] + static PathStatus locateUserInstallation(OUString& _rURL); + + /// get a file URL to the user data directory [default is ${userurl}/user] + static PathStatus locateUserData(OUString& _rURL); + + // the next two items are mainly supported for diagnostic purposes. both items may be unused + /// get a file URL to the bootstrap INI file used [e.g. ${insturl}/program/bootraprc] + static PathStatus locateBootstrapFile(OUString& _rURL); + /// get a file URL to the version locator INI file used [e.g. ${SYSUSERCONFIG}/sversion.ini] + static PathStatus locateVersionFile(OUString& _rURL); + + public: // evaluate the validity of the installation + /// high-level status of bootstrap success + enum Status + { + DATA_OK, /// user-dir and share-dir do exist, product key found or can be defaulted to exe-name + MISSING_USER_INSTALL, /// ${userurl} does not exist; or version-file cannot be found or is invalid + INVALID_USER_INSTALL, /// can locate ${userurl}, but user-dir is missing + INVALID_BASE_INSTALL /// other failure: e.g. cannot locate share-dir; bootstraprc missing or invalid; no product key + }; + + /// error code for detailed diagnostics of bootstrap failures + enum FailureCode + { + NO_FAILURE, /// bootstrap was successful + MISSING_INSTALL_DIRECTORY, /// the shared installation directory could not be located + MISSING_BOOTSTRAP_FILE, /// the bootstrap INI file could not be found or read + MISSING_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI is missing a required entry + INVALID_BOOTSTRAP_FILE_ENTRY, /// the bootstrap INI contains invalid data + MISSING_VERSION_FILE, /// the version locator INI file could not be found or read + MISSING_VERSION_FILE_ENTRY, /// the version locator INI has no entry for this version + INVALID_VERSION_FILE_ENTRY, /// the version locator INI entry is not a valid directory URL + MISSING_USER_DIRECTORY, /// the user installation directory does not exist + INVALID_BOOTSTRAP_DATA /// some bootstrap data was invalid in unexpected ways + }; + + /** Evaluates the status of the installation and returns a diagnostic + message and error code corresponding to this status + */ + static Status checkBootstrapStatus(OUString& _rDiagnosticMessage, FailureCode& _rErrCode); + + public: + // singleton impl-class + class Impl; + static const Impl& data(); // the data related to the bootstrap.ini file + }; +//----------------------------------------------------------------------------- +} // namespace utl + +#endif // _UTL_BOOTSTRAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/calendarwrapper.hxx b/include/unotools/calendarwrapper.hxx new file mode 100644 index 000000000000..d7e66dea0f33 --- /dev/null +++ b/include/unotools/calendarwrapper.hxx @@ -0,0 +1,131 @@ +/* -*- 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 _UNOTOOLS_CALENDARWRAPPER_HXX +#define _UNOTOOLS_CALENDARWRAPPER_HXX + +#include <tools/datetime.hxx> +#include <tools/string.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/i18n/Calendar2.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include "unotools/unotoolsdllapi.h" + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace com { namespace sun { namespace star { + namespace i18n { + class XCalendar3; + } +}}} + + +class UNOTOOLS_DLLPUBLIC CalendarWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar3 > xC; + + DateTime aEpochStart; // 1Jan1970 + +public: + CalendarWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext + ); + ~CalendarWrapper(); + + + // wrapper implementations of XCalendar + + void loadDefaultCalendar( const ::com::sun::star::lang::Locale& rLocale ); + void loadCalendar( const OUString& rUniqueID, const ::com::sun::star::lang::Locale& rLocale ); + ::com::sun::star::uno::Sequence< OUString > getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const; + OUString getUniqueID() const; + /// set UTC date/time + void setDateTime( double nTimeInDays ); + /// get UTC date/time + double getDateTime() const; + /// convenience method to set local date/time + void setLocalDateTime( double nTimeInDays ); + /// convenience method to get local date/time + double getLocalDateTime() const; + + + // wrapper implementations of XCalendar + + void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ); + sal_Bool isValid() const; + sal_Int16 getValue( sal_Int16 nFieldIndex ) const; + void addValue( sal_Int16 nFieldIndex, sal_Int32 nAmount ); + sal_Int16 getFirstDayOfWeek() const; + sal_Int16 getNumberOfMonthsInYear() const; + sal_Int16 getNumberOfDaysInWeek() const; + String getDisplayName( sal_Int16 nCalendarDisplayIndex, sal_Int16 nIdx, sal_Int16 nNameType ) const; + + /** Convenience method to get timezone offset in milliseconds, taking both + fields ZONE_OFFSET and ZONE_OFFSET_SECOND_MILLIS into account. */ + sal_Int32 getZoneOffsetInMillis() const; + /** Convenience method to get DST offset in milliseconds, taking both + fields DST_OFFSET and DST_OFFSET_SECOND_MILLIS into account. */ + sal_Int32 getDSTOffsetInMillis() const; + + + // wrapper implementations of XExtendedCalendar + + String getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const; + + + // wrapper implementations of XCalendar3 + + ::com::sun::star::i18n::Calendar2 getLoadedCalendar() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDays() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getMonths() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getGenitiveMonths() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getPartitiveMonths() const; + + + // convenience methods + + /// get epoch start (should be 01Jan1970) + inline const DateTime& getEpochStart() const + { return aEpochStart; } + + /// set a local (!) Gregorian DateTime + inline void setGregorianDateTime( const DateTime& rDateTime ) + { setLocalDateTime( rDateTime - aEpochStart ); } + + /// get the DateTime as a local (!) Gregorian DateTime + inline DateTime getGregorianDateTime() const + { return aEpochStart + getLocalDateTime(); } + +private: + + /** get timezone or DST offset in milliseconds, fields are + CalendarFieldIndex ZONE_OFFSET and ZONE_OFFSET_SECOND_MILLIS + respectively DST_OFFSET and DST_OFFSET_SECOND_MILLIS. + */ + sal_Int32 getCombinedOffsetInMillis( sal_Int16 nParentFieldIndex, sal_Int16 nChildFieldIndex ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/caserotate.hxx b/include/unotools/caserotate.hxx new file mode 100644 index 000000000000..d62878db2592 --- /dev/null +++ b/include/unotools/caserotate.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/. + * + * This file incorporates work covered by the following license notice: + * + */ +#ifndef INCLUDED_UNOTOOLS_CASEROTATE_HXX +#define INCLUDED_UNOTOOLS_CASEROTATE_HXX + +#include <sal/config.h> + +#include "unotools/unotoolsdllapi.h" + +//TODO Use XCharacterClassification::getStringType to determine the current +//(possibly mixed) case type and rotate to the next one + +class UNOTOOLS_DLLPUBLIC RotateTransliteration +{ +private: + int nF3ShiftCounter; +public: + RotateTransliteration() : nF3ShiftCounter(0) + { + } + sal_uInt32 getNextMode(); +}; + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/charclass.hxx b/include/unotools/charclass.hxx new file mode 100644 index 000000000000..6ea11f62063d --- /dev/null +++ b/include/unotools/charclass.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 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_CHARCLASS_HXX +#define _UNOTOOLS_CHARCLASS_HXX + +#include <ctype.h> // isdigit(), isalpha() +#include <boost/noncopyable.hpp> +#include <i18nlangtag/languagetag.hxx> +#include <tools/string.hxx> +#include <tools/solar.h> +#include <com/sun/star/i18n/KCharacterType.hpp> +#include <com/sun/star/i18n/KParseTokens.hpp> +#include <com/sun/star/i18n/KParseType.hpp> +#include <com/sun/star/i18n/ParseResult.hpp> +#include <com/sun/star/i18n/XCharacterClassification.hpp> +#include <osl/mutex.hxx> + +class String; +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +const sal_Int32 nCharClassAlphaType = + ::com::sun::star::i18n::KCharacterType::UPPER | + ::com::sun::star::i18n::KCharacterType::LOWER | + ::com::sun::star::i18n::KCharacterType::TITLE_CASE; + +const sal_Int32 nCharClassAlphaTypeMask = + nCharClassAlphaType | + ::com::sun::star::i18n::KCharacterType::PRINTABLE | + ::com::sun::star::i18n::KCharacterType::BASE_FORM; + +const sal_Int32 nCharClassLetterType = + nCharClassAlphaType | + ::com::sun::star::i18n::KCharacterType::LETTER; + +const sal_Int32 nCharClassLetterTypeMask = + nCharClassAlphaTypeMask | + ::com::sun::star::i18n::KCharacterType::LETTER; + +const sal_Int32 nCharClassNumericType = + ::com::sun::star::i18n::KCharacterType::DIGIT; + +const sal_Int32 nCharClassNumericTypeMask = + nCharClassNumericType | + ::com::sun::star::i18n::KCharacterType::PRINTABLE | + ::com::sun::star::i18n::KCharacterType::BASE_FORM; + + +class UNOTOOLS_DLLPUBLIC CharClass : private boost::noncopyable +{ + LanguageTag maLanguageTag; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCharacterClassification > xCC; + mutable ::osl::Mutex aMutex; + +public: + /// Preferred ctor with service manager specified + CharClass( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, + const LanguageTag& rLanguageTag ); + + /// Depricated ctor, tries to get a process service manager or to load the + /// library directly. + CharClass( const LanguageTag& rLanguageTag ); + + ~CharClass(); + + /// set a new Locale + void setLanguageTag( const LanguageTag& rLanguageTag ); + + /// get current Locale + const LanguageTag& getLanguageTag() const; + + + /// isdigit() on ascii values + static inline sal_Bool isAsciiDigit( sal_Unicode c ) + { + return c < 128 ? sal_Bool(isdigit( (unsigned char) c ) != 0) : sal_False; + } + + /// isalpha() on ascii values + static inline sal_Bool isAsciiAlpha( sal_Unicode c ) + { + return c < 128 ? sal_Bool(isalpha( (unsigned char) c ) != 0) : sal_False; + } + + /// isalnum() on ascii values + static inline sal_Bool isAsciiAlphaNumeric( sal_Unicode c ) + { + return c < 128 ? sal_Bool(isalnum( (unsigned char) c ) != 0) : sal_False; + } + + /// isdigit() on ascii values of entire string + static sal_Bool isAsciiNumeric( const String& rStr ); + + /// isalpha() on ascii values of entire string + static sal_Bool isAsciiAlpha( const String& rStr ); + + /// isalnum() on ascii values of entire string + static sal_Bool isAsciiAlphaNumeric( const String& rStr ); + + /// whether type is pure alpha or not, e.g. return of getStringType + static inline sal_Bool isAlphaType( sal_Int32 nType ) + { + return ((nType & nCharClassAlphaType) != 0) && + ((nType & ~(nCharClassAlphaTypeMask)) == 0); + } + + /// whether type is pure numeric or not, e.g. return of getStringType + static inline sal_Bool isNumericType( sal_Int32 nType ) + { + return ((nType & nCharClassNumericType) != 0) && + ((nType & ~(nCharClassNumericTypeMask)) == 0); + } + + /// whether type is pure alphanumeric or not, e.g. return of getStringType + static inline sal_Bool isAlphaNumericType( sal_Int32 nType ) + { + return ((nType & (nCharClassAlphaType | + nCharClassNumericType)) != 0) && + ((nType & ~(nCharClassAlphaTypeMask | + nCharClassNumericTypeMask)) == 0); + } + + /// whether type is pure letter or not, e.g. return of getStringType + static inline sal_Bool isLetterType( sal_Int32 nType ) + { + return ((nType & nCharClassLetterType) != 0) && + ((nType & ~(nCharClassLetterTypeMask)) == 0); + } + + /// whether type is pure letternumeric or not, e.g. return of getStringType + static inline sal_Bool isLetterNumericType( sal_Int32 nType ) + { + return ((nType & (nCharClassLetterType | + nCharClassNumericType)) != 0) && + ((nType & ~(nCharClassLetterTypeMask | + nCharClassNumericTypeMask)) == 0); + } + + + // Wrapper implementations of class CharacterClassification + + OUString uppercase( const OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const; + OUString lowercase( const OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const; + OUString titlecase( const OUString& rStr, sal_Int32 nPos, sal_Int32 nCount ) const; + + OUString uppercase( const OUString& _rStr ) const + { + return uppercase(_rStr, 0, _rStr.getLength()); + } + OUString lowercase( const OUString& _rStr ) const + { + return lowercase(_rStr, 0, _rStr.getLength()); + } + OUString titlecase( const OUString& _rStr ) const + { + return titlecase(_rStr, 0, _rStr.getLength()); + } + + sal_Int16 getType( const String& rStr, xub_StrLen nPos ) const; + sal_Int16 getCharacterDirection( const String& rStr, xub_StrLen nPos ) const; + sal_Int16 getScript( const String& rStr, xub_StrLen nPos ) const; + sal_Int32 getCharacterType( const String& rStr, xub_StrLen nPos ) const; + sal_Int32 getStringType( const String& rStr, xub_StrLen nPos, xub_StrLen nCount ) const; + + ::com::sun::star::i18n::ParseResult parseAnyToken( + const String& rStr, + sal_Int32 nPos, + sal_Int32 nStartCharFlags, + const String& userDefinedCharactersStart, + sal_Int32 nContCharFlags, + const String& userDefinedCharactersCont ) const; + + ::com::sun::star::i18n::ParseResult parsePredefinedToken( + sal_Int32 nTokenType, + const String& rStr, + sal_Int32 nPos, + sal_Int32 nStartCharFlags, + const String& userDefinedCharactersStart, + sal_Int32 nContCharFlags, + const String& userDefinedCharactersCont ) const; + + + // Functionality of class International methods + + sal_Bool isAlpha( const String& rStr, xub_StrLen nPos ) const; + sal_Bool isLetter( const String& rStr, xub_StrLen nPos ) const; + sal_Bool isDigit( const String& rStr, xub_StrLen nPos ) const; + sal_Bool isAlphaNumeric( const String& rStr, xub_StrLen nPos ) const; + sal_Bool isLetterNumeric( const String& rStr, xub_StrLen nPos ) const; + sal_Bool isAlpha( const String& rStr ) const; + sal_Bool isLetter( const String& rStr ) const; + sal_Bool isNumeric( const String& rStr ) const; + sal_Bool isAlphaNumeric( const String& rStr ) const; + sal_Bool isLetterNumeric( const String& rStr ) const; + +private: + + const ::com::sun::star::lang::Locale & getMyLocale() const; +}; + +#endif // _UNOTOOLS_CHARCLASS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/closeveto.hxx b/include/unotools/closeveto.hxx new file mode 100644 index 000000000000..21d381c5094b --- /dev/null +++ b/include/unotools/closeveto.hxx @@ -0,0 +1,60 @@ +/* -*- 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 UNOTOOLS_CLOSEVETO_HXX +#define UNOTOOLS_CLOSEVETO_HXX + +#include "unotools/unotoolsdllapi.h" + +#include <com/sun/star/uno/XInterface.hpp> + +#include <boost/scoped_ptr.hpp> + +//...................................................................................................................... +namespace utl +{ +//...................................................................................................................... + + //================================================================================================================== + //= CloseVeto + //================================================================================================================== + struct CloseVeto_Data; + /** will add a XCloseListener to a given component, and veto its closing as long as the <code>CloseVeto</code> + instance is alive. + + If closing has been requested and vetoed while the <code>CloseVeto</code> instance is alive, and the ownership + went to the <code>CloseVeto</code> instance, then it will close the component in its dtor. + */ + class UNOTOOLS_DLLPUBLIC CloseVeto + { + public: + CloseVeto( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& i_closeable ); + ~CloseVeto(); + + private: + ::boost::scoped_ptr< CloseVeto_Data > m_pData; + }; + +//...................................................................................................................... +} // namespace dbaui +//...................................................................................................................... + +#endif // UNOTOOLS_CLOSEVETO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/cmdoptions.hxx b/include/unotools/cmdoptions.hxx new file mode 100644 index 000000000000..173b7b585643 --- /dev/null +++ b/include/unotools/cmdoptions.hxx @@ -0,0 +1,167 @@ +/* -*- 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_unotools_CMDOPTIONS_HXX +#define INCLUDED_unotools_CMDOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/frame/XFrame.hpp> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @descr The method GetList() returns a list of property values. + Use follow defines to seperate values by names. +*//*-*************************************************************************************************************/ + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtCommandOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about dynamic menus + @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard". + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtCommandOptions : public utl::detail::Options +{ + friend class SvtCommandOptions_Impl; + + public: + + enum CmdOption + { + CMDOPTION_DISABLED, + CMDOPTION_NONE + }; + + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtCommandOptions(); + virtual ~SvtCommandOptions(); + + /*-****************************************************************************************************//** + @short return complete specified list + @descr Call it to get all entries of an dynamic menu. + We return a list of all nodes with his names and properties. + + @seealso - + + @param "eOption" select the list to retrieve. + @return A list of command strings is returned. + + @onerror We return an empty list. + *//*-*****************************************************************************************************/ + + sal_Bool HasEntries( CmdOption eOption ) const; + + /*-****************************************************************************************************//** + @short Lookup if a command URL is inside a given list + @descr Lookup if a command URL is inside a given lst + + @seealso - + + @param "eOption" select right command list + @param "aCommandURL" a command URL that is used for the look up + @return "sal_True" if the command is inside the list otherwise "sal_False" + + @onerror - + *//*-*****************************************************************************************************/ + + sal_Bool Lookup( CmdOption eOption, const OUString& aCommandURL ) const; + + /*-****************************************************************************************************//** + @short register an office frame, which must update its dispatches if + the underlying configuration was changed. + + @descr To avoid using of "dead" frame objects or implementing + deregistration mechanism too, we use weak references to + the given frames. + + @param "xFrame" points to the frame, which wish to be + notified, if configuration was changed. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void EstablisFrameCallback(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame); + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtCommandOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtCmdOptions + +#endif // #ifndef INCLUDED_unotools_CMDOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/collatorwrapper.hxx b/include/unotools/collatorwrapper.hxx new file mode 100644 index 000000000000..c73be3518569 --- /dev/null +++ b/include/unotools/collatorwrapper.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_COLLATORWRAPPER_HXX +#define _UNOTOOLS_COLLATORWRAPPER_HXX + +#include <com/sun/star/i18n/XCollator.hpp> + +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +}}}} + +class UNOTOOLS_DLLPUBLIC CollatorWrapper +{ + private: + + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext + > mxServiceFactory; + + ::com::sun::star::uno::Reference< + ::com::sun::star::i18n::XCollator + > mxInternationalCollator; + + public: + + CollatorWrapper ( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > &rxContext); + + ~CollatorWrapper(); + + sal_Int32 + compareString ( + const OUString& s1, const OUString& s2) const; + + ::com::sun::star::uno::Sequence< OUString > + listCollatorAlgorithms ( + const ::com::sun::star::lang::Locale& rLocale) const; + + sal_Int32 + loadDefaultCollator ( + const ::com::sun::star::lang::Locale& rLocale, sal_Int32 nOption); + + sal_Int32 + loadCollatorAlgorithm ( + const OUString& rAlgorithm, + const ::com::sun::star::lang::Locale& rLocale, sal_Int32 nOption); + + protected: + + CollatorWrapper(); +}; + +#endif /* _UNOTOOLS_COLLATORWRAPPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx new file mode 100644 index 000000000000..16c73dbc3215 --- /dev/null +++ b/include/unotools/compatibility.hxx @@ -0,0 +1,240 @@ +/* -*- 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_unotools_COMPATIBILITY_HXX +#define INCLUDED_unotools_COMPATIBILITY_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <unotools/options.hxx> + +//_________________________________________________________________________________________________________________ +// types, enums, ... +//_________________________________________________________________________________________________________________ + +enum CompatibilityOptions +{ + COPT_USE_PRINTERDEVICE = 0, + COPT_ADD_SPACING, + COPT_ADD_SPACING_AT_PAGES, + COPT_USE_OUR_TABSTOPS, + COPT_NO_EXTLEADING, + COPT_USE_LINESPACING, + COPT_ADD_TABLESPACING, + COPT_USE_OBJECTPOSITIONING, + COPT_USE_OUR_TEXTWRAPPING, + COPT_CONSIDER_WRAPPINGSTYLE, + COPT_EXPAND_WORDSPACE +}; + +/*-************************************************************************************************************//** + @descr The method GetList() returns a list of property values. + Use follow defines to seperate values by names. +*//*-*************************************************************************************************************/ +#define COMPATIBILITY_PROPERTYNAME_NAME OUString( "Name" ) +#define COMPATIBILITY_PROPERTYNAME_MODULE OUString( "Module" ) +#define COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS OUString( "UsePrinterMetrics" ) +#define COMPATIBILITY_PROPERTYNAME_ADDSPACING OUString( "AddSpacing" ) +#define COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES OUString( "AddSpacingAtPages" ) +#define COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS OUString( "UseOurTabStopFormat" ) +#define COMPATIBILITY_PROPERTYNAME_NOEXTLEADING OUString( "NoExternalLeading" ) +#define COMPATIBILITY_PROPERTYNAME_USELINESPACING OUString( "UseLineSpacing" ) +#define COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING OUString( "AddTableSpacing" ) +#define COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING OUString( "UseObjectPositioning" ) +#define COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING OUString( "UseOurTextWrapping" ) +#define COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE OUString( "ConsiderWrappingStyle" ) +#define COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE OUString( "ExpandWordSpace" ) + +#define COMPATIBILITY_DEFAULT_NAME OUString( "_default" ) + +//_________________________________________________________________________________________________________________ +// forward declarations +//_________________________________________________________________________________________________________________ + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtCompatibilityOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about dynamic menus + @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard". + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtCompatibilityOptions(); + virtual ~SvtCompatibilityOptions(); + + //--------------------------------------------------------------------------------------------------------- + // interface + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short clear complete specified list + @descr Call this methods to clear the whole list. + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void Clear(); + + void SetDefault( OUString sName, bool bValue ); + + /*-****************************************************************************************************//** + @short return complete specified list + @descr Call it to get all entries of compatibility options. + We return a list of all nodes with its names and properties. + + @seealso - + + @param - + @return A list of compatibility options is returned. + + @onerror We return an empty list. + *//*-*****************************************************************************************************/ + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > GetList() const; + + /*-****************************************************************************************************//** + @short append a new item + @descr + + @seealso method Clear() + + @param "sName" Name + @param "sModule" Module + + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void AppendItem( const OUString& sName, + const OUString& sModule, + bool bUsePrtMetrics, + bool bAddSpacing, + bool bAddSpacingAtPages, + bool bUseOurTabStops, + bool bNoExtLeading, + bool bUseLineSpacing, + bool bAddTableSpacing, + bool bUseObjectPositioning, + bool bUseOurTextWrapping, + bool bConsiderWrappingStyle, + bool bExpandWordSpace ); + + bool IsUsePrtDevice() const; + bool IsAddSpacing() const; + bool IsAddSpacingAtPages() const; + bool IsUseOurTabStops() const; + bool IsNoExtLeading() const; + bool IsUseLineSpacing() const; + bool IsAddTableSpacing() const; + bool IsUseObjectPositioning() const; + bool IsUseOurTextWrapping() const; + bool IsConsiderWrappingStyle() const; + bool IsExpandWordSpace() const; + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtCompatibilityOptions_Impl* m_pDataContainer; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtCompatibilityOptions + +#endif // #ifndef INCLUDED_unotools_COMPATIBILITY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/componentresmodule.hxx b/include/unotools/componentresmodule.hxx new file mode 100644 index 000000000000..0014794f3584 --- /dev/null +++ b/include/unotools/componentresmodule.hxx @@ -0,0 +1,180 @@ +/* -*- 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 UNOTOOLS_INC_UNOTOOLS_COMPONENTRESMODULE_HXX +#define UNOTOOLS_INC_UNOTOOLS_COMPONENTRESMODULE_HXX + +#include <comphelper/componentmodule.hxx> +#include <unotools/unotoolsdllapi.h> + +#include <tools/resid.hxx> + +#include <memory> + +class ResMgr; + +//........................................................................ +namespace utl +{ +//........................................................................ + + class OComponentResModuleImpl; + + //==================================================================== + //= OComponentResourceModule + //==================================================================== + /** extends the <type scope="comphelper">OModule</type> implementation with + simply resource access + */ + class UNOTOOLS_DLLPUBLIC OComponentResourceModule : public ::comphelper::OModule + { + private: + typedef ::comphelper::OModule BaseClass; + + private: + ::std::auto_ptr< OComponentResModuleImpl > m_pImpl; + + public: + OComponentResourceModule( const OString& _rResFilePrefix ); + ~OComponentResourceModule(); + + /// get the vcl res manager of the module + ResMgr* getResManager(); + + protected: + // OModule overridables + virtual void onFirstClient(); + virtual void onLastClient(); + }; + + //========================================================================= + //= ModuleRes + //========================================================================= + /** specialized ResId, using the resource manager provided by a given <type>OModule</type> + */ + class UNOTOOLS_DLLPUBLIC ModuleRes : public ::ResId + { + public: + ModuleRes( sal_uInt16 _nId, OComponentResourceModule& _rModule ) : ResId( _nId, *_rModule.getResManager() ) { } + }; + + //==================================================================== + //= defining a concrete module + //==================================================================== +#define DEFINE_MODULE( ModuleClass, ClientClass, ResClass ) \ + /* -------------------------------------------------------------------- */ \ + class ModuleClass : public ::utl::OComponentResourceModule \ + { \ + friend struct CreateModuleClass; \ + typedef ::utl::OComponentResourceModule BaseClass; \ + \ + public: \ + static ModuleClass& getInstance(); \ + \ + private: \ + ModuleClass(); \ + }; \ + \ + /* -------------------------------------------------------------------- */ \ + class ClientClass : public ::comphelper::OModuleClient \ + { \ + private: \ + typedef ::comphelper::OModuleClient BaseClass; \ + \ + public: \ + ClientClass() : BaseClass( ModuleClass::getInstance() ) \ + { \ + } \ + }; \ + \ + /* -------------------------------------------------------------------- */ \ + class ResClass : public ::utl::ModuleRes \ + { \ + private: \ + typedef ::utl::ModuleRes BaseClass; \ + \ + public: \ + ResClass( sal_uInt16 _nId ) : BaseClass( _nId, ModuleClass::getInstance() ) \ + { \ + } \ + }; \ + \ + /* -------------------------------------------------------------------- */ \ + template < class TYPE > \ + class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE > \ + { \ + private: \ + typedef ::comphelper::OAutoRegistration< TYPE > BaseClass; \ + \ + public: \ + OAutoRegistration() : BaseClass( ModuleClass::getInstance() ) \ + { \ + } \ + }; \ + \ + /* -------------------------------------------------------------------- */ \ + template < class TYPE > \ + class OSingletonRegistration : public ::comphelper::OSingletonRegistration< TYPE > \ + { \ + private: \ + typedef ::comphelper::OSingletonRegistration< TYPE > BaseClass; \ + \ + public: \ + OSingletonRegistration() : BaseClass( ModuleClass::getInstance() ) \ + { \ + } \ + }; + + //==================================================================== + //= implementing a concrete module + //==================================================================== +#define IMPLEMENT_MODULE( ModuleClass, resprefix ) \ + struct CreateModuleClass \ + { \ + ModuleClass* operator()() \ + { \ + static ModuleClass* pModule = new ModuleClass; \ + return pModule; \ + /* yes, in theory, this is a resource leak, since the ModuleClass \ + will never be cleaned up. However, using a non-heap instance of ModuleClass \ + would not work: It would be cleaned up when the module is unloaded. \ + This might happen (and is likely to happen) *after* the tools-library \ + has been unloaded. However, the module's dtor is where we would delete \ + our resource manager (in case not all our clients de-registered) - which \ + would call into the already-unloaded tools-library. */ \ + } \ + }; \ + \ + ModuleClass::ModuleClass() \ + :BaseClass( OString( resprefix ) ) \ + { \ + } \ + \ + ModuleClass& ModuleClass::getInstance() \ + { \ + return *rtl_Instance< ModuleClass, CreateModuleClass, ::osl::MutexGuard, ::osl::GetGlobalMutex >:: \ + create( CreateModuleClass(), ::osl::GetGlobalMutex() ); \ + } \ + +//........................................................................ +} // namespace utl +//........................................................................ + +#endif // UNOTOOLS_INC_UNOTOOLS_COMPONENTRESMODULE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/configitem.hxx b/include/unotools/configitem.hxx new file mode 100644 index 000000000000..d9f7675a185e --- /dev/null +++ b/include/unotools/configitem.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UTL_CONFIGITEM_HXX_ +#define _UTL_CONFIGITEM_HXX_ + +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Reference.h> +#include "unotools/unotoolsdllapi.h" +#include "unotools/options.hxx" + +//----------------------------------------------------------------------------- +namespace com{ namespace sun{ namespace star{ + namespace uno{ + class Any; + } + namespace beans{ + struct PropertyValue; + } + namespace container{ + class XHierarchicalNameAccess; + } + namespace util{ + class XChangesListener; + } +}}} +//----------------------------------------------------------------------------- +namespace utl +{ +#define CONFIG_MODE_IMMEDIATE_UPDATE 0x00 +#define CONFIG_MODE_DELAYED_UPDATE 0x01 +#define CONFIG_MODE_ALL_LOCALES 0x02 +#define CONFIG_MODE_RELEASE_TREE 0x04 + + enum ConfigNameFormat + { + CONFIG_NAME_PLAINTEXT_NAME, // unescaped local node name, for user display etc. + CONFIG_NAME_LOCAL_NAME, // local node name, for use in XNameAccess etc. ("Item", "Q & A") + CONFIG_NAME_LOCAL_PATH, // one-level relative path, for use when building paths etc. ("Item", "Typ['Q & A']") + CONFIG_NAME_FULL_PATH, // full absolute path. ("/org.openoffice.Sample/Group/Item", "/org.openoffice.Sample/Set/Typ['Q & A']") + + CONFIG_NAME_DEFAULT = CONFIG_NAME_LOCAL_PATH // default format + }; + + class ConfigChangeListener_Impl; + class ConfigManager; + struct ConfigItem_Impl; + + class UNOTOOLS_DLLPUBLIC ConfigItem : public ConfigurationBroadcaster + { + friend class ConfigChangeListener_Impl; + friend class ConfigManager; + + const OUString sSubTree; + com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess> + m_xHierarchyAccess; + com::sun::star::uno::Reference< com::sun::star::util::XChangesListener > + xChangeLstnr; + ConfigItem_Impl* pImpl; + + ConfigItem();// + void RemoveChangesListener(); + void CallNotify( + const com::sun::star::uno::Sequence<OUString>& aPropertyNames); + + //*********************************************************************************************************************** + // In special mode ALL_LOCALES we must support reading/writing of localized cfg entries as Sequence< PropertyValue >. + // These methods are helper to convert given lists of names and Any-values. + // format: PropertyValue.Name = <locale as ISO string> + // PropertyValue.Value = <value; type depends from cfg entry!> + // e.g. + // LOCALIZED NODE + // "UIName" + // LOCALE VALUE + // "de" "Mein Name" + // "en-US" "my name" + void impl_packLocalizedProperties ( const com::sun::star::uno::Sequence< OUString >& lInNames , + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& lInValues , + com::sun::star::uno::Sequence< com::sun::star::uno::Any >& lOutValues ); + void impl_unpackLocalizedProperties ( const com::sun::star::uno::Sequence< OUString >& lInNames , + const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& lInValues , + com::sun::star::uno::Sequence< OUString >& lOutNames , + com::sun::star::uno::Sequence< com::sun::star::uno::Any >& lOutValues ); + + com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess> + GetTree(); + + protected: + explicit ConfigItem(const OUString &rSubTree, + sal_Int16 nMode = CONFIG_MODE_DELAYED_UPDATE); + + void SetModified (); // mark item as modified + void ClearModified(); // reset state after commit! + + com::sun::star::uno::Sequence< com::sun::star::uno::Any> + GetProperties(const com::sun::star::uno::Sequence< OUString >& rNames); + + com::sun::star::uno::Sequence< sal_Bool > + GetReadOnlyStates(const com::sun::star::uno::Sequence< OUString >& rNames); + + sal_Bool PutProperties( + const com::sun::star::uno::Sequence< OUString >& rNames, + const com::sun::star::uno::Sequence< com::sun::star::uno::Any>& rValues); + + /** enables notifications about changes on selected sub nodes/values + + Before calling this method a second time for a possibly changed node/value set, + you must disable the current notifications by calling DisableNotification. + + @see Notify + @see DisableNotification + */ + sal_Bool EnableNotification(const com::sun::star::uno::Sequence< OUString >& rNames, + sal_Bool bEnableInternalNotification = sal_False); + /** disables notifications about changes on sub nodes/values, which previosly had + been enabled with EnableNotification + @see Notify + @see EnableNotification + */ + void DisableNotification(); + sal_Bool IsInternalNotification()const {return IsInValueChange();} + + //returns all members of a node in a specific format + com::sun::star::uno::Sequence< OUString > + GetNodeNames(const OUString& rNode); + //returns all members of a node in a specific format + com::sun::star::uno::Sequence< OUString > + GetNodeNames(const OUString& rNode, ConfigNameFormat eFormat); + // remove all members of a set + sal_Bool ClearNodeSet(const OUString& rNode); + // remove selected members of a set + sal_Bool ClearNodeElements(const OUString& rNode, + com::sun::star::uno::Sequence< OUString >& rElements); + // change or add members to a set + sal_Bool SetSetProperties(const OUString& rNode, com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues); + // remove, change or add members of a set + sal_Bool ReplaceSetProperties(const OUString& rNode, com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues); + // add a new node without setting any properties + sal_Bool AddNode(const OUString& rNode, const OUString& rNewNode); + + /** get a name for a new element of a set node + @param _rSetNode + relative path to the set node + @param _rBaseName + <ul><li><b>in</b>: the base to use when calculating a new name</li> + <li><b>out</b>: an unused element name</li> + </ul> + @return <TRUE/> if a free name could be generated + */ + sal_Bool getUniqueSetElementName( const OUString& _rSetNode, OUString& _rBaseName); + + public: + virtual ~ConfigItem(); + + /** is called from the ConfigManager before application ends of from the + PropertyChangeListener if the sub tree broadcasts changes. */ + virtual void Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames)=0; + + const OUString& GetSubTreeName() const {return sSubTree;} + + sal_Bool IsModified() const; + + /** writes the changed values into the sub tree. Always called in the Dtor of the derived class. */ + virtual void Commit()=0; + + sal_Bool IsInValueChange() const; + + sal_Int16 GetMode() const; + + /** checks if the configuration manager used by this item is valid. + */ + sal_Bool IsValidConfigMgr() const; + }; +}//namespace utl +#endif //_UTL_CONFIGITEM_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/configmgr.hxx b/include/unotools/configmgr.hxx new file mode 100644 index 000000000000..f5964a505cf4 --- /dev/null +++ b/include/unotools/configmgr.hxx @@ -0,0 +1,93 @@ +/* -*- 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_UNOTOOLS_CONFIGMGR_HXX +#define INCLUDED_UNOTOOLS_CONFIGMGR_HXX + +#include "sal/config.h" + +#include <list> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "sal/types.h" +#include "unotools/unotoolsdllapi.h" + +namespace com { namespace sun { namespace star { + namespace container{ class XHierarchicalNameAccess; } +} } } +namespace utl { class ConfigItem; } + +namespace utl { + +class UNOTOOLS_DLLPUBLIC ConfigManager: private boost::noncopyable { +public: + static OUString getAboutBoxProductVersion(); + + static OUString getAboutBoxProductVersionSuffix(); + + static OUString getDefaultCurrency(); + + static OUString getLocale(); + + static OUString getProductExtension(); + + static OUString getProductName(); + + static OUString getProductXmlFileFormat(); + + static OUString getProductXmlFileFormatVersion(); + + static OUString getProductVersion(); + + static OUString getVendor(); + + static OUString getWriterCompatibilityVersionOOo_1_1(); + + static void storeConfigItems(); + + SAL_DLLPRIVATE static ConfigManager & getConfigManager(); + + SAL_DLLPRIVATE static com::sun::star::uno::Reference< + com::sun::star::container::XHierarchicalNameAccess> + acquireTree(utl::ConfigItem & item); + + SAL_DLLPRIVATE ConfigManager(); + + SAL_DLLPRIVATE ~ConfigManager(); + + SAL_DLLPRIVATE com::sun::star::uno::Reference< + com::sun::star::container::XHierarchicalNameAccess > + addConfigItem(utl::ConfigItem & item); + + SAL_DLLPRIVATE void removeConfigItem(utl::ConfigItem & item); + + SAL_DLLPRIVATE void registerConfigItem(utl::ConfigItem * item); + +private: + void doStoreConfigItems(); + + std::list< ConfigItem * > items_; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/confignode.hxx b/include/unotools/confignode.hxx new file mode 100644 index 000000000000..4e663dd25bbb --- /dev/null +++ b/include/unotools/confignode.hxx @@ -0,0 +1,325 @@ +/* -*- 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 _UNOTOOLS_CONFIGNODE_HXX_ +#define _UNOTOOLS_CONFIGNODE_HXX_ + +#include "unotools/unotoolsdllapi.h" +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <unotools/eventlisteneradapter.hxx> + +namespace comphelper +{ + class ComponentContext; +} + +//........................................................................ +namespace utl +{ +//........................................................................ + + //======================================================================== + //= OConfigurationNode + //======================================================================== + class OConfigurationTreeRoot; + /** a small wrapper around a configuration node.<p/> + Nodes in the terminology used herein are <em>inner</em> nodes of a configuration + tree, which means <em>no leafs</em>. + */ + class UNOTOOLS_DLLPUBLIC OConfigurationNode : public ::utl::OEventListenerAdapter + { + private: + ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > + m_xHierarchyAccess; /// accessing children grandchildren (mandatory interface of our UNO object) + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > + m_xDirectAccess; /// accessing children (mandatory interface of our UNO object) + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > + m_xReplaceAccess; /// replacing child values + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > + m_xContainerAccess; /// modifying set nodes (optional interface of our UNO object) + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + m_xDummy; + sal_Bool m_bEscapeNames; /// escape names before accessing children ? + + OUString + m_sCompletePath; + + OConfigurationNode insertNode(const OUString& _rName,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xNode) const throw(); + + protected: + /// constructs a node object with an interface representing a node + OConfigurationNode( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxNode + ); + + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& + getUNONode() const { return m_xDirectAccess; } + + public: + /// constructs an empty and invalid node object + OConfigurationNode() :m_bEscapeNames(sal_False) { } + /// copy ctor + OConfigurationNode(const OConfigurationNode& _rSource); + + /// assigment + const OConfigurationNode& operator=(const OConfigurationNode& _rSource); + + /// dtor + ~OConfigurationNode() {} + + /// returns the local name of the node + OUString getLocalName() const; + + /// returns the fully qualified path of the node + OUString getNodePath() const; + + /** open a sub node + @param _rPath access path of the to-be-opened sub node. May be a hierarchical path. + */ + OConfigurationNode openNode(const OUString& _rPath) const throw(); + + OConfigurationNode openNode( const sal_Char* _pAsciiPath ) const + { + return openNode( OUString::createFromAscii( _pAsciiPath ) ); + } + + /** create a new child node + + If the object represents a set node, this method may be used to create a new child. For non-set-nodes, the + method will fail.<br/> + Unless the respective operations on the pure configuration API, the to-be-created node immediately + becomes a part of it's hierarchy, no explicit insertion is necessary. + @param _rName name for the new child. Must be level-1-depth. + */ + OConfigurationNode createNode(const OUString& _rName) const throw(); + + OConfigurationNode createNode( const sal_Char* _pAsciiName ) const + { + return createNode( OUString::createFromAscii( _pAsciiName ) ); + } + + /** remove an existent child nod + + If the object represents a set node, this method may be used to delete an existent child. For non-set-nodes, + the method will fail. + */ + sal_Bool removeNode(const OUString& _rName) const throw(); + + sal_Bool removeNode( const sal_Char* _pAsciiName ) const + { + return removeNode( OUString::createFromAscii( _pAsciiName ) ); + } + + /** retrieves the content of a descendant + + the returned value may contain anything from an interface (if <arg>_rPath</arg> refers to inner node of + the configuration tree) to any explicit value (e.g. string, integer) or even void.<br/> + Unfortunately, this implies that if a void value is returned, you won't have a clue if this means + "the path does not exist" (besides the assertion made :), or if the value is really void. + */ + ::com::sun::star::uno::Any + getNodeValue(const OUString& _rPath) const throw(); + + ::com::sun::star::uno::Any + getNodeValue( const sal_Char* _pAsciiPath ) const + { + return getNodeValue( OUString::createFromAscii( _pAsciiPath ) ); + } + + /** write a node value<p/> + The value given is written into the node specified by the given relative path.<br/> + In opposite to <method>getNodeValue</method>, _rName must refer to a leaf in the configuration tree, not an inner + node. + @return sal_True if and only if the write was successful. + */ + sal_Bool setNodeValue(const OUString& _rPath, const ::com::sun::star::uno::Any& _rValue) const throw(); + + sal_Bool setNodeValue( const sal_Char* _pAsciiPath, const ::com::sun::star::uno::Any& _rValue ) const + { + return setNodeValue( OUString::createFromAscii( _pAsciiPath ), _rValue ); + } + + /// return the names of the existing children + ::com::sun::star::uno::Sequence< OUString > + getNodeNames() const throw(); + + /** enables or disables name escaping when accessing direct children<p/> + Escaping is disabled by default, usually you enable it for set nodes (e.g. with calling setEscape(isSetNode)). + Once escaping is enabled, you should not access indirect children (e.g. openNode("child/grandchild"), 'cause + escaping for such names may not be supported by the underlying API objects. + @see getEscape + */ + void setEscape(sal_Bool _bEnable = sal_True); + /** get the flag specifying the current escape behaviour + @see setEscape + */ + sal_Bool getEscape() const { return m_bEscapeNames; } + + /// invalidate the object + virtual void clear() throw(); + + // ----------------------- + // meta information about the node + + /// checks whether or not the object represents a set node. + sal_Bool isSetNode() const; + + /// checks whether or not a direct child with a given name exists + sal_Bool hasByName(const OUString& _rName) const throw(); + sal_Bool hasByName( const sal_Char* _pAsciiName ) const { return hasByName( OUString::createFromAscii( _pAsciiName ) ); } + + /// checks whether or not a descendent (no matter if direct or indirect) with the given name exists + sal_Bool hasByHierarchicalName( const OUString& _rName ) const throw(); + sal_Bool hasByHierarchicalName( const sal_Char* _pAsciiName ) const { return hasByHierarchicalName( OUString::createFromAscii( _pAsciiName ) ); } + + /// check if the objects represents a valid configuration node + sal_Bool isValid() const { return m_xHierarchyAccess.is(); } + + /// check whether the object is read-only of updatable + sal_Bool isReadonly() const { return !m_xReplaceAccess.is(); } + + protected: + // OEventListenerAdapter + virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ); + + protected: + enum NAMEORIGIN + { + NO_CONFIGURATION, /// the name came from a configuration node + NO_CALLER /// the name came from a client of this class + }; + OUString normalizeName(const OUString& _rName, NAMEORIGIN _eOrigin) const; + }; + + //======================================================================== + //= OConfigurationTreeRoot + //======================================================================== + /** a specialized version of a OConfigurationNode, representing the root + of a configuration sub tree<p/> + Only this class is able to commit any changes made any any OConfigurationNode + objects. + */ + class UNOTOOLS_DLLPUBLIC OConfigurationTreeRoot : public OConfigurationNode + { + ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesBatch > + m_xCommitter; + protected: + /** ctor for a readonly node + */ + OConfigurationTreeRoot( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxRootNode + ); + + public: + /// modes to use when creating a top-level node object + enum CREATION_MODE + { + /// open the node (i.e. sub tree) for read access only + CM_READONLY, + /// open the node (i.e. sub tree) for read and write access, fall back to read-only if write access is not possible + CM_UPDATABLE + }; + + public: + /** default ctor<p/> + The object constructed here is invalid (i.e. <method>isValid</method> will return sal_False). + */ + OConfigurationTreeRoot() :OConfigurationNode() { } + + /** creates a configuration tree for the given path in the given mode + */ + OConfigurationTreeRoot( + const css::uno::Reference<css::uno::XComponentContext> & i_rContext, + const OUString& i_rNodePath, + const bool i_bUpdatable + ); + + /// copy ctor + OConfigurationTreeRoot(const OConfigurationTreeRoot& _rSource) + :OConfigurationNode(_rSource), m_xCommitter(_rSource.m_xCommitter) { } + + /** open a new top-level configuration node + + opens a new node which is the root if an own configuration sub tree. This is what "top level" means: The + node does not have a parent. It does not mean that the node represents a module tree (like org.openoffice.Office.Writer + or such).<br/> + In opposite to <method>createWithServiceFactory</method>, createWithProvider expects a configuration provider + to work with. + + @param _rxConfProvider configuration provider to use when retrieving the node. + @param _rPath path to the node the object should represent + @param _nDepth depth for node retrieval + @param _eMode specifies which privileges should be applied when retrieving the node + + @see createWithServiceFactory + */ + static OConfigurationTreeRoot createWithProvider( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxConfProvider, + const OUString& _rPath, + sal_Int32 _nDepth = -1, + CREATION_MODE _eMode = CM_UPDATABLE, + sal_Bool _bLazyWrite = sal_True + ); + + /** open a new top-level configuration node<p/> + opens a new node which is the root if an own configuration sub tree. This is what "top level" means: The + node does not have a parent. It does not mean that the node represents a module tree (like org.openoffice.Office.Writer + or such).<br/> + In opposite to <method>createWithProvider</method>, createWithProvider expects a service factory. This factory + is used to create a configuration provider, and this provider is used to retrieve the node + @see createWithProvider + @param _rxContext service factory to use to create the configuration provider. + @param _rPath path to the node the object should represent + @param _nDepth depth for node retrieval + @param _eMode specifies which privileges should be applied when retrieving the node + */ + static OConfigurationTreeRoot createWithComponentContext(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, + const OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE, sal_Bool _bLazyWrite = sal_True); + + /** tolerant version of the <member>createWithServiceFactory</member> + + <p>No assertions are thrown in case of an failure to initialize the configuration service, but once + the configuration could be initialized, errors in the creation of the specific node (e.g. because the + given node path does not exist) are still asserted.</p> + */ + static OConfigurationTreeRoot tryCreateWithComponentContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const OUString& _rPath, sal_Int32 _nDepth = -1, CREATION_MODE _eMode = CM_UPDATABLE, sal_Bool _bLazyWrite = sal_True ); + + /** commit all changes made on the subtree the object is the root for<p/> + All changes made on any <type>OConfigurationNode</type> object retrieved (maybe indirect) from this root + object are committed when calling this method. + @return sal_True if and only if the commit was successful + */ + sal_Bool commit() const throw(); + + /// invalidate the object + virtual void clear() throw(); + }; + +//........................................................................ +} // namespace utl +//........................................................................ + +#endif // _UNOTOOLS_CONFIGNODE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/configpaths.hxx b/include/unotools/configpaths.hxx new file mode 100644 index 000000000000..d3e400ae1158 --- /dev/null +++ b/include/unotools/configpaths.hxx @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#define UNOTOOLS_CONFIGPATHS_HXX_INCLUDED +#include <sal/types.h> +#include <rtl/ustring.hxx> + +//---------------------------------------------------------------------------- +namespace utl +{ +//---------------------------------------------------------------------------- + /** extract the local nodename and the parent nodepath + from a configuration path. + + @param _sInPath + A configuration path that is not an empty or root path.<BR/> + If this is not a valid configuration path, it is interpreted as + local name of a node. + + @param _rsOutPath + On exit: The configuration path obtained by dropping + the last level off <var>_sInPath</var>.<BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, this is set to an empty string. + + @param _rsLocalName + On exit: The plain (non-escaped) name of the node identified by + <var>_sInPath</var>. <BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, this is set to <var>_sInPath</var>. + + @returns + <TRUE/>, if a parent path could be set + <FALSE/>, if the path was a one-level path or an invalid path + + */ + UNOTOOLS_DLLPUBLIC sal_Bool splitLastFromConfigurationPath(OUString const& _sInPath, + OUString& _rsOutPath, + OUString& _rsLocalName); + +//---------------------------------------------------------------------------- + /** extract the first nodename from a configuration path. + + @param _sInPath + A relative configuration path that is not empty.<BR/> + If this is not a valid configuration path, it is interpreted as + a single name of a node. + + @param _sOutPath + If non-null, contains the remainder of the path upon return. + + @returns + The plain (non-escaped) name of the node that is the first step + when traversing <var>_sInPath</var>.<BR/> + If <var>_sInPath</var> could not be parsed as a valid + configuration path, it is returned unaltered. + + */ + UNOTOOLS_DLLPUBLIC OUString extractFirstFromConfigurationPath( + OUString const& _sInPath, OUString* _sOutPath = 0); + +//---------------------------------------------------------------------------- + /** check whether a path is to a nested node with respect to a parent path. + + @param _sNestedPath + A configuration path that maybe points to a descendant of the node + identified by <var>_sPrefixPath</var>, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.<BR/> + If this path is absolute, <var>_sNestedPath</var> should be absolute; + If this path is relative, <var>_sNestedPath</var> should be relative; + If this path is empty, <var>_sNestedPath</var> may start with a '/', + which is disregarded. + + @returns + <TRUE/>, if <var>_sPrefixPath</var> is a prefix of <var>_sNestedPath</var>; + <FALSE/> otherwise.<BR/> + If both paths are equal <TRUE/> is returned. + + */ + sal_Bool isPrefixOfConfigurationPath(OUString const& _sNestedPath, + OUString const& _sPrefixPath); + +//---------------------------------------------------------------------------- + /** get the relative path to a nested node with respect to a parent path. + + @param _sNestedPath + A configuration path that points to a descendant of the node + identified by <var>_sPrefixPath</var>, with both paths starting + from the same node (or both being absolute). + + @param _sPrefixPath + A configuration path.<BR/> + If this path is absolute, <var>_sNestedPath</var> must be absolute; + If this path is relative, <var>_sNestedPath</var> must be relative; + If this path is empty, <var>_sNestedPath</var> may start with a '/', + which is stripped. + + @returns + The remaining relative path from the target of <var>_sPrefixPath</var> + to the target of <var>_sNestedPath</var>.<BR/> + If <var>_sPrefixPath</var> is not a prefix of <var>_sNestedPath</var>, + <var>_sNestedPath</var> is returned unaltered. + + */ + UNOTOOLS_DLLPUBLIC OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, + OUString const& _sPrefixPath); + +//---------------------------------------------------------------------------- + /** Create a one-level relative configuration path from a set element name + without a known set element type. + + @param _sElementName + An arbitrary string that is to be interpreted as + name of a configuration set element. + + @returns + A one-level relative path to the element, of the form + "*['<Name>']", where <Name> is properly escaped. + + */ + UNOTOOLS_DLLPUBLIC OUString wrapConfigurationElementName(OUString const& _sElementName); + +//---------------------------------------------------------------------------- + /** Create a one-level relative configuration path from a set element name + and a known set element type. + + @param _sElementName + An arbitrary string that is to be interpreted as + name of a configuration set element. + + @param _sTypeName + An string identifying the type of the element. Usually this is be + the name of the element-template of the set.<BR/> + + @returns + A one-level relative path to the element, of the form + "<Type>['<Name>']", where <Name> is properly escaped. + + */ + OUString wrapConfigurationElementName(OUString const& _sElementName, + OUString const& _sTypeName); + +//---------------------------------------------------------------------------- +} // namespace utl +//---------------------------------------------------------------------------- + +#endif // UNOTOOLS_CONFIGPATHS_HXX_INCLUDED + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/configvaluecontainer.hxx b/include/unotools/configvaluecontainer.hxx new file mode 100644 index 000000000000..2fa95c337bd0 --- /dev/null +++ b/include/unotools/configvaluecontainer.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef UNOTOOLS_CONFIGVALUECONTAINER_HXX +#define UNOTOOLS_CONFIGVALUECONTAINER_HXX +#include <com/sun/star/uno/XComponentContext.hpp> +#include <osl/mutex.hxx> + +//......................................................................... +namespace utl +{ +//......................................................................... + +#define CVC_READONLY_ACCESS 0x0000 +#define CVC_UPDATE_ACCESS 0x0001 + +#define CVC_LAZY_UPDATE 0x0000 +#define CVC_IMMEDIATE_UPDATE 0x0002 + + struct OConfigurationValueContainerImpl; + struct NodeValueAccessor; + //===================================================================== + //= OConfigurationValueContainer + //===================================================================== + /** allows simple access to static configuration structures. + + <p>The basic idea of this class is that it's clients (usually derived classes) simply register an + address in memory and a node path, and upon explicit request, the configuration value and the memory + are syncronized.<br/> + This means that when calling <method>read</method>, the current configuration values are copied into + the memory registered for them, and upon calling <method>write</method> the current values in memory + are set in the configuration nodes.</p> + + <p>This way, the usage of this class is pretty straight forward: derive your own class, spend some members + to it, and bind these members to configuration node (usually done in the ctor of the derived class).<br/> + In the dtor, simply call <method>write</method> and <method>commit</method>.</p> + + <p>There is no auto-commit mechanism in the dtor: In the usual scenario, when you derive from this class + and bind some members of your derived class to config nodes, this means that your members will be destroyed + before your base class' dtor is called, so accessing the memory during such a theoretical auto-commit would + yield undefined behaviour.</p> + */ + class UNOTOOLS_DLLPUBLIC OConfigurationValueContainer + { + private: + OConfigurationValueContainerImpl* + m_pImpl; + + protected: + //----------------------------------------------------------------- + // construction/destruction + + /** constructs the object + + @param _rxORB + specifies the service factory which should be used to access the configuration + @param _rAccessSafety + As this class is intented to manipulate objects it does not hold itself (see the various + registerXXX methods), it needs to guard these access for muti threading safety.<br/> + The mutex given here is locked whenever such an access occurs. + @param _pConfigLocation + is an ASCII string describing the configurations node path + @param _nAccessFlags + specifies different aspects of the configuration aspect to be created, e.g. it's update mode etc.<br/> + See the CVC_xxx constants for what you can use here. + @param _nLevels + specifies the number of levels to access under the node given by <arg>_pConfigLocation</arg> + */ + OConfigurationValueContainer( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB, + ::osl::Mutex& _rAccessSafety, + const sal_Char* _pConfigLocation, + const sal_uInt16 _nAccessFlags = CVC_UPDATE_ACCESS | CVC_LAZY_UPDATE, + const sal_Int32 _nLevels = -1 + ); + + /// dtor + ~OConfigurationValueContainer(); + + //----------------------------------------------------------------- + // registering data containers + + /** registers a data accessor of an arbitrary type. + + <p>Usually, in your derived class you simply add a member of the correct type of the configuration + value, and then call this method with the address of this member.</p> + + @param _pRelativePathAscii + is a relative (ASCII) path of the node which should be "mirrored" into the accessor. + @param _pContainer + points to the accessors location in memory. Usually, this is simply an address of your derived class + @param _rValueType + is the type of your accessort. This type must be supported by the configuration. + */ + void registerExchangeLocation( + const sal_Char* _pRelativePathAscii, + void* _pContainer, + const ::com::sun::star::uno::Type& _rValueType + ); + + public: + /** reads the configuration data + + <p>The current values of the nodes bound (using the registerXXX methods) is copied into their + respective exchange locations.</p> + + <p>Please note that any changes done to your exchange locations are overridden with the current config + values.</p> + + @see write + */ + void read( ); + + /** updates the configuration data + + <p>The current values in memory (your exchange locations registered using the registerXXX methods) is + forwarded to their respective configuration nodes.</p> + + <p>Note that calling <method>write</method>(<sal_True/) is the same as calling <method>commit</method>(<TRUE/>).</p> + + @precond + The access must have been created for update access + + @param _bCommit + If set to <TRUE/>, an automatic commit is done after the values have been synchronized.<br/> + If set to <FALSE/>, you must explicitly call <method>commit</method> to make your changes persistent. + + @see read + @see commit + */ + void write( sal_Bool _bCommit = sal_True ); + + /** commits any changes done + + <p>Note that calling <method>write</method>(<sal_True/) is the same as calling <method>commit</method>(<TRUE/>).</p> + + @precond + The access must have been created for update access + + @param _bWrite + If <TRUE/>, the current values in the exchange locations are written to the configuration nodes + before the changes are committed.<br/> + If <FALSE/>, only the current values in the config nodes (as present since the last call to + <method>write</method>) are committed. + */ + void commit( sal_Bool _bWrite = sal_True ); + + private: + /// implements the ctors + void implConstruct( + const OUString& _rConfigLocation, + const sal_uInt16 _nAccessFlags, + const sal_Int32 _nLevels + ); + + /// registers a value container + void implRegisterExchangeLocation( const NodeValueAccessor& _rAccessor ); + }; + +//......................................................................... +} // namespace utl +//......................................................................... + +#endif // UNOTOOLS_CONFIGVALUECONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/datetime.hxx b/include/unotools/datetime.hxx new file mode 100644 index 000000000000..dfc0ab139825 --- /dev/null +++ b/include/unotools/datetime.hxx @@ -0,0 +1,59 @@ +/* -*- 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 . + */ + +//= conversions UNO3.TimeClass <-> Tools.TimeClass (Date/Time/DateTime) +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_DATETIME_HXX_ +#define _UNOTOOLS_DATETIME_HXX_ + +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/DateTime.hpp> + +class Date; +class Time; +class DateTime; + +//......................................................................... +namespace utl +{ +//......................................................................... + + namespace starutil = ::com::sun::star::util; + + UNOTOOLS_DLLPUBLIC void typeConvert(const Date& _rDate, starutil::Date& _rOut); + UNOTOOLS_DLLPUBLIC void typeConvert(const starutil::Date& _rDate, Date& _rOut); + + UNOTOOLS_DLLPUBLIC void typeConvert(const DateTime& _rDateTime, starutil::DateTime& _rOut); + UNOTOOLS_DLLPUBLIC void typeConvert(const starutil::DateTime& _rDateTime, DateTime& _rOut); + + UNOTOOLS_DLLPUBLIC ::rtl::OUString toISO8601(const starutil::DateTime& _rDateTime); + UNOTOOLS_DLLPUBLIC ::rtl::OUString toISO8601(const starutil::Time& _rTime); + UNOTOOLS_DLLPUBLIC bool ISO8601parseDateTime(const ::rtl::OUString &i_rIn, starutil::DateTime& o_rDateTime); + UNOTOOLS_DLLPUBLIC bool ISO8601parseDate(const ::rtl::OUString &i_rIn, starutil::Date& o_rDate); + UNOTOOLS_DLLPUBLIC bool ISO8601parseTime(const ::rtl::OUString &i_rIn, starutil::Time& o_Time); + +//......................................................................... +} // namespace utl +//......................................................................... + +#endif // _UNOTOOLS_DATETIME_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/defaultoptions.hxx b/include/unotools/defaultoptions.hxx new file mode 100644 index 000000000000..175fd3239f7a --- /dev/null +++ b/include/unotools/defaultoptions.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_unotools_DEFAULTOPTIONS_HXX +#define INCLUDED_unotools_DEFAULTOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include "tools/solar.h" +#include <unotools/options.hxx> + +class String; +class SvtDefaultOptions_Impl; + +// class SvtDefaultOptions ----------------------------------------------- + +class SvtDefaultOptions_Impl; +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtDefaultOptions : public utl::detail::Options +{ +private: + SvtDefaultOptions_Impl* pImp; + +public: + + SvtDefaultOptions(); + virtual ~SvtDefaultOptions(); + + String GetDefaultPath( sal_uInt16 nId ) const; +}; + +#endif // #ifndef INCLUDED_unotools_DEFAULTOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/desktopterminationobserver.hxx b/include/unotools/desktopterminationobserver.hxx new file mode 100644 index 000000000000..0f771669a485 --- /dev/null +++ b/include/unotools/desktopterminationobserver.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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef UNOTOOLS_INC_UNOTOOLS_DESKTOPTERMINATIONOBSERVER_HXX +#define UNOTOOLS_INC_UNOTOOLS_DESKTOPTERMINATIONOBSERVER_HXX + +//........................................................................ +namespace utl +{ +//........................................................................ + + //==================================================================== + //= ITerminationListener + //==================================================================== + /** non-UNO version of the <type scope="com.sun.star.frame">XTerminateListener</type> + */ + class ITerminationListener + { + public: + virtual bool queryTermination() const = 0; + virtual void notifyTermination() = 0; + + protected: + ~ITerminationListener() {} + }; + + //==================================================================== + //= DesktopTerminationObserver + //==================================================================== + /** a class which allows non-UNO components to observe the desktop (aka application) + for it's shutdown + */ + class UNOTOOLS_DLLPUBLIC DesktopTerminationObserver + { + public: + /** registers a listener which should be notified when the desktop terminates + (which means the application is shutting down) + */ + static void registerTerminationListener( ITerminationListener* _pListener ); + + /** revokes a termination listener + */ + static void revokeTerminationListener( ITerminationListener* _pListener ); + + private: + DesktopTerminationObserver(); // never implemented, only static methods + }; + +//........................................................................ +} // namespace utl +//........................................................................ + +#endif // UNOTOOLS_INC_UNOTOOLS_DESKTOPTERMINATIONOBSERVER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/digitgroupingiterator.hxx b/include/unotools/digitgroupingiterator.hxx new file mode 100644 index 000000000000..d7bca117756b --- /dev/null +++ b/include/unotools/digitgroupingiterator.hxx @@ -0,0 +1,198 @@ +/* -*- 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_UNOTOOLS_DIGITGROUPINGITERATOR_HXX +#define INCLUDED_UNOTOOLS_DIGITGROUPINGITERATOR_HXX + +#include <com/sun/star/uno/Sequence.hxx> + +namespace utl { + +/** Iterator to be used with a digit grouping as obtained through + LocaleDataWrapper::getDigitGrouping(). + + The iterator advances over the digit groupings, returning the number of + digits per group. If the last group was encountered the iterator will + always return the last grouping. + + Grouping values are sanitized to be 0 <= value <= SAL_MAX_UINT16, even if + originally Int32, to be able to easily cast it down to String's xub_StrLen. + This shouldn't make any difference in practice. + + Usage example with a string buffer containing a decimal representation of + an integer number. Note that of course this loop could be optimized to not + count single characters but hunks of groups instead using the get() method, + this is just for illustrating usage. Anyway, for double values it is highly + more efficient to use ::rtl::math::doubleToString() and pass the grouping + sequence, instead of using this iterator and inserting characters into + strings. + + DigitGroupingIterator aGrouping(...) + sal_Int32 nCount = 0; + sal_Int32 n = aBuffer.getLength(); + // >1 because we don't want to insert a separator if there is no leading digit. + while (n-- > 1) + { + if (++nCount >= aGrouping.getPos()) + { + aBuffer.insert( n, cSeparator); + nGroupDigits = aGrouping.advance(); + } + } + + */ + +class DigitGroupingIterator +{ + const ::com::sun::star::uno::Sequence< sal_Int32 > maGroupings; + + sal_Int32 mnGroup; // current active grouping + sal_Int32 mnDigits; // current active digits per group + sal_Int32 mnNextPos; // position (in digits) of next grouping + + void setInfinite() + { + mnGroup = maGroupings.getLength(); + } + + bool isInfinite() const + { + return mnGroup >= maGroupings.getLength(); + } + + sal_Int32 getGrouping() const + { + if (mnGroup < maGroupings.getLength()) + { + sal_Int32 n = maGroupings[mnGroup]; + OSL_ENSURE( 0 <= n && n <= SAL_MAX_UINT16, "DigitGroupingIterator::getGrouping: far out"); + if (n < 0) + n = 0; // sanitize ... + else if (n > SAL_MAX_UINT16) + n = SAL_MAX_UINT16; // limit for use with xub_StrLen + return n; + } + return 0; + } + + void setPos() + { + // someone might be playing jokes on us, so check for overflow + if (mnNextPos <= SAL_MAX_INT32 - mnDigits) + mnNextPos += mnDigits; + } + + void setDigits() + { + sal_Int32 nPrev = mnDigits; + mnDigits = getGrouping(); + if (!mnDigits) + { + mnDigits = nPrev; + setInfinite(); + } + setPos(); + } + + void initGrouping() + { + mnDigits = 3; // just in case of constructed with empty grouping + mnGroup = 0; + mnNextPos = 0; + setDigits(); + } + + // not implemented, prevent usage + DigitGroupingIterator(); + DigitGroupingIterator( const DigitGroupingIterator & ); + DigitGroupingIterator & operator=( const DigitGroupingIterator & ); + +public: + + explicit DigitGroupingIterator( const ::com::sun::star::uno::Sequence< sal_Int32 > & rGroupings ) + : maGroupings( rGroupings) + { + initGrouping(); + } + + /** Advance iterator to next grouping. */ + DigitGroupingIterator & advance() + { + if (isInfinite()) + setPos(); + else + { + ++mnGroup; + setDigits(); + } + return *this; + } + + /** Obtain current grouping. Always > 0. */ + sal_Int32 get() const + { + return mnDigits; + } + + /** The next position (in integer digits) from the right where to insert a + group separator. */ + sal_Int32 getPos() + { + return mnNextPos; + } + + /** Reset iterator to start again from the right beginning. */ + void reset() + { + initGrouping(); + } + + /** Create a sequence of bool values containing positions where to add a + separator when iterating forward over a string and copying digit per + digit. For example, for grouping in thousands and nIntegerDigits==7 the + sequence returned would be {1,0,0,1,0,0,0} so the caller would add a + separator after the 1st and the 4th digit. */ + static ::com::sun::star::uno::Sequence< sal_Bool > createForwardSequence( + sal_Int32 nIntegerDigits, + const ::com::sun::star::uno::Sequence< sal_Int32 > & rGroupings ) + { + if (nIntegerDigits <= 0) + return ::com::sun::star::uno::Sequence< sal_Bool >(); + DigitGroupingIterator aIterator( rGroupings); + ::com::sun::star::uno::Sequence< sal_Bool > aSeq( nIntegerDigits); + sal_Bool* pArr = aSeq.getArray(); + for (sal_Int32 j = 0; --nIntegerDigits >= 0; ++j) + { + if (j == aIterator.getPos()) + { + pArr[nIntegerDigits] = sal_True; + aIterator.advance(); + } + else + pArr[nIntegerDigits] = sal_False; + } + return aSeq; + } +}; + +} // namespace utl + +#endif // INCLUDED_UNOTOOLS_DIGITGROUPINGITERATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/docinfohelper.hxx b/include/unotools/docinfohelper.hxx new file mode 100644 index 000000000000..be32c3bfc7c9 --- /dev/null +++ b/include/unotools/docinfohelper.hxx @@ -0,0 +1,40 @@ +/* -*- 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 _UNOTOOLS_DOCINFOHELPER_HXX_ +#define _UNOTOOLS_DOCINFOHELPER_HXX_ + +#include <unotools/unotoolsdllapi.h> +#include <rtl/ustring.hxx> + +namespace utl +{ +class UNOTOOLS_DLLPUBLIC DocInfoHelper +{ +public: + static OUString GetGeneratorString(); + +}; + +} // namespace utl + + +#endif // _UNOTOOLS_DOCINFOHELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/dynamicmenuoptions.hxx b/include/unotools/dynamicmenuoptions.hxx new file mode 100644 index 000000000000..46a8a211531c --- /dev/null +++ b/include/unotools/dynamicmenuoptions.hxx @@ -0,0 +1,138 @@ +/* -*- 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_unotools_DYNAMICMENUOPTIONS_HXX +#define INCLUDED_unotools_DYNAMICMENUOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @descr The method GetList() returns a list of property values. + Use follow defines to seperate values by names. +*//*-*************************************************************************************************************/ +#define DYNAMICMENU_PROPERTYNAME_URL OUString("URL") +#define DYNAMICMENU_PROPERTYNAME_TITLE OUString("Title") +#define DYNAMICMENU_PROPERTYNAME_IMAGEIDENTIFIER OUString("ImageIdentifier") +#define DYNAMICMENU_PROPERTYNAME_TARGETNAME OUString("TargetName") + +/*-************************************************************************************************************//** + @descr You can use these enum values to specify right menu if you call our interface methods. +*//*-*************************************************************************************************************/ +enum EDynamicMenuType +{ + E_NEWMENU = 0, + E_WIZARDMENU = 1, + E_HELPBOOKMARKS = 2 +}; + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtDynamicMenuOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about dynamic menus + @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard". + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtDynamicMenuOptions : public utl::detail::Options +{ + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtDynamicMenuOptions(); + virtual ~SvtDynamicMenuOptions(); + + /*-****************************************************************************************************//** + @short return complete specified list + @descr Call it to get all entries of an dynamic menu. + We return a list of all nodes with his names and properties. + + @seealso - + + @param "eMenu" select right menu. + @return A list of menu items is returned. + + @onerror We return an empty list. + *//*-*****************************************************************************************************/ + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > GetMenu( EDynamicMenuType eMenu ) const; + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtDynamicMenuOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtDynamicMenuOptions + +#endif // #ifndef INCLUDED_unotools_DYNAMICMENUOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/eventcfg.hxx b/include/unotools/eventcfg.hxx new file mode 100644 index 000000000000..2ea72642805a --- /dev/null +++ b/include/unotools/eventcfg.hxx @@ -0,0 +1,113 @@ +/* -*- 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 _EVENTCFG_HXX +#define _EVENTCFG_HXX + +#include "unotools/unotoolsdllapi.h" +#include <unotools/configitem.hxx> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/container/XNameReplace.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/implbase2.hxx> +#include <boost/unordered_map.hpp> +#include <vector> + +#define STR_EVENT_STARTAPP 0 +#define STR_EVENT_CLOSEAPP 1 +#define STR_EVENT_DOCCREATED 2 +#define STR_EVENT_CREATEDOC 3 +#define STR_EVENT_LOADFINISHED 4 +#define STR_EVENT_OPENDOC 5 +#define STR_EVENT_PREPARECLOSEDOC 6 +#define STR_EVENT_CLOSEDOC 7 +#define STR_EVENT_SAVEDOC 8 +#define STR_EVENT_SAVEDOCDONE 9 +#define STR_EVENT_SAVEDOCFAILED 10 +#define STR_EVENT_SAVEASDOC 11 +#define STR_EVENT_SAVEASDOCDONE 12 +#define STR_EVENT_SAVEASDOCFAILED 13 +#define STR_EVENT_SAVETODOC 14 +#define STR_EVENT_SAVETODOCDONE 15 +#define STR_EVENT_SAVETODOCFAILED 16 +#define STR_EVENT_ACTIVATEDOC 17 +#define STR_EVENT_DEACTIVATEDOC 18 +#define STR_EVENT_PRINTDOC 19 +#define STR_EVENT_VIEWCREATED 20 +#define STR_EVENT_PREPARECLOSEVIEW 21 +#define STR_EVENT_CLOSEVIEW 22 +#define STR_EVENT_MODIFYCHANGED 23 +#define STR_EVENT_TITLECHANGED 24 +#define STR_EVENT_VISAREACHANGED 25 +#define STR_EVENT_MODECHANGED 26 +#define STR_EVENT_STORAGECHANGED 27 + +typedef ::boost::unordered_map< OUString, OUString, OUStringHash, ::std::equal_to< OUString > > EventBindingHash; +typedef ::std::vector< ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > > FrameVector; +typedef ::std::vector< OUString > SupportedEventsVector; + +class GlobalEventConfig_Impl : public utl::ConfigItem +{ + EventBindingHash m_eventBindingHash; + FrameVector m_lFrames; + SupportedEventsVector m_supportedEvents; + + void initBindingInfo(); + +public: + GlobalEventConfig_Impl( ); + ~GlobalEventConfig_Impl( ); + + void Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames); + void Commit(); + + void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException); + ::sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + OUString GetEventName( sal_Int32 nID ); +}; + +class UNOTOOLS_DLLPUBLIC GlobalEventConfig: + public ::cppu::WeakImplHelper2 < ::com::sun::star::document::XEventsSupplier, ::com::sun::star::container::XNameReplace > +{ + public: + GlobalEventConfig( ); + ~GlobalEventConfig( ); + static ::osl::Mutex& GetOwnStaticMutex(); + + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException); + ::sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException); + ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException); + static OUString GetEventName( sal_Int32 nID ); + + private: + static GlobalEventConfig_Impl* m_pImpl; + static sal_Int32 m_nRefCount; +}; + +#endif // _EVENTCFG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/eventlisteneradapter.hxx b/include/unotools/eventlisteneradapter.hxx new file mode 100644 index 000000000000..89fe74782e34 --- /dev/null +++ b/include/unotools/eventlisteneradapter.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 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ +#define _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ +#include <com/sun/star/lang/XComponent.hpp> + +//......................................................................... +namespace utl +{ +//......................................................................... + + struct OEventListenerAdapterImpl; + //===================================================================== + //= OEventListenerAdapter + //===================================================================== + /** base class for non-UNO dispose listeners + */ + class UNOTOOLS_DLLPUBLIC OEventListenerAdapter + { + friend class OEventListenerImpl; + + private: + UNOTOOLS_DLLPRIVATE OEventListenerAdapter( const OEventListenerAdapter& _rSource ); // never implemented + UNOTOOLS_DLLPRIVATE const OEventListenerAdapter& operator=( const OEventListenerAdapter& _rSource ); // never implemented + + protected: + OEventListenerAdapterImpl* m_pImpl; + + protected: + OEventListenerAdapter(); + virtual ~OEventListenerAdapter(); + + void startComponentListening( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp ); + void stopComponentListening( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp ); + void stopAllComponentListening( ); + + virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ) = 0; + }; + +//......................................................................... +} // namespace utl +//......................................................................... + +#endif // _UNOTOOLS_EVENTLISTENERADAPTER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/extendedsecurityoptions.hxx b/include/unotools/extendedsecurityoptions.hxx new file mode 100644 index 000000000000..245f87e0d50f --- /dev/null +++ b/include/unotools/extendedsecurityoptions.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_unotools_EXTENDEDSECURITYOPTIONS_HXX +#define INCLUDED_unotools_EXTENDEDSECURITYOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtExtendedSecurityOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about security features + @descr - + + @implements - + @base - + + @ATTENTION This class is partially threadsafe. + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtExtendedSecurityOptions : public utl::detail::Options +{ + public: + // Must be zero based! + enum OpenHyperlinkMode + { + OPEN_NEVER = 0, + OPEN_WITHSECURITYCHECK, + OPEN_ALWAYS + }; + + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtExtendedSecurityOptions(); + virtual ~SvtExtendedSecurityOptions(); + + OpenHyperlinkMode GetOpenHyperlinkMode(); + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetInitMutex(); + + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtExtendedSecurityOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtExtendedSecurityOptions + +#endif // #ifndef INCLUDED_unotools_EXTENDEDSECURITYOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/fltrcfg.hxx b/include/unotools/fltrcfg.hxx new file mode 100644 index 000000000000..0356aeeb5d12 --- /dev/null +++ b/include/unotools/fltrcfg.hxx @@ -0,0 +1,91 @@ +/* -*- 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 _SVT_FLTRCFG_HXX +#define _SVT_FLTRCFG_HXX + +// ----------------------------------------------------------------------- + +#include "unotools/unotoolsdllapi.h" +#include <unotools/configitem.hxx> + +struct SvtFilterOptions_Impl; +class UNOTOOLS_DLLPUBLIC SvtFilterOptions : public utl::ConfigItem +{ + SvtFilterOptions_Impl* pImp; + + const com::sun::star::uno::Sequence<OUString>& GetPropertyNames(); +public: + SvtFilterOptions(); + virtual ~SvtFilterOptions(); + + virtual void Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames); + virtual void Commit(); + void Load(); + + void SetLoadWordBasicCode( sal_Bool bFlag ); + sal_Bool IsLoadWordBasicCode() const; + void SetLoadWordBasicExecutable( sal_Bool bFlag ); + sal_Bool IsLoadWordBasicExecutable() const; + void SetLoadWordBasicStorage( sal_Bool bFlag ); + sal_Bool IsLoadWordBasicStorage() const; + + void SetLoadExcelBasicCode( sal_Bool bFlag ); + sal_Bool IsLoadExcelBasicCode() const; + void SetLoadExcelBasicExecutable( sal_Bool bFlag ); + sal_Bool IsLoadExcelBasicExecutable() const; + void SetLoadExcelBasicStorage( sal_Bool bFlag ); + sal_Bool IsLoadExcelBasicStorage() const; + + void SetLoadPPointBasicCode( sal_Bool bFlag ); + sal_Bool IsLoadPPointBasicCode() const; + void SetLoadPPointBasicStorage( sal_Bool bFlag ); + sal_Bool IsLoadPPointBasicStorage() const; + + sal_Bool IsMathType2Math() const; + void SetMathType2Math( sal_Bool bFlag ); + sal_Bool IsMath2MathType() const; + void SetMath2MathType( sal_Bool bFlag ); + + sal_Bool IsWinWord2Writer() const; + void SetWinWord2Writer( sal_Bool bFlag ); + sal_Bool IsWriter2WinWord() const; + void SetWriter2WinWord( sal_Bool bFlag ); + + sal_Bool IsUseEnhancedFields() const; + + sal_Bool IsExcel2Calc() const; + void SetExcel2Calc( sal_Bool bFlag ); + sal_Bool IsCalc2Excel() const; + void SetCalc2Excel( sal_Bool bFlag ); + + sal_Bool IsPowerPoint2Impress() const; + void SetPowerPoint2Impress( sal_Bool bFlag ); + sal_Bool IsImpress2PowerPoint() const; + void SetImpress2PowerPoint( sal_Bool bFlag ); + + sal_Bool IsEnablePPTPreview() const; + sal_Bool IsEnableCalcPreview() const; + sal_Bool IsEnableWordPreview() const; + + static SvtFilterOptions& Get(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/fontcfg.hxx b/include/unotools/fontcfg.hxx new file mode 100644 index 000000000000..23ea55140655 --- /dev/null +++ b/include/unotools/fontcfg.hxx @@ -0,0 +1,221 @@ +/* -*- 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 _UNOTOOLS_FONTCFG_HXX +#define _UNOTOOLS_FONTCFG_HXX + +#include <unotools/unotoolsdllapi.h> +#include <tools/string.hxx> +#include <tools/fontenum.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNameAccess.hpp> + +#include <boost/unordered_map.hpp> +#include <boost/unordered_set.hpp> +#include <vector> + +namespace com { +namespace sun { +namespace star { +namespace lang { + +// equality operator needed for hash_map; +// (-> why does this need to be in the namespace of Locale ? g++ fails to compile else) +inline bool operator==( const com::sun::star::lang::Locale& rLeft, const com::sun::star::lang::Locale& rRight ) +{ + return + rLeft.Language.equals( rRight.Language ) && + rLeft.Country.equals( rRight.Country ) && + rLeft.Variant.equals( rRight.Variant ) + ; +} +}}}} + +namespace utl +{ + +struct LocaleHash +{ + size_t operator()( const com::sun::star::lang::Locale& rLocale ) const + { + return + (size_t)rLocale.Language.hashCode() ^ + (size_t)rLocale.Country.hashCode() ^ + (size_t)rLocale.Variant.hashCode(); + } +}; + +class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration +{ + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + m_xConfigProvider; + com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > + m_xConfigAccess; + + struct LocaleAccess + { + // the real string used in the configuration + // used to get rid of upper/lower case problems + OUString aConfigLocaleString; + // xAccess is mutable to be able to be filled on demand + mutable com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xAccess; + }; + + boost::unordered_map< com::sun::star::lang::Locale, + LocaleAccess, + utl::LocaleHash > + m_aConfig; + + OUString tryLocale( const com::sun::star::lang::Locale& rLocale, const OUString& rType ) const; + + public: + DefaultFontConfiguration(); + ~DefaultFontConfiguration(); + + static DefaultFontConfiguration& get(); + + OUString getDefaultFont( const com::sun::star::lang::Locale& rLocale, int nType ) const; + OUString getUserInterfaceFont( const com::sun::star::lang::Locale& rLocale ) const; +}; + +// IMPL_FONT_ATTR_DEFAULT - Default-Font like Andale Sans UI, Palace Script, Albany, Thorndale, Cumberland, ... +// IMPL_FONT_ATTR_STANDARD - Standard-Font like Arial, Times, Courier, ... +// IMPL_FONT_ATTR_NORMAL - normal Font for writing text like Arial, Verdana, Arial Narrow, Trebuchet, Times, Courier, ... +// IMPL_FONT_ATTR_SYMBOL - Font with symbols +// IMPL_FONT_ATTR_DECORATIVE - Readable and normally used for drawings +// IMPL_FONT_ATTR_SPECIAL - very special design +// IMPL_FONT_ATTR_TITLING - only uppercase characters +// IMPL_FONT_ATTR_FULL - Font with normally all characters +// IMPL_FONT_ATTR_CAPITALS - only uppercase characters, but lowercase characters smaller as the uppercase characters +// IMPL_FONT_ATTR_TYPEWRITER - like a typewriter: Courier, ... +// IMPL_FONT_ATTR_SCRIPT - Handwriting or Script +// IMPL_FONT_ATTR_HANDWRITING - More Handwriting with normal letters +// IMPL_FONT_ATTR_CHANCERY - Like Zapf Chancery +// IMPL_FONT_ATTR_COMIC - Like Comic Sans MS +// IMPL_FONT_ATTR_BRUSHSCRIPT - More Script +// IMPL_FONT_ATTR_OTHERSTYLE - OldStyle, ... so negativ points +#define IMPL_FONT_ATTR_DEFAULT ((sal_uLong)0x00000001) +#define IMPL_FONT_ATTR_STANDARD ((sal_uLong)0x00000002) +#define IMPL_FONT_ATTR_NORMAL ((sal_uLong)0x00000004) +#define IMPL_FONT_ATTR_SYMBOL ((sal_uLong)0x00000008) +#define IMPL_FONT_ATTR_FIXED ((sal_uLong)0x00000010) +#define IMPL_FONT_ATTR_SANSSERIF ((sal_uLong)0x00000020) +#define IMPL_FONT_ATTR_SERIF ((sal_uLong)0x00000040) +#define IMPL_FONT_ATTR_DECORATIVE ((sal_uLong)0x00000080) +#define IMPL_FONT_ATTR_SPECIAL ((sal_uLong)0x00000100) +#define IMPL_FONT_ATTR_ITALIC ((sal_uLong)0x00000200) +#define IMPL_FONT_ATTR_TITLING ((sal_uLong)0x00000400) +#define IMPL_FONT_ATTR_CAPITALS ((sal_uLong)0x00000800) +#define IMPL_FONT_ATTR_CJK ((sal_uLong)0x00001000) +#define IMPL_FONT_ATTR_CJK_JP ((sal_uLong)0x00002000) +#define IMPL_FONT_ATTR_CJK_SC ((sal_uLong)0x00004000) +#define IMPL_FONT_ATTR_CJK_TC ((sal_uLong)0x00008000) +#define IMPL_FONT_ATTR_CJK_KR ((sal_uLong)0x00010000) +#define IMPL_FONT_ATTR_CTL ((sal_uLong)0x00020000) +#define IMPL_FONT_ATTR_NONELATIN ((sal_uLong)0x00040000) +#define IMPL_FONT_ATTR_FULL ((sal_uLong)0x00080000) +#define IMPL_FONT_ATTR_OUTLINE ((sal_uLong)0x00100000) +#define IMPL_FONT_ATTR_SHADOW ((sal_uLong)0x00200000) +#define IMPL_FONT_ATTR_ROUNDED ((sal_uLong)0x00400000) +#define IMPL_FONT_ATTR_TYPEWRITER ((sal_uLong)0x00800000) +#define IMPL_FONT_ATTR_SCRIPT ((sal_uLong)0x01000000) +#define IMPL_FONT_ATTR_HANDWRITING ((sal_uLong)0x02000000) +#define IMPL_FONT_ATTR_CHANCERY ((sal_uLong)0x04000000) +#define IMPL_FONT_ATTR_COMIC ((sal_uLong)0x08000000) +#define IMPL_FONT_ATTR_BRUSHSCRIPT ((sal_uLong)0x10000000) +#define IMPL_FONT_ATTR_GOTHIC ((sal_uLong)0x20000000) +#define IMPL_FONT_ATTR_SCHOOLBOOK ((sal_uLong)0x40000000) +#define IMPL_FONT_ATTR_OTHERSTYLE ((sal_uLong)0x80000000) + +#define IMPL_FONT_ATTR_CJK_ALLLANG (IMPL_FONT_ATTR_CJK_JP | IMPL_FONT_ATTR_CJK_SC | IMPL_FONT_ATTR_CJK_TC | IMPL_FONT_ATTR_CJK_KR) +#define IMPL_FONT_ATTR_ALLSCRIPT (IMPL_FONT_ATTR_SCRIPT | IMPL_FONT_ATTR_HANDWRITING | IMPL_FONT_ATTR_CHANCERY | IMPL_FONT_ATTR_COMIC | IMPL_FONT_ATTR_BRUSHSCRIPT) +#define IMPL_FONT_ATTR_ALLSUBSCRIPT (IMPL_FONT_ATTR_HANDWRITING | IMPL_FONT_ATTR_CHANCERY | IMPL_FONT_ATTR_COMIC | IMPL_FONT_ATTR_BRUSHSCRIPT) +#define IMPL_FONT_ATTR_ALLSERIFSTYLE (IMPL_FONT_ATTR_ALLSCRIPT |\ + IMPL_FONT_ATTR_SANSSERIF | IMPL_FONT_ATTR_SERIF |\ + IMPL_FONT_ATTR_FIXED | IMPL_FONT_ATTR_ITALIC |\ + IMPL_FONT_ATTR_GOTHIC | IMPL_FONT_ATTR_SCHOOLBOOK |\ + IMPL_FONT_ATTR_SHADOW | IMPL_FONT_ATTR_OUTLINE) + +struct UNOTOOLS_DLLPUBLIC FontNameAttr +{ + String Name; + ::std::vector< String > Substitutions; + ::std::vector< String > MSSubstitutions; + ::std::vector< String > PSSubstitutions; + ::std::vector< String > HTMLSubstitutions; + FontWeight Weight; + FontWidth Width; + unsigned long Type; // bitfield of IMPL_FONT_ATTR_* +}; + +class UNOTOOLS_DLLPUBLIC FontSubstConfiguration +{ +private: + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + m_xConfigProvider; + com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > + m_xConfigAccess; + struct LocaleSubst + { + OUString aConfigLocaleString; + mutable bool bConfigRead; + // note: aSubstAttributes must be sorted alphabetically by Name + // searches on the substitutes are done with Name as key, where + // a minimal match is sufficient (that is e.g. "Thorndale" will match + // "Thorndale BlaBlub"). Also names must be lower case. + mutable std::vector< FontNameAttr > aSubstAttributes; + + LocaleSubst() : bConfigRead( false ) {} + }; + boost::unordered_map< com::sun::star::lang::Locale, LocaleSubst, utl::LocaleHash > m_aSubst; + typedef boost::unordered_set< OUString, OUStringHash > UniqueSubstHash; + mutable UniqueSubstHash maSubstHash; + + + void fillSubstVector( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont, + const OUString& rType, + std::vector< String >& rSubstVector ) const; + FontWeight getSubstWeight( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont, + const OUString& rType ) const; + FontWidth getSubstWidth( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont, + const OUString& rType ) const; + unsigned long getSubstType( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont, + const OUString& rType ) const; + void readLocaleSubst( const com::sun::star::lang::Locale& rLocale ) const; +public: + FontSubstConfiguration(); + ~FontSubstConfiguration(); + + static FontSubstConfiguration& get(); + + const FontNameAttr* getSubstInfo( + const String& rFontName, + const com::sun::star::lang::Locale& rLocale = + com::sun::star::lang::Locale( OUString( "en" ), + OUString(), + OUString() ) + ) const; + static void getMapName( const String& rOrgName, String& rShortName, String& rFamilyName, FontWeight& rWeight, FontWidth& rWidth, sal_uLong& rType ); +}; + +} // namespace utl + +#endif // _UNOTOOLS_FONTCFG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/fontcvt.hxx b/include/unotools/fontcvt.hxx new file mode 100644 index 000000000000..05564f974a79 --- /dev/null +++ b/include/unotools/fontcvt.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 _UNOTOOLS_FONTCVT_HXX +#define _UNOTOOLS_FONTCVT_HXX + +#include <unotools/unotoolsdllapi.h> +#include <tools/string.hxx> + +// ------------------ +// - FontToSubsFont - +// ------------------ + +#define FONTTOSUBSFONT_IMPORT ((sal_uLong)0x00000001) +#define FONTTOSUBSFONT_EXPORT ((sal_uLong)0x00000002) +#define FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ((sal_uLong)0x00000004) + +typedef void* FontToSubsFontConverter; +UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter( const String& rFontName, sal_uLong nFlags ); +UNOTOOLS_DLLPUBLIC void DestroyFontToSubsFontConverter( FontToSubsFontConverter hConverter ); +UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar( FontToSubsFontConverter hConverter, sal_Unicode c ); +UNOTOOLS_DLLPUBLIC String GetFontToSubsFontName( FontToSubsFontConverter hConverter ); + +// --------------------------- +// - StarSymbolToMSMultiFont - +// --------------------------- + +class UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont +{ +public: + //Returns the name of the best windows symbol font which this char can be + //mapped to. Sets rChar to the correct position for that font. If no + //match found, then no name is returned, and rChar is unchanged. If you + //want to convert a string, you don't want to use this. + virtual String ConvertChar(sal_Unicode &rChar) = 0; + + //Starts converting the string at position rIndex. It converts as much of + //the string that can be converted to the same symbol font and returns the + //name of that font. rIndex is modified to the last index that was + //converted. Typically you call if continously until rIndex == + //rString.Len() and handle each section as seperate 8bit strings using + //seperate fonts. Will return an empty string for a continous section + //that has no possible mapping. + virtual String ConvertString(String &rString, xub_StrLen &rIndex) = 0; + virtual ~StarSymbolToMSMultiFont() {} +}; + +//with bPerfect set the converter will only try and convert symbols which have +//perfect mappings to the windows symbols fonts. With it not set, it will +//allow somewhat more dubious transformations that are nevertheless +//recognizably similar. Even in this mode there will be characters that fail. +//The users of this might want to make a distinction between failed characters +//which were inside and those outside the unicode private area. +UNOTOOLS_DLLPUBLIC StarSymbolToMSMultiFont *CreateStarSymbolToMSMultiFont(bool bPerfectOnly=false); +#endif // _UNOTOOLS_FONTCVT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx new file mode 100644 index 000000000000..60c37d498045 --- /dev/null +++ b/include/unotools/fontdefs.hxx @@ -0,0 +1,95 @@ +/* -*- 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 _UNOTOOLS_FONTDEFS_HXX +#define _UNOTOOLS_FONTDEFS_HXX + +#include <unotools/unotoolsdllapi.h> +#include <sal/types.h> +#include <tools/string.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> + +namespace utl { + class FontSubstConfiguration; + struct FontNameAttr; +} + +// ---------------- +// - SubsFontName - +// ---------------- + +#define SUBSFONT_ONLYONE ((sal_uLong)0x00000001) +#define SUBSFONT_MS ((sal_uLong)0x00000002) +#define SUBSFONT_PS ((sal_uLong)0x00000004) +#define SUBSFONT_HTML ((sal_uLong)0x00000008) + +UNOTOOLS_DLLPUBLIC OUString GetSubsFontName( const OUString& rName, sal_uLong nFlags ); + +UNOTOOLS_DLLPUBLIC void AddTokenFontName( OUString& rName, const OUString& rNewToken ); + +struct UNOTOOLS_DLLPUBLIC FontNameHash { int operator()(const String&) const; }; + +// --------------- +// - ConvertChar - +// --------------- + +class UNOTOOLS_DLLPUBLIC ConvertChar +{ +public: + const sal_Unicode* mpCvtTab; + const char* mpSubsFontName; + sal_Unicode (*mpCvtFunc)( sal_Unicode ); + sal_Unicode RecodeChar( sal_Unicode c ) const; + void RecodeString( OUString& rStra, sal_Int32 nIndex, sal_Int32 nLen ) const; + static const ConvertChar* GetRecodeData( const String& rOrgFontName, const String& rMapFontName ); +}; + + +// Default-Font +#define DEFAULTFONT_SANS_UNICODE ((sal_uInt16)1) +#define DEFAULTFONT_SANS ((sal_uInt16)2) +#define DEFAULTFONT_SERIF ((sal_uInt16)3) +#define DEFAULTFONT_FIXED ((sal_uInt16)4) +#define DEFAULTFONT_SYMBOL ((sal_uInt16)5) +#define DEFAULTFONT_UI_SANS ((sal_uInt16)1000) +#define DEFAULTFONT_UI_FIXED ((sal_uInt16)1001) +#define DEFAULTFONT_LATIN_TEXT ((sal_uInt16)2000) +#define DEFAULTFONT_LATIN_PRESENTATION ((sal_uInt16)2001) +#define DEFAULTFONT_LATIN_SPREADSHEET ((sal_uInt16)2002) +#define DEFAULTFONT_LATIN_HEADING ((sal_uInt16)2003) +#define DEFAULTFONT_LATIN_DISPLAY ((sal_uInt16)2004) +#define DEFAULTFONT_LATIN_FIXED ((sal_uInt16)2005) +#define DEFAULTFONT_CJK_TEXT ((sal_uInt16)3000) +#define DEFAULTFONT_CJK_PRESENTATION ((sal_uInt16)3001) +#define DEFAULTFONT_CJK_SPREADSHEET ((sal_uInt16)3002) +#define DEFAULTFONT_CJK_HEADING ((sal_uInt16)3003) +#define DEFAULTFONT_CJK_DISPLAY ((sal_uInt16)3004) +#define DEFAULTFONT_CTL_TEXT ((sal_uInt16)4000) +#define DEFAULTFONT_CTL_PRESENTATION ((sal_uInt16)4001) +#define DEFAULTFONT_CTL_SPREADSHEET ((sal_uInt16)4002) +#define DEFAULTFONT_CTL_HEADING ((sal_uInt16)4003) +#define DEFAULTFONT_CTL_DISPLAY ((sal_uInt16)4004) + +UNOTOOLS_DLLPUBLIC OUString GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex ); + +UNOTOOLS_DLLPUBLIC void GetEnglishSearchFontName( OUString& rName ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/fontoptions.hxx b/include/unotools/fontoptions.hxx new file mode 100644 index 000000000000..d37423138e00 --- /dev/null +++ b/include/unotools/fontoptions.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_unotools_FONTOPTIONS_HXX +#define INCLUDED_unotools_FONTOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtFontOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about font features + @descr - + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtFontOptions : public utl::detail::Options +{ + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtFontOptions(); + virtual ~SvtFontOptions(); + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/Font" + @descr These values defines different states of font handling. + + ..ReplacementTable..() => Determines if the list of font replacements is applied or not. + + ..FontHistory..() => The last 5 fonts will be shown and the last one will be the + first name on the list. These will be displayed in the Font name + combo box on the Object bar. + + ..FontWYSIWYG..() => With this option the names of the selectable fonts + (for example, the fonts in the Font field in the object bar) + will be formatted as the current font. + + @seealso - + + @param - + @return - + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Bool IsFontHistoryEnabled ( ) const ; + void EnableFontHistory ( sal_Bool bState ) ; + + sal_Bool IsFontWYSIWYGEnabled ( ) const ; + void EnableFontWYSIWYG ( sal_Bool bState ) ; + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class use his own static mutex to be threadsafe. + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& impl_GetOwnStaticMutex(); + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtFontOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtFontOptions + +#endif // #ifndef INCLUDED_unotools_FONTOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/historyoptions.hxx b/include/unotools/historyoptions.hxx new file mode 100644 index 000000000000..3e1431544049 --- /dev/null +++ b/include/unotools/historyoptions.hxx @@ -0,0 +1,204 @@ +/* -*- 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_SVTOOLS_HISTORYOPTIONS_HXX +#define INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @descr The method GetList() returns a list of property values. + Use follow defines to seperate values by names. +*//*-*************************************************************************************************************/ + +#define HISTORY_PROPERTYNAME_URL OUString("URL") +#define HISTORY_PROPERTYNAME_FILTER OUString("Filter") +#define HISTORY_PROPERTYNAME_TITLE OUString("Title") +#define HISTORY_PROPERTYNAME_PASSWORD OUString("Password") + +/*-************************************************************************************************************//** + @descr You can use these enum values to specify right history if you call ouer interface methods. +*//*-*************************************************************************************************************/ + +enum EHistoryType +{ + ePICKLIST = 0, + eHISTORY = 1, + eHELPBOOKMARKS = 2 +}; + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtHistoryOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about history features + @descr - + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtHistoryOptions : public utl::detail::Options +{ + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtHistoryOptions(); + virtual ~SvtHistoryOptions(); + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/History/..." + @descr key "PickList" : The last used documents displayed in the file menu. + key "History" : The last opened documents general. + *//*-*****************************************************************************************************/ + + /*-****************************************************************************************************//** + @short set/get max size of specified history + @descr Call this methods to get information about max. size of specified list. + These value lay down the max count of items in these history. If a new one + is add to it the oldest one is deleted automaticly! + + @seealso - + + @param "eHistory" select right history. + @param "nSize" is the new max size of specified list. If new size smaller then the old one + some oldest entries will be destroyed automaticly! + @return Current max size of specified list. + + @onerror - + *//*-*****************************************************************************************************/ + + sal_uInt32 GetSize( EHistoryType eHistory ) const ; + + /*-****************************************************************************************************//** + @short clear complete sepcified list + @descr Call this methods to clear the whole list. After that GetItemCount() will return 0 ... + but GetSize() will return the old value! + + @seealso - + + @param "eHistory" select right history. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void Clear( EHistoryType eHistory ); + + /*-****************************************************************************************************//** + @short return complete sepcified list + @descr If you will show the whole list call this method to get it completely. + + @seealso - + + @param "eHistory" select right history. + @return A list of history items is returned. + + @onerror - + *//*-*****************************************************************************************************/ + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > GetList( EHistoryType eHistory ) const ; + + /*-****************************************************************************************************//** + @short append a new item to specified list + @descr You can append items to a list only - removing isn't allowed for a special item! + The oldest entry is deleted automaticly if max size arrived or you can call Clear() ... + It exist two different overload methods to do this. + One for user which have an complete history item and another one for uncompletly data sets! + + @seealso method SetSize() + @seealso method Clear() + + @param "eHistory" select right history. + @param "sURL" URL to save in history + @param "sFilter" filter name to save in history + @param "sTitle" document title to save in history + @param "sPassword" password to save in history + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + void AppendItem( EHistoryType eHistory , + const OUString& sURL , + const OUString& sFilter , + const OUString& sTitle , + const OUString& sPassword ); + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr Make these class threadsafe. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtHistoryOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtHistoryOptions + +#endif // #ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/idhelper.hxx b/include/unotools/idhelper.hxx new file mode 100644 index 000000000000..b96c27e8ac0d --- /dev/null +++ b/include/unotools/idhelper.hxx @@ -0,0 +1,199 @@ +/* -*- 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 _UNOTOOLS_ID_HELPER_HXX_ +#define _UNOTOOLS_ID_HELPER_HXX_ + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <osl/mutex.hxx> +#include <comphelper/stl_types.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <tools/debug.hxx> + +//......................................................................... +namespace utl +{ +//......................................................................... + +//========================================================================= +// to shorten some lines ... +typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > TypeSequence; + +// compare to Sequences of Types +struct TypeSequenceLess : public ::std::binary_function<TypeSequence, TypeSequence, bool> +{ +public: + inline bool operator() (const TypeSequence& lhs, const TypeSequence& rhs) const + { + sal_Int32 nLengthLeft = lhs.getLength(); + sal_Int32 nLengthRight = rhs.getLength(); + + // first check the two lengths + if (nLengthLeft < nLengthRight) + return sal_True; + if (nLengthLeft > nLengthRight) + return sal_False; + + // both sequences have the same length -> check the type names + const ::com::sun::star::uno::Type* pTypesLeft = lhs.getConstArray(); + const ::com::sun::star::uno::Type* pTypesRight = rhs.getConstArray(); + for (sal_Int32 i=0; i<nLengthLeft; ++i, ++pTypesLeft, ++pTypesRight) + { + sal_Int32 nTypeNameCompare = pTypesLeft->getTypeName().compareTo(pTypesRight->getTypeName()); + if (nTypeNameCompare < 0) + return sal_True; + if (nTypeNameCompare > 0) + return sal_False; + } + + // both sequences are equal ... + return sal_False; + } +}; + +// declare the map +DECLARE_STL_MAP ( TypeSequence, + ::cppu::OImplementationId, + TypeSequenceLess, + MapType2Id + ); + +//......................................................................... +} // namespace utl +//......................................................................... + +//========================================================================= +/** defines a helper class for implementing the XTypeProvider::getImplementationId. + it maps sequences of ::com::sun::star::uno::Type to implementation ids + (which means sequences of bytes).<BR> + As there is no possibility to determine the time where the id's are no longer + needed (e.g. because the last instance of the class using this mechanism died) + the helper is "refcounted", i.e. there are acquire and release methods. + To simplify this there is a class classname##Ref which you may want to + use as an member of your classes. + <BR><BR> + As we don't want a global helper class which handles implementation id's + of components from all over the office (supposing somebody want's to use this :) + this is only a define. Wherever you have a "closed" area (which is small enough + and large enough :), see below) where diffenrent components want to use an id helper, + define your own one with this macro.<BR> + The more classes use this helper, the later redundant map entries will be + cleared. The less classes use it, the earlier map entries which may have + been reused will be cleared. +*/ +#define DECLARE_IMPLEMENTATIONID_HELPER(_namespace, classname) \ +namespace _namespace { \ +class classname \ +{ \ + friend class classname##Ref; \ + \ + static sal_Int32 s_nReferenced; \ + static void* s_pMap; \ + \ + static ::osl::Mutex s_aMutex; \ + \ +public: \ + static void acquire(); \ + static void release(); \ + \ + static ::com::sun::star::uno::Sequence< sal_Int8 > getImplementationId( \ + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _rTypes); \ + \ +private: \ + static void implCreateMap(); \ + \ + classname() { } \ +}; \ + \ +/*=======================================================================*/ \ +class classname##Ref \ +{ \ +public: \ + classname##Ref() { classname::acquire(); } \ + ~classname##Ref() { classname::release(); } \ +}; \ + \ +} /* _namespace */ \ + \ + +/** implement an id helper +*/ +#define IMPLEMENT_IMPLEMENTATIONID_HELPER(_namespace, classname) \ +namespace _namespace { \ + \ +/*=======================================================================*/ \ + \ +sal_Int32 classname::s_nReferenced(0); \ +void* classname::s_pMap = NULL; \ +::osl::Mutex classname::s_aMutex; \ + \ +/*-----------------------------------------------------------------------*/ \ +void classname::acquire() \ +{ \ + ::osl::MutexGuard aGuard(s_aMutex); \ + ++s_nReferenced; \ +} \ + \ +/*-----------------------------------------------------------------------*/ \ +void classname::release() \ +{ \ + ::osl::MutexGuard aGuard(s_aMutex); \ + if (!--s_nReferenced) \ + { \ + delete static_cast< ::utl::MapType2Id *>( s_pMap ); \ + s_pMap = NULL; \ + } \ +} \ + \ +/*-----------------------------------------------------------------------*/ \ +::com::sun::star::uno::Sequence< sal_Int8 > classname::getImplementationId( \ + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _rTypes) \ +{ \ + ::osl::MutexGuard aGuard(s_aMutex); \ + DBG_ASSERT(s_nReferenced, \ + "classname::getImplementationId : you need to hold a reference to this class in order to use it !"); \ + /* give the calling class a member of type classname##Ref and all is fine .... */ \ + \ + implCreateMap(); \ + \ + ::utl::MapType2Id* pMap = static_cast< ::utl::MapType2Id *>(s_pMap); \ + \ + ::cppu::OImplementationId& rId = (*pMap)[_rTypes]; \ + /* this will create an entry for the given type sequence, if necessary */ \ + \ + return rId.getImplementationId(); \ +} \ + \ +/*-----------------------------------------------------------------------*/ \ +void classname::implCreateMap() \ +{ \ + if (s_pMap) \ + return; \ + s_pMap = new ::utl::MapType2Id(); \ +} \ + \ + \ +} /* _namespace */ \ + \ + + +#endif // _UNOTOOLS_ID_HELPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/intlwrapper.hxx b/include/unotools/intlwrapper.hxx new file mode 100644 index 000000000000..9165be22b414 --- /dev/null +++ b/include/unotools/intlwrapper.hxx @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_INTLWRAPPER_HXX +#define _UNOTOOLS_INTLWRAPPER_HXX +#include <unotools/charclass.hxx> +#include <unotools/localedatawrapper.hxx> +#include <unotools/calendarwrapper.hxx> +#include <unotools/collatorwrapper.hxx> +#include <i18nlangtag/lang.h> +#include <i18nlangtag/languagetag.hxx> + + +/** + A wrapper of I18N wrappers. Using this is more expensive than using some + single wrapper classes so use it only if you must pass a single pointer + without knowing in advance what is needed, e.g. for + SfxPoolItem::GetPresentation(). Remember that this wrapper was only created + for convenience to bypass some oddities, if possible don't use it. <p> + + Implemented are only the const get...() methods of the wrappers, which are + loaded on demand, for consistency reasons no change of locale is possible. + Only default calendar and default collator are supported. <p> + + One exception though is the calendar wrapper: to be able to set a value and + retrieve calendar values it is not const, so methods using this should + reset the calendar to the previous value if it isn't sure where the + IntlWrapper did come from. <p> + */ +class UNOTOOLS_DLLPUBLIC IntlWrapper +{ +private: + + LanguageTag maLanguageTag; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + + LocaleDataWrapper* pLocaleData; + CollatorWrapper* pCollator; + CollatorWrapper* pCaseCollator; + + void ImplNewLocaleData() const; + void ImplNewCollator( sal_Bool bCaseSensitive ) const; + + +public: + IntlWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, + const LanguageTag& rLanguageTag + ); + IntlWrapper( + const LanguageTag& rLanguageTag + ); + ~IntlWrapper(); + + const LanguageTag& getLanguageTag() const { return maLanguageTag; } + + const LocaleDataWrapper* getLocaleData() const + { + if ( !pLocaleData ) + ImplNewLocaleData(); + return pLocaleData; + } + /// case insensitive collator, simple IGNORE_CASE + const CollatorWrapper* getCollator() const + { + if ( !pCollator ) + ImplNewCollator( sal_False ); + return pCollator; + } + /// case sensitive collator + const CollatorWrapper* getCaseCollator() const + { + if ( !pCaseCollator ) + ImplNewCollator( sal_True ); + return pCaseCollator; + } +}; + +#endif // _UNOTOOLS_INTLWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/itemholderbase.hxx b/include/unotools/itemholderbase.hxx new file mode 100644 index 000000000000..831cba4a4a72 --- /dev/null +++ b/include/unotools/itemholderbase.hxx @@ -0,0 +1,104 @@ +/* -*- 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_unotools_ITEMHOLDERBASE_HXX_ +#define INCLUDED_unotools_ITEMHOLDERBASE_HXX_ + +#include <vector> +#include <osl/mutex.hxx> + +namespace utl { namespace detail { class Options; } } + + +struct ItemHolderMutexBase +{ + ::osl::Mutex m_aLock; +}; + +enum EItem +{ + E_ACCESSIBILITYOPTIONS , // 2 + E_ADDXMLTOSTORAGEOPTIONS , // + E_APEARCFG , // 2 + + E_CJKOPTIONS , // 2 + E_CMDOPTIONS , // + E_COLORCFG , // 2 + E_COMPATIBILITY , // + E_CTLOPTIONS , // 2 + + E_DEFAULTOPTIONS , // + E_DYNAMICMENUOPTIONS , // + + E_EVENTCFG , // + E_EXTENDEDSECURITYOPTIONS , // + + E_FLTRCFG , // + E_FONTOPTIONS , // + E_FONTSUBSTCONFIG , // 2 + + E_HELPOPTIONS , // 2 + E_HISTORYOPTIONS , // + + E_LANGUAGEOPTIONS , // 2 + E_LINGUCFG , // + E_LOCALISATIONOPTIONS , // + + E_MENUOPTIONS , // + E_MISCCFG , // 2 + E_MISCOPTIONS , // + E_MODULEOPTIONS , // + + E_OPTIONSDLGOPTIONS , // + + E_PATHOPTIONS , // + E_PRINTOPTIONS , // 2 + E_PRINTFILEOPTIONS , // 2 + E_PRINTWARNINGOPTIONS , // + + E_REGOPTIONS , // + + E_SAVEOPTIONS , // + E_SEARCHOPT , // + E_SECURITYOPTIONS , // + E_SYSLOCALEOPTIONS , // 2 + + E_USEROPTIONS , // 2 + + E_VIEWOPTIONS_DIALOG , // + E_VIEWOPTIONS_TABDIALOG , // + E_VIEWOPTIONS_TABPAGE , // + E_VIEWOPTIONS_WINDOW // +}; + +struct TItemInfo +{ + TItemInfo() + : pItem(0) + {} + + utl::detail::Options * pItem; + EItem eItem; +}; + +typedef ::std::vector< TItemInfo > TItems; + +#endif // INCLUDED_unotools_ITEMHOLDERBASE_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/lingucfg.hxx b/include/unotools/lingucfg.hxx new file mode 100644 index 000000000000..1dc24c605702 --- /dev/null +++ b/include/unotools/lingucfg.hxx @@ -0,0 +1,228 @@ +/* -*- 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 _unotools_LINGUCFG_HXX_ +#define _unotools_LINGUCFG_HXX_ + +#include "unotools/unotoolsdllapi.h" +#include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> +#include <tools/solar.h> +#include <rtl/ustring.hxx> +#include <unotools/configitem.hxx> +#include <osl/mutex.hxx> +#include <unotools/options.hxx> +#include <i18nlangtag/lang.h> + +#include <vector> + +class SvtLinguConfigItem; + +////////////////////////////////////////////////////////////////////// + +struct UNOTOOLS_DLLPUBLIC SvtLinguOptions +{ + ::com::sun::star::uno::Sequence< OUString > aActiveDics; + ::com::sun::star::uno::Sequence< OUString > aActiveConvDics; + + sal_Bool bROActiveDics; + sal_Bool bROActiveConvDics; + + // Hyphenator service specific options + sal_Int16 nHyphMinLeading, + nHyphMinTrailing, + nHyphMinWordLength; + + sal_Bool bROHyphMinLeading, + bROHyphMinTrailing, + bROHyphMinWordLength; + + // misc options (non-service specific) + sal_Int16 nDefaultLanguage; + sal_Int16 nDefaultLanguage_CJK; + sal_Int16 nDefaultLanguage_CTL; + + sal_Bool bRODefaultLanguage; + sal_Bool bRODefaultLanguage_CJK; + sal_Bool bRODefaultLanguage_CTL; + + // spelling options (non-service specific) + sal_Bool bIsSpellSpecial; + sal_Bool bIsSpellAuto; + sal_Bool bIsSpellReverse; + + sal_Bool bROIsSpellSpecial; + sal_Bool bROIsSpellAuto; + sal_Bool bROIsSpellReverse; + + // hyphenation options (non-service specific) + sal_Bool bIsHyphSpecial; + sal_Bool bIsHyphAuto; + + sal_Bool bROIsHyphSpecial; + sal_Bool bROIsHyphAuto; + + // common to SpellChecker, Hyphenator and Thesaurus service + sal_Bool bIsUseDictionaryList; + sal_Bool bIsIgnoreControlCharacters; + + sal_Bool bROIsUseDictionaryList; + sal_Bool bROIsIgnoreControlCharacters; + + // SpellChecker service specific options + sal_Bool bIsSpellWithDigits, + bIsSpellUpperCase, + bIsSpellCapitalization; + + sal_Bool bROIsSpellWithDigits, + bROIsSpellUpperCase, + bROIsSpellCapitalization; + + // text conversion specific options + sal_Bool bIsIgnorePostPositionalWord; + sal_Bool bIsAutoCloseDialog; + sal_Bool bIsShowEntriesRecentlyUsedFirst; + sal_Bool bIsAutoReplaceUniqueEntries; + sal_Bool bIsDirectionToSimplified; + sal_Bool bIsUseCharacterVariants; + sal_Bool bIsTranslateCommonTerms; + sal_Bool bIsReverseMapping; + + sal_Bool bROIsIgnorePostPositionalWord; + sal_Bool bROIsAutoCloseDialog; + sal_Bool bROIsShowEntriesRecentlyUsedFirst; + sal_Bool bROIsAutoReplaceUniqueEntries; + sal_Bool bROIsDirectionToSimplified; + sal_Bool bROIsUseCharacterVariants; + sal_Bool bROIsTranslateCommonTerms; + sal_Bool bROIsReverseMapping; + + // check value need to determine if the configuration needs to updatet + // or not (used for a quick check if data files have been changed/added + // or deleted + sal_Int32 nDataFilesChangedCheckValue; + sal_Bool bRODataFilesChangedCheckValue; + + sal_Bool bIsGrammarAuto; + sal_Bool bIsGrammarInteractive; + + sal_Bool bROIsGrammarAuto; + sal_Bool bROIsGrammarInteractive; + + SvtLinguOptions(); +}; + +////////////////////////////////////////////////////////////////////// + +struct UNOTOOLS_DLLPUBLIC SvtLinguConfigDictionaryEntry +{ + // the URL's pointing to the location of the files the dictionary consists of + com::sun::star::uno::Sequence< OUString > aLocations; + // the name of the dictionary format implement + OUString aFormatName; + // the list of languages (ISO names) the dictionary can be used for + com::sun::star::uno::Sequence< OUString > aLocaleNames; +}; + +////////////////////////////////////////////////////////////////////// + +class UNOTOOLS_DLLPUBLIC SvtLinguConfig: public utl::detail::Options +{ + // returns static object + UNOTOOLS_DLLPRIVATE SvtLinguConfigItem & GetConfigItem(); + + SvtLinguConfigItem & GetConfigItem() const { return const_cast< SvtLinguConfig * >( this )->GetConfigItem(); } + + // configuration update access for the 'Linguistic' main node + mutable com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > m_xMainUpdateAccess; + + com::sun::star::uno::Reference< com::sun::star::util::XChangesBatch > GetMainUpdateAccess() const; + + com::sun::star::uno::Sequence< OUString > GetCurrentOrLastActiveDicts_Impl( const OUString &rPropName ) const; + void SetCurrentOrLastActiveDicts_Impl( const OUString &rPropName, const com::sun::star::uno::Sequence< OUString > &rDictionaries ) const; + + OUString GetVendorImageUrl_Impl( const OUString &rServiceImplName, const OUString &rImageName ) const; + + // disallow copy-constructor and assignment-operator for now + SvtLinguConfig( const SvtLinguConfig & ); + SvtLinguConfig & operator = ( const SvtLinguConfig & ); + +public: + SvtLinguConfig(); + virtual ~SvtLinguConfig(); + + // + // borrowed from utl::ConfigItem + // + com::sun::star::uno::Sequence< OUString > + GetNodeNames( const OUString &rNode ); + // + com::sun::star::uno::Sequence< com::sun::star::uno::Any > + GetProperties( + const com::sun::star::uno::Sequence< OUString > &rNames ); + // + sal_Bool + ReplaceSetProperties( + const OUString &rNode, + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues ); + + com::sun::star::uno::Any + GetProperty( const OUString &rPropertyName ) const; + com::sun::star::uno::Any + GetProperty( sal_Int32 nPropertyHandle ) const; + + sal_Bool SetProperty( const OUString &rPropertyName, + const com::sun::star::uno::Any &rValue ); + sal_Bool SetProperty( sal_Int32 nPropertyHandle, + const com::sun::star::uno::Any &rValue ); + + sal_Bool GetOptions( SvtLinguOptions &rOptions ) const; + + sal_Bool IsReadOnly( const OUString &rPropertyName ) const; + + //! + //! the following functions work on the 'ServiceManager' sub node of the + //! linguistic configuration only + //! + sal_Bool GetElementNamesFor( const OUString &rNodeName, com::sun::star::uno::Sequence< OUString > &rElementNames ) const; + // + sal_Bool GetSupportedDictionaryFormatsFor( const OUString &rSetName, const OUString &rSetEntry, com::sun::star::uno::Sequence< OUString > &rFormatList ) const; + + sal_Bool GetDictionaryEntry( const OUString &rNodeName, SvtLinguConfigDictionaryEntry &rDicEntry ) const; + + com::sun::star::uno::Sequence< OUString > GetDisabledDictionaries() const; + + std::vector< SvtLinguConfigDictionaryEntry > GetActiveDictionariesByFormat( const OUString &rFormatName ); + + // functions returning file URLs to the respective images (if found) and empty string otherwise + OUString GetSpellAndGrammarContextSuggestionImage( const OUString &rServiceImplName ) const; + OUString GetSpellAndGrammarContextDictionaryImage( const OUString &rServiceImplName ) const; + OUString GetSynonymsContextImage( const OUString &rServiceImplName ) const; + + bool HasGrammarChecker() const; +}; + +////////////////////////////////////////////////////////////////////// + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/linguprops.hxx b/include/unotools/linguprops.hxx new file mode 100644 index 000000000000..85cf64b3d31c --- /dev/null +++ b/include/unotools/linguprops.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 _unotools_LINGUPROPS_HXX_ +#define _unotools_LINGUPROPS_HXX_ + + +// UNO property names for general options +#define UPN_IS_GERMAN_PRE_REFORM "IsGermanPreReform" /*! deprecated #i91949 !*/ +#define UPN_IS_USE_DICTIONARY_LIST "IsUseDictionaryList" +#define UPN_IS_IGNORE_CONTROL_CHARACTERS "IsIgnoreControlCharacters" +#define UPN_ACTIVE_DICTIONARIES "ActiveDictionaries" + +// UNO property names for SpellChecker +#define UPN_IS_SPELL_UPPER_CASE "IsSpellUpperCase" +#define UPN_IS_SPELL_WITH_DIGITS "IsSpellWithDigits" +#define UPN_IS_SPELL_CAPITALIZATION "IsSpellCapitalization" + +// UNO property names for Hyphenator +#define UPN_HYPH_MIN_LEADING "HyphMinLeading" +#define UPN_HYPH_MIN_TRAILING "HyphMinTrailing" +#define UPN_HYPH_MIN_WORD_LENGTH "HyphMinWordLength" + +// UNO property names for Lingu +// (those not covered by the SpellChecker and Hyphenator +// properties and more likely to be used in other modules only) +#define UPN_DEFAULT_LANGUAGE "DefaultLanguage" +#define UPN_DEFAULT_LOCALE "DefaultLocale" +#define UPN_DEFAULT_LOCALE_CJK "DefaultLocale_CJK" +#define UPN_DEFAULT_LOCALE_CTL "DefaultLocale_CTL" +#define UPN_IS_HYPH_AUTO "IsHyphAuto" +#define UPN_IS_HYPH_SPECIAL "IsHyphSpecial" +#define UPN_IS_SPELL_AUTO "IsSpellAuto" +#define UPN_IS_SPELL_HIDE "IsSpellHide" /*! deprecated #i91949 !*/ +#define UPN_IS_SPELL_IN_ALL_LANGUAGES "IsSpellInAllLanguages" /*! deprecated #i91949 !*/ +#define UPN_IS_SPELL_SPECIAL "IsSpellSpecial" +#define UPN_IS_WRAP_REVERSE "IsWrapReverse" +#define UPN_DATA_FILES_CHANGED_CHECK_VALUE "DataFilesChangedCheckValue" + +// UNO property names for text conversion options +#define UPN_ACTIVE_CONVERSION_DICTIONARIES "ActiveConversionDictionaries" +#define UPN_IS_IGNORE_POST_POSITIONAL_WORD "IsIgnorePostPositionalWord" +#define UPN_IS_AUTO_CLOSE_DIALOG "IsAutoCloseDialog" +#define UPN_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST "IsShowEntriesRecentlyUsedFirst" +#define UPN_IS_AUTO_REPLACE_UNIQUE_ENTRIES "IsAutoReplaceUniqueEntries" +#define UPN_IS_DIRECTION_TO_SIMPLIFIED "IsDirectionToSimplified" +#define UPN_IS_USE_CHARACTER_VARIANTS "IsUseCharacterVariants" +#define UPN_IS_TRANSLATE_COMMON_TERMS "IsTranslateCommonTerms" +#define UPN_IS_REVERSE_MAPPING "IsReverseMapping" + +// new UNO propertynames to be used with 'dictionaries as extensions' +#define UPN_DICTIONARIES "Dictionaries" +#define UPN_SPELL_CHECKERS "SpellCheckers" +#define UPN_HYPHENATORS "Hyphenators" +#define UPN_THESAURI "Thesauri" +#define UPN_CURRENT_ACTIVE_DICTIONARIES "CurrentActiveDictionaries" +#define UPN_LAST_ACTIVE_DICTIONARIES "LastActiveDictionaries" + +#define UPN_IS_GRAMMAR_AUTO "IsAutoGrammarCheck" +#define UPN_IS_GRAMMAR_INTERACTIVE "IsInteractiveGrammarCheck" + +// uno property handles +#define UPH_IS_GERMAN_PRE_REFORM 0 +#define UPH_IS_USE_DICTIONARY_LIST 1 +#define UPH_IS_IGNORE_CONTROL_CHARACTERS 2 +#define UPH_IS_SPELL_UPPER_CASE 3 +#define UPH_IS_SPELL_WITH_DIGITS 4 +#define UPH_IS_SPELL_CAPITALIZATION 5 +#define UPH_HYPH_MIN_LEADING 6 +#define UPH_HYPH_MIN_TRAILING 7 +#define UPH_HYPH_MIN_WORD_LENGTH 8 +#define UPH_DEFAULT_LOCALE 9 +#define UPH_IS_SPELL_AUTO 10 +#define UPH_IS_SPELL_HIDE 11 +#define UPH_IS_SPELL_IN_ALL_LANGUAGES 12 +#define UPH_IS_SPELL_SPECIAL 13 +#define UPH_IS_HYPH_AUTO 14 +#define UPH_IS_HYPH_SPECIAL 15 +#define UPH_IS_WRAP_REVERSE 16 +#define UPH_DATA_FILES_CHANGED_CHECK_VALUE 17 +#define UPH_DEFAULT_LANGUAGE 21 +#define UPH_DEFAULT_LOCALE_CJK 22 +#define UPH_DEFAULT_LOCALE_CTL 23 +#define UPH_ACTIVE_DICTIONARIES 24 +#define UPH_ACTIVE_CONVERSION_DICTIONARIES 25 +#define UPH_IS_IGNORE_POST_POSITIONAL_WORD 26 +#define UPH_IS_AUTO_CLOSE_DIALOG 27 +#define UPH_IS_SHOW_ENTRIES_RECENTLY_USED_FIRST 28 +#define UPH_IS_AUTO_REPLACE_UNIQUE_ENTRIES 29 +#define UPH_IS_DIRECTION_TO_SIMPLIFIED 30 +#define UPH_IS_USE_CHARACTER_VARIANTS 31 +#define UPH_IS_TRANSLATE_COMMON_TERMS 32 +#define UPH_IS_REVERSE_MAPPING 33 +#define UPH_IS_GRAMMAR_AUTO 34 +#define UPH_IS_GRAMMAR_INTERACTIVE 35 +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/localedatawrapper.hxx b/include/unotools/localedatawrapper.hxx new file mode 100644 index 000000000000..a198163831f7 --- /dev/null +++ b/include/unotools/localedatawrapper.hxx @@ -0,0 +1,362 @@ +/* -*- 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 _UNOTOOLS_LOCALEDATAWRAPPER_HXX +#define _UNOTOOLS_LOCALEDATAWRAPPER_HXX + +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> +#include <com/sun/star/i18n/XLocaleData4.hpp> +#include <com/sun/star/i18n/LocaleItem.hpp> +#include <com/sun/star/i18n/reservedWords.hpp> +#include <rtl/ustring.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <unotools/readwritemutexguard.hxx> +#include "unotools/unotoolsdllapi.h" + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} +class Date; +class Time; +class CalendarWrapper; + + +enum DateFormat { + MDY, + DMY, + YMD +}; + + +enum MeasurementSystem { + MEASURE_METRIC, + MEASURE_US +}; + + +class UNOTOOLS_DLLPUBLIC LocaleDataWrapper : private boost::noncopyable +{ + static sal_uInt8 nLocaleDataChecking; // 0:=dontknow, 1:=yes, 2:=no + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData4 > xLD; + LanguageTag maLanguageTag; + ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > xDefaultCalendar; + ::com::sun::star::i18n::LocaleDataItem aLocaleDataItem; + ::com::sun::star::uno::Sequence< OUString > aReservedWordSeq; + ::com::sun::star::uno::Sequence< OUString > aDateAcceptancePatterns; + ::com::sun::star::uno::Sequence< sal_Int32 > aGrouping; + // cached items + OUString aLocaleItem[::com::sun::star::i18n::LocaleItem::COUNT]; + OUString aReservedWord[::com::sun::star::i18n::reservedWords::COUNT]; + OUString aCurrSymbol; + OUString aCurrBankSymbol; + int nDateFormat; + int nLongDateFormat; + sal_uInt16 nCurrPositiveFormat; + sal_uInt16 nCurrNegativeFormat; + sal_uInt16 nCurrDigits; + sal_Bool bLocaleDataItemValid; + sal_Bool bReservedWordValid; + mutable ::utl::ReadWriteMutex aMutex; + + // dummies, to be implemented or provided by XML locale data + sal_Unicode cCurrZeroChar; + + // whenever Locale changes + void invalidateData(); + + void getOneLocaleItemImpl( sal_Int16 nItem ); + const OUString& getOneLocaleItem( sal_Int16 nItem ) const; + + void getOneReservedWordImpl( sal_Int16 nWord ); + const OUString& getOneReservedWord( sal_Int16 nWord ) const; + + void getCurrSymbolsImpl(); + void getCurrFormatsImpl(); + + void scanCurrFormatImpl( const OUString& rCode, + sal_Int32 nStart, sal_Int32& nSign, + sal_Int32& nPar, sal_Int32& nNum, + sal_Int32& nBlank, sal_Int32& nSym ); + + void getDateFormatsImpl(); + DateFormat scanDateFormatImpl( const OUString& rCode ); + + void getDefaultCalendarImpl(); + + sal_Unicode* ImplAddFormatNum( sal_Unicode* pBuf, + sal_Int64 nNumber, sal_uInt16 nDecimals, + sal_Bool bUseThousandSep, sal_Bool bTrailingZeros ) const; + + void getDigitGroupingImpl(); + +public: + LocaleDataWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, + const LanguageTag& rLanguageTag + ); + LocaleDataWrapper( + const LanguageTag& rLanguageTag + ); + ~LocaleDataWrapper(); + + /** Get the service factory, meant to be able to create a CalendarWrapper + from a LocaleDataWrapper. Note that the service factory may be + non-existent if this LocaleDataWrapper was created without one and + lives "on the grassland". The CalendarWrapper ctor can handle that + though. */ + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & getComponentContext() + const { return m_xContext; } + + /// set a new Locale to request + void setLanguageTag( const LanguageTag& rLanguageTag ); + + /// get current requested Locale + const LanguageTag& getLanguageTag() const; + + /// get current loaded Locale, which might differ from the requested Locale + LanguageTag getLoadedLanguageTag() const; + + + // Wrapper implementations of service LocaleData + + ::com::sun::star::i18n::LanguageCountryInfo getLanguageCountryInfo() const; + ::com::sun::star::i18n::LocaleDataItem getLocaleItem() const; + /// NOTE: this wraps XLocaleData3::getAllCalendars2() in fact. + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 > getAllCalendars() const; + /// NOTE: this wraps XLocaleData2::getAllCurrencies2() in fact. + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > getAllCurrencies() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > getAllFormats() const; + ::com::sun::star::i18n::ForbiddenCharacters getForbiddenCharacters() const; + ::com::sun::star::uno::Sequence< OUString > getReservedWord() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > getAllInstalledLocaleNames() const; + ::com::sun::star::uno::Sequence< OUString > getDateAcceptancePatterns() const; + + /** Override locale's date acceptance patterns. + An empty sequence resets the patterns to the locale's pattern sequence. + */ + void setDateAcceptancePatterns( const ::com::sun::star::uno::Sequence< OUString > & rPatterns ); + + /// same as the wrapper implementation but static + static ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > getInstalledLocaleNames(); + + /** Get LanguageTypes for all installed locales which are unambiguous + convertible back and forth between locale ISO strings and MS-LCID + LanguageType. Upon the first time the function is called when + locale data checking is enabled, messages are shown for locales not + matching, excluding already known problems. + (e.g. used in number formatter dialog init) + */ + static ::com::sun::star::uno::Sequence< sal_uInt16 > getInstalledLanguageTypes(); + + /// maps the LocaleData string to the International enum + MeasurementSystem mapMeasurementStringToEnum( const OUString& rMS ) const; + + /// Convenience method to obtain the default calendar. + const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > getDefaultCalendar() const; + + /// Convenience method to obtain the day names of the default calendar. + const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDefaultCalendarDays() const; + + /// Convenience method to obtain the month names of the default calendar. + const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem2 > getDefaultCalendarMonths() const; + + /** Obtain digit grouping. The usually known grouping by thousands (#,###) + is actually only one of possible groupings. Another one, for example, + used in India is group by 3 and then by 2 indefinitely (#,##,###). The + integer sequence returned here specifies grouping from right to left + (!), with a 0 entry designating the end of rules and the previous value + to be repeated indefinitely. Hence the sequence {3,0} specifies the + usual grouping by thousands, whereas the sequence {3,2,0} specifies + Indian grouping. The sal_Int32* getConstArray() can be passed directly + to the ::rtl::math::doubleToString() methods as argument for the + pGroups parameter. */ + const ::com::sun::star::uno::Sequence< sal_Int32 > getDigitGrouping() const; + + // Functionality of class International methods, LocaleItem + + const OUString& getDateSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::DATE_SEPARATOR ); } + const OUString& getNumThousandSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::THOUSAND_SEPARATOR ); } + const OUString& getNumDecimalSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::DECIMAL_SEPARATOR ); } + const OUString& getTimeSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::TIME_SEPARATOR ); } + const OUString& getTime100SecSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::TIME_100SEC_SEPARATOR ); } + const OUString& getListSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::LIST_SEPARATOR ); } + const OUString& getQuotationMarkStart() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::SINGLE_QUOTATION_START ); } + const OUString& getQuotationMarkEnd() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::SINGLE_QUOTATION_END ); } + const OUString& getDoubleQuotationMarkStart() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::DOUBLE_QUOTATION_START ); } + const OUString& getDoubleQuotationMarkEnd() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::DOUBLE_QUOTATION_END ); } + const OUString& getMeasurementSystem() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::MEASUREMENT_SYSTEM ); } + MeasurementSystem getMeasurementSystemEnum() const + { return mapMeasurementStringToEnum( getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::MEASUREMENT_SYSTEM ) ); } + const OUString& getTimeAM() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::TIME_AM ); } + const OUString& getTimePM() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::TIME_PM ); } + const OUString& getLongDateDayOfWeekSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::LONG_DATE_DAY_OF_WEEK_SEPARATOR ); } + const OUString& getLongDateDaySep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::LONG_DATE_DAY_SEPARATOR ); } + const OUString& getLongDateMonthSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::LONG_DATE_MONTH_SEPARATOR ); } + const OUString& getLongDateYearSep() const + { return getOneLocaleItem( ::com::sun::star::i18n::LocaleItem::LONG_DATE_YEAR_SEPARATOR ); } + + // currency + const OUString& getCurrSymbol() const; + const OUString& getCurrBankSymbol() const; + sal_uInt16 getCurrPositiveFormat() const; + sal_uInt16 getCurrNegativeFormat() const; + sal_uInt16 getCurrDigits() const; + + // simple date and time formatting + DateFormat getDateFormat() const; + DateFormat getLongDateFormat() const; + /// only numerical values of Gregorian calendar + OUString getDate( const Date& rDate ) const; + OUString getTime( const Time& rTime, sal_Bool bSec = sal_True, + sal_Bool b100Sec = sal_False ) const; + OUString getDuration( const Time& rTime, + sal_Bool bSec = sal_True, sal_Bool b100Sec = sal_False ) const; + + /** The CalendarWrapper already <b>MUST</b> + have loaded a calendar. + @param nDisplayDayOfWeek + 0 := abbreviated name + 1 := full name + @param bDayOfMonthWithLeadingZero + <FALSE/> := without leading zero + <TRUE/> := with leading zero if <10 + @param nDisplayMonth + 0 := abbreviated name + 1 := full name + @param bTwoDigitYear + <FALSE/> := full year + <TRUE/> := year % 100 + */ + OUString getLongDate( const Date& rDate, + CalendarWrapper& rCal, + sal_Int16 nDisplayDayOfWeek = 1, + sal_Bool bDayOfMonthWithLeadingZero = sal_False, + sal_Int16 nDisplayMonth = 1, + sal_Bool bTwoDigitYear = sal_False + ) const; + + /** Simple number formatting + @param nNumber + value * 10**nDecimals + @param bTrailingZeros + </sal_True> := always display trailing zeros in + decimal places, even if integer value. + </sal_False> := trailing zeros are only displayed + if the value is not an integer value. + */ + OUString getNum( sal_Int64 nNumber, sal_uInt16 nDecimals, + sal_Bool bUseThousandSep = sal_True, + sal_Bool bTrailingZeros = sal_True ) const; + + /// "Secure" currency formatted string. + OUString getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, + const OUString& rCurrencySymbol, + sal_Bool bUseThousandSep = sal_True ) const; + /** Default currency formatted string, use with + care as default currency may change in any + locale, for example, DEM -> EUR */ + OUString getCurr( sal_Int64 nNumber, sal_uInt16 nDecimals, + sal_Bool bUseThousandSep = sal_True ) const + { return getCurr( nNumber, nDecimals, + getCurrSymbol(), bUseThousandSep ); } + + // dummy returns, to be implemented + inline sal_Unicode getCurrZeroChar() const + { return cCurrZeroChar; } + inline sal_Bool isNumLeadingZero() const + { return sal_True; } + /// standard decimal places + inline sal_uInt16 getNumDigits() const + { return 2; } + inline sal_Bool isNumTrailingZeros() const + { return sal_True; } + + + // reserved words + + const OUString& getTrueWord() const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::TRUE_WORD ); } + const OUString& getFalseWord() const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::FALSE_WORD ); } + /// return a quarter string matching nQuarter (0..3) => "1st quarter" .. "4th quarter" + const OUString& getQuarterWord( sal_Int16 nQuarter ) const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::QUARTER1_WORD + nQuarter ); } + const OUString& getAboveWord() const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::ABOVE_WORD ); } + const OUString& getBelowWord() const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::BELOW_WORD ); } + /// return a quarter abbreviation string matching nQuarter (0..3) => "Q1" .. "Q2" + const OUString& getQuarterAbbreviation( sal_Int16 nQuarter ) const + { return getOneReservedWord( ::com::sun::star::i18n::reservedWords::QUARTER1_ABBREVIATION + nQuarter ); } + + /** Return whether locale data checks are enabled. + Checks are enabled if the environment variable + OOO_ENABLE_LOCALE_DATA_CHECKS is set to 'Y' or 'Yes' (or any other + string starting with 'Y') or '1'. + Also used in conjunction with the number formatter. */ + static inline bool areChecksEnabled() + { + if (nLocaleDataChecking == 0) + evaluateLocaleDataChecking(); + return nLocaleDataChecking == 1; + } + + /** Append locale info to string, used with locale data checking. + A string similar to "de_DE requested\n en_US loaded" is appended. */ + OUString appendLocaleInfo(const OUString& rDebugMsg) const; + + /** Ouput a message during locale data checking. The (UTF-8) string is + written to stderr and in a non-product build or if DBG_UTIL is enabled + also raised as an assertion message box. */ + static void outputCheckMessage( const OUString& rMsg ); + static void outputCheckMessage( const char* pStr); + +private: + + const ::com::sun::star::lang::Locale & getMyLocale() const; + + static void evaluateLocaleDataChecking(); +}; + + +#endif // _UNOTOOLS_LOCALEDATAWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/localfilehelper.hxx b/include/unotools/localfilehelper.hxx new file mode 100644 index 000000000000..4a1864b2f44f --- /dev/null +++ b/include/unotools/localfilehelper.hxx @@ -0,0 +1,60 @@ +/* -*- 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 _UNOTOOLS_LOCALFILEHELPER_HXX +#define _UNOTOOLS_LOCALFILEHELPER_HXX + +#include <com/sun/star/uno/Sequence.hxx> +#include "unotools/unotoolsdllapi.h" + +#include <rtl/ustring.hxx> +#include <tools/string.hxx> + +namespace utl +{ + class UNOTOOLS_DLLPUBLIC LocalFileHelper + { + public: + /** + Converts a "physical" file name into a "UCB compatible" URL ( if possible ). + If no UCP is available for the local file system, sal_False and an empty URL is returned. + Returning sal_True and an empty URL means that the URL doesn't point to a local file. + */ + static bool ConvertPhysicalNameToURL(const OUString& rName, OUString& rReturn); + static sal_Bool ConvertSystemPathToURL( const OUString& rName, const OUString& rBaseURL, OUString& rReturn ); + + /** + Converts a "UCB compatible" URL into a "physical" file name. + If no UCP is available for the local file system, sal_False and an empty file name is returned, + otherwise sal_True and a valid URL, because a file name can always be converted if a UCP for the local + file system is present ( watch: this doesn't mean that this file really exists! ) + */ + static bool ConvertURLToPhysicalName( const OUString& rName, OUString& rReturn ); + static sal_Bool ConvertURLToSystemPath( const OUString& rName, OUString& rReturn ); + + static sal_Bool IsLocalFile(const OUString& rName); + static sal_Bool IsFileContent(const OUString& rName); + + static ::com::sun::star::uno::Sequence< OUString > + GetFolderContents( const OUString& rFolder, sal_Bool bFolder ); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/localisationoptions.hxx b/include/unotools/localisationoptions.hxx new file mode 100644 index 000000000000..931d59f1980d --- /dev/null +++ b/include/unotools/localisationoptions.hxx @@ -0,0 +1,136 @@ +/* -*- 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_unotools_LOCALISATIONOPTIONS_HXX +#define INCLUDED_unotools_LOCALISATIONOPTIONS_HXX + +#include <sal/types.h> +#include "unotools/unotoolsdllapi.h" +#include <osl/mutex.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtLocalisationOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about localisation features + @descr - + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtLocalisationOptions : public utl::detail::Options +{ + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtLocalisationOptions(); + virtual ~SvtLocalisationOptions(); + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/View/Localisation/AutoMnemonic" + @descr These value specifies if shortcuts should be assigned automatically. + + @seealso - + + @param "bState", new value to set it in configuration. + @return The value which represent current state of internal variable. + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Bool IsAutoMnemonic ( ) const ; + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/View/Localisation/DialogScale" + @descr These value specifies the factor for increasing controls. + Value from [0..100] are allowed. + + @ATTENTION These methods don't check for valid or invalid values! + Our configuration server can do it ... but these implementation don't get any notifications + about wrong commits ...! + => If you set an invalid value - nothing will be changed. The information will lost. + + @seealso baseclass ConfigItem + + @param "nScale" new value to set it in configuration. + @return The value which represent current state of internal variable. + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Int32 GetDialogScale( ) const ; + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtLocalisationOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtLocalisationOptions + +#endif // #ifndef INCLUDED_unotools_LOCALISATIONOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/misccfg.hxx b/include/unotools/misccfg.hxx new file mode 100644 index 000000000000..7759b31ed24a --- /dev/null +++ b/include/unotools/misccfg.hxx @@ -0,0 +1,57 @@ +/* -*- 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 _UTL_MISCCFG_HXX +#define _UTL_MISCCFG_HXX + +#include "unotools/unotoolsdllapi.h" +#include "tools/solar.h" +#include "unotools/options.hxx" + +namespace utl +{ + class SfxMiscCfg; + +class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options +{ + SfxMiscCfg* pImpl; + +public: + MiscCfg( ); + virtual ~MiscCfg( ); + + sal_Bool IsNotFoundWarning() const; + void SetNotFoundWarning( sal_Bool bSet); + + sal_Bool IsPaperSizeWarning() const; + void SetPaperSizeWarning(sal_Bool bSet); + + sal_Bool IsPaperOrientationWarning() const; + void SetPaperOrientationWarning( sal_Bool bSet); + + // 0 ... 99 + sal_Int32 GetYear2000() const; + void SetYear2000( sal_Int32 nSet ); +}; + +} + +#endif // _MISCCFG_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/moduleoptions.hxx b/include/unotools/moduleoptions.hxx new file mode 100644 index 000000000000..75b83b1c0988 --- /dev/null +++ b/include/unotools/moduleoptions.hxx @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX +#define INCLUDED_SVTOOLS_MODULEOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <salhelper/singletonref.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <unotools/options.hxx> + +#define FEATUREFLAG_BASICIDE 0x00000020 +#define FEATUREFLAG_MATH 0x00000100 +#define FEATUREFLAG_CHART 0x00000200 +#define FEATUREFLAG_CALC 0x00000800 +#define FEATUREFLAG_DRAW 0x00001000 +#define FEATUREFLAG_WRITER 0x00002000 +#define FEATUREFLAG_IMPRESS 0x00008000 +#define FEATUREFLAG_INSIGHT 0x00010000 + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ +class SvtModuleOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about installation state of modules + @descr Use these class to get installation state of different office modules like writer, calc etc + Further you can ask for additional information; e.g. name of standard template file, which + should be used by corresponding module; or short/long name of these module factory. + + @implements - + @base - + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtModuleOptions : public utl::detail::Options +{ + public: + + enum EModule + { + E_SWRITER = 0, + E_SCALC = 1, + E_SDRAW = 2, + E_SIMPRESS = 3, + E_SMATH = 4, + E_SCHART = 5, + E_SSTARTMODULE = 6, + E_SBASIC = 7, + E_SDATABASE = 8, + E_SWEB = 9, + E_SGLOBAL = 10 + }; + + /*ATTENTION: + If you change these enum ... don't forget to change reading/writing and order of configuration values too! + See "SvtModuleOptions_Impl::impl_GetSetNames()" and his ctor for further information. + */ + enum EFactory + { + E_UNKNOWN_FACTORY = -1, + E_WRITER = 0, + E_WRITERWEB = 1, + E_WRITERGLOBAL = 2, + E_CALC = 3, + E_DRAW = 4, + E_IMPRESS = 5, + E_MATH = 6, + E_CHART = 7, + E_STARTMODULE = 8, + E_DATABASE = 9, + E_BASIC = 10 + + }; + + public: + + SvtModuleOptions(); + virtual ~SvtModuleOptions(); + + sal_Bool IsModuleInstalled ( EModule eModule ) const; + OUString GetModuleName ( EModule eModule ) const; + OUString GetFactoryName ( EFactory eFactory ) const; + OUString GetFactoryStandardTemplate( EFactory eFactory ) const; + OUString GetFactoryEmptyDocumentURL( EFactory eFactory ) const; + OUString GetFactoryDefaultFilter ( EFactory eFactory ) const; + sal_Bool IsDefaultFilterReadonly ( EFactory eFactory ) const; + sal_Int32 GetFactoryIcon ( EFactory eFactory ) const; + static sal_Bool ClassifyFactoryByName ( const OUString& sName , + EFactory& eFactory ); + void SetFactoryStandardTemplate( EFactory eFactory , + const OUString& sTemplate ); + void SetFactoryDefaultFilter ( EFactory eFactory , + const OUString& sFilter ); + + //_______________________________________ + + /** @short return the corresponding application ID for the given + document service name. + */ + static EFactory ClassifyFactoryByServiceName(const OUString& sName); + + //_______________________________________ + + /** @short return the corresponding application ID for the given + short name. + */ + static EFactory ClassifyFactoryByShortName(const OUString& sName); + + //_______________________________________ + + /** @short return the corresponding application ID for the given properties. + + @descr Because this search base on filters currently (till we have a better solution) + a result is not guaranteed everytimes. May a filter does not exists for the specified + content (but a FrameLoader which is not bound to any application!) ... or + the given properties describe a stream (and we make no deep detection inside here!). + + @attention The module BASIC cant be detected here. Because it does not + has an own URL schema. + + @param sURL + the complete URL! + + @param lMediaDescriptor + additional information + + @return A suitable enum value. See EFactory above. + */ + static EFactory ClassifyFactoryByURL(const OUString& sURL , + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lMediaDescriptor); + + //_______________________________________ + + /** @short return the corresponding application ID for the given properties. + + @descr Here we try to use the list of supported service names of the given model + to find out the right application module. + + @attention The module BASIC cant be detected here. Because it does not + support any model/ctrl/view paradigm. + + @param xModel + the document model + + @return A suitable enum value. See EFactory above. + */ + static EFactory ClassifyFactoryByModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel); + + OUString GetDefaultModuleName(); + + sal_Bool IsMath () const; + sal_Bool IsChart () const; + sal_Bool IsCalc () const; + sal_Bool IsDraw () const; + sal_Bool IsWriter () const; + sal_Bool IsImpress () const; + sal_Bool IsBasicIDE () const; + sal_Bool IsDataBase () const; + + ::com::sun::star::uno::Sequence < OUString > GetAllServiceNames(); + + private: + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& impl_GetOwnStaticMutex(); + + /*Attention + + Don't initialize these static member in these header! + a) Double defined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtModuleOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtModuleOptions + +#endif // #ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/nativenumberwrapper.hxx b/include/unotools/nativenumberwrapper.hxx new file mode 100644 index 000000000000..252a48d85a13 --- /dev/null +++ b/include/unotools/nativenumberwrapper.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 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_NATIVENUMBERWRAPPER_HXX +#define _UNOTOOLS_NATIVENUMBERWRAPPER_HXX +#include <com/sun/star/i18n/XNativeNumberSupplier.hpp> + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + + +class UNOTOOLS_DLLPUBLIC NativeNumberWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XNativeNumberSupplier > xNNS; + // not implemented, prevent usage + NativeNumberWrapper( const NativeNumberWrapper& ); + NativeNumberWrapper& operator=( const NativeNumberWrapper& ); + +public: + NativeNumberWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext + ); + + ~NativeNumberWrapper(); + + // Wrapper implementations of XNativeNumberSupplier + + OUString getNativeNumberString( + const OUString& rNumberString, + const ::com::sun::star::lang::Locale& rLocale, + sal_Int16 nNativeNumberMode ) const; + + ::com::sun::star::i18n::NativeNumberXmlAttributes convertToXmlAttributes( + const ::com::sun::star::lang::Locale& rLocale, + sal_Int16 nNativeNumberMode ) const; + + sal_Int16 convertFromXmlAttributes( + const ::com::sun::star::i18n::NativeNumberXmlAttributes& rAttr ) const; + +}; + +#endif // _UNOTOOLS_NATIVENUMBERWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/numberformatcodewrapper.hxx b/include/unotools/numberformatcodewrapper.hxx new file mode 100644 index 000000000000..82e254e7ea1d --- /dev/null +++ b/include/unotools/numberformatcodewrapper.hxx @@ -0,0 +1,68 @@ +/* -*- 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 _UNOTOOLS_NUMBERFORMATCODEWRAPPER_HXX +#define _UNOTOOLS_NUMBERFORMATCODEWRAPPER_HXX + +#include <com/sun/star/i18n/XNumberFormatCode.hpp> +#include "unotools/unotoolsdllapi.h" + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + + +class UNOTOOLS_DLLPUBLIC NumberFormatCodeWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XNumberFormatCode > xNFC; + ::com::sun::star::lang::Locale aLocale; + + // not implemented, prevent usage + NumberFormatCodeWrapper( const NumberFormatCodeWrapper& ); + NumberFormatCodeWrapper& operator=( const NumberFormatCodeWrapper& ); + +public: + NumberFormatCodeWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext, + const ::com::sun::star::lang::Locale& rLocale + ); + + ~NumberFormatCodeWrapper(); + + + /// set a new Locale + void setLocale( const ::com::sun::star::lang::Locale& rLocale ); + + /// get current Locale + const ::com::sun::star::lang::Locale& getLocale() const { return aLocale; } + + + // Wrapper implementations of class NumberFormatCodeMapper + + ::com::sun::star::i18n::NumberFormatCode getFormatCode( sal_Int16 nFormatIndex ) const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > getAllFormatCode( sal_Int16 nFormatUsage ) const; + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode > getAllFormatCodes() const; + +}; + +#endif // _UNOTOOLS_NUMBERFORMATCODEWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/options.hxx b/include/unotools/options.hxx new file mode 100644 index 000000000000..5a37b026fb63 --- /dev/null +++ b/include/unotools/options.hxx @@ -0,0 +1,95 @@ +/* -*- 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_unotools_OPTIONS_HXX +#define INCLUDED_unotools_OPTIONS_HXX + +#include "sal/config.h" +#include "unotools/unotoolsdllapi.h" +#include <vector> + +/* + The class utl::detail::Options provides a kind of multiplexer. It implements a ConfigurationListener + that is usually registered at a ConfigItem class. At the same time it implements a ConfigurationBroadcaster + that allows further ("external") listeners to register. + Once the class deriving from Options is notified about + configuration changes by the ConfigItem if its content has been changed by calling some of its methods, + a call of the Options::NotifyListeners() method will send out notifications to all external listeners. +*/ + +namespace utl { + + class ConfigurationBroadcaster; + + // interface for configuration listener + class UNOTOOLS_DLLPUBLIC ConfigurationListener + { + public: + virtual ~ConfigurationListener(); + + virtual void ConfigurationChanged( ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ) = 0; + }; + typedef ::std::vector< ConfigurationListener* > IMPL_ConfigurationListenerList; + + // complete broadcasting implementation + class UNOTOOLS_DLLPUBLIC ConfigurationBroadcaster + { + IMPL_ConfigurationListenerList* mpList; + sal_Int32 m_nBroadcastBlocked; // broadcast only if this is 0 + sal_uInt32 m_nBlockedHint; + + public: + void AddListener( utl::ConfigurationListener* pListener ); + void RemoveListener( utl::ConfigurationListener* pListener ); + + // notify listeners; nHint is an implementation detail of the particular class deriving from ConfigurationBroadcaster + void NotifyListeners( sal_uInt32 nHint ); + ConfigurationBroadcaster(); + virtual ~ConfigurationBroadcaster(); + virtual void BlockBroadcasts( bool bBlock ); + }; + +namespace detail { + +// A base class for the various option classes supported by +// unotools/source/config/itemholderbase.hxx (which must be public, as it is +// shared between unotools, svl and svt) +// It also provides an implementation for a Configuration Listener and inherits a broadcaster implementation + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED Options + : public utl::ConfigurationBroadcaster, public utl::ConfigurationListener +{ +public: + Options(); + + virtual ~Options() = 0; + +private: + UNOTOOLS_DLLPRIVATE Options(Options &); // not defined + UNOTOOLS_DLLPRIVATE void operator =(Options &); // not defined + +protected: + virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster* p, sal_uInt32 nHint=0 ); +}; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/optionsdlg.hxx b/include/unotools/optionsdlg.hxx new file mode 100644 index 000000000000..ba28032a49ea --- /dev/null +++ b/include/unotools/optionsdlg.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_unotools_OPTIONSDLG_HXX +#define INCLUDED_unotools_OPTIONSDLG_HXX + +#include "unotools/unotoolsdllapi.h" +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +class SvtOptionsDlgOptions_Impl; + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtOptionsDialogOptions : public utl::detail::Options +{ +private: + SvtOptionsDlgOptions_Impl* m_pImp; + +public: + SvtOptionsDialogOptions(); + virtual ~SvtOptionsDialogOptions(); + + sal_Bool IsGroupHidden ( const OUString& _rGroup ) const; + sal_Bool IsPageHidden ( const OUString& _rPage, + const OUString& _rGroup ) const; + sal_Bool IsOptionHidden ( const OUString& _rOption, + const OUString& _rPage, + const OUString& _rGroup ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/pathoptions.hxx b/include/unotools/pathoptions.hxx new file mode 100644 index 000000000000..ad1d16d19c79 --- /dev/null +++ b/include/unotools/pathoptions.hxx @@ -0,0 +1,130 @@ +/* -*- 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_unotools_PATHOPTIONS_HXX +#define INCLUDED_unotools_PATHOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <tools/string.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <unotools/options.hxx> + +#define SVT_SEARCHPATH_DELIMITER ';' + +// class SvtPathOptions -------------------------------------------------- + +class SvtPathOptions_Impl; +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtPathOptions : public utl::detail::Options +{ +private: + SvtPathOptions_Impl* pImp; + +public: + enum Paths + { + PATH_ADDIN, + PATH_AUTOCORRECT, + PATH_AUTOTEXT, + PATH_BACKUP, + PATH_BASIC, + PATH_BITMAP, + PATH_CONFIG, + PATH_DICTIONARY, + PATH_FAVORITES, + PATH_FILTER, + PATH_GALLERY, + PATH_GRAPHIC, + PATH_HELP, + PATH_LINGUISTIC, + PATH_MODULE, + PATH_PALETTE, + PATH_PLUGIN, + PATH_STORAGE, + PATH_TEMP, + PATH_TEMPLATE, + PATH_USERCONFIG, + PATH_WORK, + PATH_UICONFIG, + PATH_FINGERPRINT, + PATH_COUNT // should always be the last element + }; + + SvtPathOptions(); + virtual ~SvtPathOptions(); + + // get the paths, not const because of using a mutex + const String& GetAddinPath() const; + const String& GetAutoCorrectPath() const; + const String& GetAutoTextPath() const; + const String& GetBackupPath() const; + const String& GetBasicPath() const; + const String& GetBitmapPath() const; + const String& GetConfigPath() const; + const String& GetDictionaryPath() const; + const String& GetFavoritesPath() const; + const String& GetFilterPath() const; + const String& GetGalleryPath() const; + const String& GetGraphicPath() const; + const String& GetHelpPath() const; + const String& GetLinguisticPath() const; + const String& GetModulePath() const; + const String& GetPalettePath() const; + const String& GetPluginPath() const; + const String& GetStoragePath() const; + const String& GetTempPath() const; + const String& GetTemplatePath() const; + const String& GetUserConfigPath() const; + const String& GetWorkPath() const; + const String& GetUIConfigPath() const; + const String& GetFingerprintPath() const; + + // set the paths + void SetAddinPath( const String& rPath ); + void SetAutoCorrectPath( const String& rPath ); + void SetAutoTextPath( const String& rPath ); + void SetBackupPath( const String& rPath ); + void SetBasicPath( const String& rPath ); + void SetBitmapPath( const String& rPath ); + void SetConfigPath( const String& rPath ); + void SetDictionaryPath( const String& rPath ); + void SetFavoritesPath( const String& rPath ); + void SetFilterPath( const String& rPath ); + void SetGalleryPath( const String& rPath ); + void SetGraphicPath( const String& rPath ); + void SetHelpPath( const String& rPath ); + void SetLinguisticPath( const String& rPath ); + void SetModulePath( const String& rPath ); + void SetPalettePath( const String& rPath ); + void SetPluginPath( const String& rPath ); + void SetStoragePath( const String& rPath ); + void SetTempPath( const String& rPath ); + void SetTemplatePath( const String& rPath ); + void SetUserConfigPath( const String& rPath ); + void SetWorkPath( const String& rPath ); + + String SubstituteVariable( const String& rVar ) const; + String ExpandMacros( const String& rPath ) const; + String UseVariable( const String& rVar ) const; + sal_Bool SearchFile( String& rIniFile, Paths ePath = PATH_USERCONFIG ); + const LanguageTag& GetLanguageTag() const; + sal_Bool IsReadonly() const; +}; + +#endif // #ifndef INCLUDED_unotools_PATHOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/printwarningoptions.hxx b/include/unotools/printwarningoptions.hxx new file mode 100644 index 000000000000..61b79ee2eb45 --- /dev/null +++ b/include/unotools/printwarningoptions.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_unotools_PRINTWARNINGOPTIONS_HXX +#define INCLUDED_unotools_PRINTWARNINGOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtPrintWarningOptions_Impl; + +/*-************************************************************************************************************//** + @short collect information about startup features + @descr - + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtPrintWarningOptions : public utl::detail::Options +{ + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtPrintWarningOptions(); + virtual ~SvtPrintWarningOptions(); + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/Print/Warning..." + @descr These options describe internal states to enable/disable features of installed office. + + @seealso configuration package "org.openoffice.Office.Common/_3D-Engine" + *//*-*****************************************************************************************************/ + + sal_Bool IsPaperSize() const; + sal_Bool IsPaperOrientation() const; + sal_Bool IsTransparency() const; + sal_Bool IsModifyDocumentOnPrintingAllowed() const; + + void SetPaperSize( sal_Bool bState ); + void SetPaperOrientation( sal_Bool bState ); + void SetTransparency( sal_Bool bState ); + void SetModifyDocumentOnPrintingAllowed( sal_Bool bState ); + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class use his own static mutex to be threadsafe. + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtPrintWarningOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtPrintWarningOptions + +#endif // #ifndef INCLUDED_unotools_PRINTWARNINGOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/progresshandlerwrap.hxx b/include/unotools/progresshandlerwrap.hxx new file mode 100644 index 000000000000..fc640dc4c4a9 --- /dev/null +++ b/include/unotools/progresshandlerwrap.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UTL_PROGRESSHANDLERWRAP_HXX_ +#define _UTL_PROGRESSHANDLERWRAP_HXX_ +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/ucb/XProgressHandler.hpp> + +namespace utl +{ + +class UNOTOOLS_DLLPUBLIC ProgressHandlerWrap : public ::cppu::WeakImplHelper1< ::com::sun::star::ucb::XProgressHandler > +{ + ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > m_xStatusIndicator; + +public: + ProgressHandlerWrap( ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > xSI ); + + // XProgressHandler + virtual void SAL_CALL push( const ::com::sun::star::uno::Any& Status ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL update( const ::com::sun::star::uno::Any& Status ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL pop() + throw (::com::sun::star::uno::RuntimeException); +}; + +} // namespace utl + +#endif // _UTL_PROGRESSHANDLERWRAP_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/readwritemutexguard.hxx b/include/unotools/readwritemutexguard.hxx new file mode 100644 index 000000000000..dd182d1e9a67 --- /dev/null +++ b/include/unotools/readwritemutexguard.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_UNOTOOLS_READWRITEMUTEXGUARD_HXX +#define INCLUDED_UNOTOOLS_READWRITEMUTEXGUARD_HXX + +#include <osl/mutex.hxx> + +namespace utl { + +class ReadWriteGuard; +class ReadWriteMutex +{ + friend class ReadWriteGuard; + + sal_uInt32 nReadCount; + sal_uInt32 nBlockCriticalCount; + ::osl::Mutex* pMutex; + ::osl::Mutex* pWriteMutex; + +public: + ReadWriteMutex() + : nReadCount(0) + , nBlockCriticalCount(0) + , pMutex( new ::osl::Mutex ) + , pWriteMutex( new ::osl::Mutex ) + {} + ~ReadWriteMutex() + { + delete pMutex; + delete pWriteMutex; + } +}; + + +namespace ReadWriteGuardMode { +const sal_Int32 nWrite = 0x01; +const sal_Int32 nCriticalChange = 0x02 | nWrite; +const sal_Int32 nBlockCritical = 0x04; // only a block, not a read, exclusive flag! +} + +/** Enable multiple threads to read simultaneously, but a write blocks all + other reads and writes, and a read blocks any write. + Used in I18N wrappers to be able to maintain a single instance of a wrapper + for the standard Office locale. + NEVER construct a writing guard if there is already a reading guard in the + same context, the following will dead lock EVEN IN THE SAME THREAD! + void foo() + { + ReadWriteGuard aGuard1( aMutex ); + bar(); + } + void bar() + { + // waits forever for aGuard1 + ReadWriteGuard aGuard2( aMutex, ReadWriteGuardMode::nWrite ); + } + */ +class ReadWriteGuard +{ + ReadWriteMutex& rMutex; + sal_Int32 nMode; +public: + ReadWriteGuard( + ReadWriteMutex& rMutex, + sal_Int32 nRequestMode = 0 // read only + ); + ~ReadWriteGuard(); + + /** Be careful with this, it does wait for ANY read to complete. + The following will dead lock EVEN IN THE SAME THREAD! + void foo() + { + ReadWriteGuard aGuard1( aMutex ); + bar(); + } + void bar() + { + ReadWriteGuard aGuard2( aMutex ); + aGuard2.changeReadToWrite(); // waits forever for aGuard1 + } + */ + void changeReadToWrite(); +}; + +} // namespace utl + +#endif // INCLUDED_UNOTOOLS_READWRITEMUTEXGUARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/saveopt.hxx b/include/unotools/saveopt.hxx new file mode 100644 index 000000000000..771c7210d09c --- /dev/null +++ b/include/unotools/saveopt.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_unotools_SAVEOPT_HXX +#define INCLUDED_unotools_SAVEOPT_HXX + +#include "unotools/unotoolsdllapi.h" +#include <unotools/options.hxx> + +struct SvtLoadSaveOptions_Impl; +class UNOTOOLS_DLLPUBLIC SvtSaveOptions: public utl::detail::Options +{ + SvtLoadSaveOptions_Impl* pImp; + +public: + + enum EOption + { + E_AUTOSAVETIME, + E_USEUSERDATA, + E_BACKUP, + E_AUTOSAVE, + E_AUTOSAVEPROMPT, + E_DOCINFSAVE, + E_SAVEWORKINGSET, + E_SAVEDOCVIEW, + E_SAVERELINET, + E_SAVERELFSYS, + E_SAVEUNPACKED, + E_DOPRETTYPRINTING, + E_WARNALIENFORMAT, + E_LOADDOCPRINTER, + E_ODFDEFAULTVERSION, + E_USESHA1INODF12, + E_USEBLOWFISHINODF12, + E_USERAUTOSAVE, + }; + + // keep enum values sorted that a less or greater compare maps to older and newer versions! + enum ODFDefaultVersion + { + ODFVER_UNKNOWN = 0, // unknown + ODFVER_010 = 1, // ODF 1.0 + ODFVER_011 = 2, // ODF 1.1 + DO_NOT_USE = 3, // Do not use this, only here for compatibility with pre OOo 3.2 configuration + ODFVER_012 = 4, // ODF 1.2 + ODFVER_012_EXT_COMPAT = 8, // ODF 1.2 extended, but with compatibility fallbacks + + ODFVER_LATEST = SAL_MAX_ENUM, // ODF latest version with enhancements + }; + + SvtSaveOptions(); + virtual ~SvtSaveOptions(); + + void SetAutoSaveTime( sal_Int32 n ); + sal_Int32 GetAutoSaveTime() const; + + void SetUseUserData( sal_Bool b ); + sal_Bool IsUseUserData() const; + + void SetBackup( sal_Bool b ); + sal_Bool IsBackup() const; + + void SetAutoSave( sal_Bool b ); + sal_Bool IsAutoSave() const; + + void SetAutoSavePrompt( sal_Bool b ); + sal_Bool IsAutoSavePrompt() const; + + void SetUserAutoSave( sal_Bool b ); + sal_Bool IsUserAutoSave() const; + + void SetDocInfoSave(sal_Bool b); + sal_Bool IsDocInfoSave() const; + + void SetSaveWorkingSet( sal_Bool b ); + sal_Bool IsSaveWorkingSet() const; + + void SetSaveDocView( sal_Bool b ); + sal_Bool IsSaveDocView() const; + + void SetSaveRelINet( sal_Bool b ); + sal_Bool IsSaveRelINet() const; + + void SetSaveRelFSys( sal_Bool b ); + sal_Bool IsSaveRelFSys() const; + + sal_Bool IsSaveUnpacked() const; + + void SetLoadUserSettings(sal_Bool b); + sal_Bool IsLoadUserSettings() const; + + void SetPrettyPrinting( sal_Bool _bEnable ); + sal_Bool IsPrettyPrinting( ) const; + + void SetWarnAlienFormat( sal_Bool _bEnable ); + sal_Bool IsWarnAlienFormat( ) const; + + void SetLoadDocumentPrinter( sal_Bool _bEnable ); + sal_Bool IsLoadDocumentPrinter( ) const; + + void SetODFDefaultVersion( ODFDefaultVersion eVersion ); + ODFDefaultVersion GetODFDefaultVersion() const; + + sal_Bool IsUseSHA1InODF12() const; + + sal_Bool IsUseBlowfishInODF12() const; + + sal_Bool IsReadOnly( EOption eOption ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/searchopt.hxx b/include/unotools/searchopt.hxx new file mode 100644 index 000000000000..0ce76a846024 --- /dev/null +++ b/include/unotools/searchopt.hxx @@ -0,0 +1,111 @@ +/* -*- 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 _SVT_SEARCHOPT_HXX_ +#define _SVT_SEARCHOPT_HXX_ + +#include "unotools/unotoolsdllapi.h" +#include "tools/solar.h" + +class SvtSearchOptions_Impl; + +class UNOTOOLS_DLLPUBLIC SvtSearchOptions +{ + SvtSearchOptions_Impl *pImpl; + + // disallow copy-constructor and assignment-operator for now + SvtSearchOptions( const SvtSearchOptions & ); + SvtSearchOptions & operator = ( const SvtSearchOptions & ); + +protected: + +public: + SvtSearchOptions(); + ~SvtSearchOptions(); + + sal_Int32 GetTransliterationFlags() const; + + // + // General Options + // + + sal_Bool IsWholeWordsOnly() const; + sal_Bool IsBackwards() const; + sal_Bool IsUseRegularExpression() const; + sal_Bool IsSimilaritySearch() const; + sal_Bool IsUseAsianOptions() const; + sal_Bool IsMatchCase() const; // also Japanese search option + sal_Bool IsNotes() const; + + void SetWholeWordsOnly( sal_Bool bVal ); + void SetBackwards( sal_Bool bVal ); + void SetUseRegularExpression( sal_Bool bVal ); + void SetSearchForStyles( sal_Bool bVal ); + void SetSimilaritySearch( sal_Bool bVal ); + void SetUseAsianOptions( sal_Bool bVal ); + void SetMatchCase( sal_Bool bVal ); // also Japanese search option + void SetNotes( sal_Bool bVal); + + // + // Japanese search options + // + + sal_Bool IsMatchFullHalfWidthForms() const; + sal_Bool IsMatchHiraganaKatakana() const; + sal_Bool IsMatchContractions() const; + sal_Bool IsMatchMinusDashChoon() const; + sal_Bool IsMatchRepeatCharMarks() const; + sal_Bool IsMatchVariantFormKanji() const; + sal_Bool IsMatchOldKanaForms() const; + sal_Bool IsMatchDiziDuzu() const; + sal_Bool IsMatchBavaHafa() const; + sal_Bool IsMatchTsithichiDhizi() const; + sal_Bool IsMatchHyuiyuByuvyu() const; + sal_Bool IsMatchSesheZeje() const; + sal_Bool IsMatchIaiya() const; + sal_Bool IsMatchKiku() const; + sal_Bool IsIgnorePunctuation() const; + sal_Bool IsIgnoreWhitespace() const; + sal_Bool IsIgnoreProlongedSoundMark() const; + sal_Bool IsIgnoreMiddleDot() const; + + void SetMatchFullHalfWidthForms( sal_Bool bVal ); + void SetMatchHiraganaKatakana( sal_Bool bVal ); + void SetMatchContractions( sal_Bool bVal ); + void SetMatchMinusDashChoon( sal_Bool bVal ); + void SetMatchRepeatCharMarks( sal_Bool bVal ); + void SetMatchVariantFormKanji( sal_Bool bVal ); + void SetMatchOldKanaForms( sal_Bool bVal ); + void SetMatchDiziDuzu( sal_Bool bVal ); + void SetMatchBavaHafa( sal_Bool bVal ); + void SetMatchTsithichiDhizi( sal_Bool bVal ); + void SetMatchHyuiyuByuvyu( sal_Bool bVal ); + void SetMatchSesheZeje( sal_Bool bVal ); + void SetMatchIaiya( sal_Bool bVal ); + void SetMatchKiku( sal_Bool bVal ); + void SetIgnorePunctuation( sal_Bool bVal ); + void SetIgnoreWhitespace( sal_Bool bVal ); + void SetIgnoreProlongedSoundMark( sal_Bool bVal ); + void SetIgnoreMiddleDot( sal_Bool bVal ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/securityoptions.hxx b/include/unotools/securityoptions.hxx new file mode 100644 index 000000000000..2156cb5ec3e5 --- /dev/null +++ b/include/unotools/securityoptions.hxx @@ -0,0 +1,261 @@ +/* -*- 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_unotools_SECURITYOPTIONS_HXX +#define INCLUDED_unotools_SECURITYOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +/*-************************************************************************************************************//** + @short forward declaration to our private date container implementation + @descr We use these class as internal member to support small memory requirements. + You can create the container if it is neccessary. The class which use these mechanism + is faster and smaller then a complete implementation! +*//*-*************************************************************************************************************/ + +class SvtSecurityOptions_Impl; + +/*-************************************************************************************************************//** + @descr These values present modes to handle StarOffice basic scripts. + see GetBasicMode/SetBasicMode() for further information +*//*-*************************************************************************************************************/ + +enum EBasicSecurityMode +{ + eNEVER_EXECUTE = 0, + eFROM_LIST = 1, + eALWAYS_EXECUTE = 2 +}; + +/*-************************************************************************************************************//** + @short collect information about security features + @descr - + + @implements - + @base - + + @ATTENTION This class is partially threadsafe. + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSecurityOptions : public utl::detail::Options +{ + public: + + enum EOption + { + E_SECUREURLS, + E_BASICMODE, // xmlsec05 depricated + E_EXECUTEPLUGINS, // xmlsec05 depricated + E_WARNING, // xmlsec05 depricated + E_CONFIRMATION, // xmlsec05 depricated + E_DOCWARN_SAVEORSEND, + E_DOCWARN_SIGNING, + E_DOCWARN_PRINT, + E_DOCWARN_CREATEPDF, + E_DOCWARN_REMOVEPERSONALINFO, + E_DOCWARN_RECOMMENDPASSWORD, + E_MACRO_SECLEVEL, + E_MACRO_TRUSTEDAUTHORS, + E_MACRO_DISABLE, + E_CTRLCLICK_HYPERLINK + }; + + enum MacroAction + { + MA_DONTRUN = 0, + MA_CONFIRM, + MA_RUN + }; + + typedef ::com::sun::star::uno::Sequence< OUString > Certificate; + + /* + // MT: Doesn't work for sequence... + struct Certificate + { + OUString SubjectName; + OUString SerialNumber; + OUString RawData; + }; + */ + + public: + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will initialize an instance with default values. + We implement these class with a refcount mechanism! Every instance of this class increase it + at create and decrease it at delete time - but all instances use the same data container! + He is implemented as a static member ... + + @seealso member m_nRefCount + @seealso member m_pDataContainer + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + SvtSecurityOptions(); + virtual ~SvtSecurityOptions(); + + /*-****************************************************************************************************//** + @short returns readonly state + @descr It can be called to get information about the readonly state of a provided item. + @seealso - + + @param "eOption", specify, which item is queried + @return <TRUE/> if item is readonly; <FALSE/> otherwise + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Bool IsReadOnly( EOption eOption ) const ; + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL" + @descr These value displays the list of all trustworthy URLs. + zB.: file:/ => All scripts from the local file system including a LAN; + private:explorer => Scripts from the Explorer; + private:help => Scripts in the help system; + private:newmenu => Scripts that are executed by the commands File-New and AutoPilot; + private:schedule => Scripts of the scheduler; + private:searchfolder => Scripts of the searchfolder; + private:user => Scripts that are entered in the URL field. + @seealso - + + @param "seqURLList", new values to set it in configuration. + @return The values which represent current state of internal variable. + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + ::com::sun::star::uno::Sequence< OUString > GetSecureURLs( ) const ; + void SetSecureURLs( const ::com::sun::star::uno::Sequence< OUString >& seqURLList ) ; + + /*-****************************************************************************************************//** + @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/StarOfficeBasic" + @descr These value determines how StarOffice Basic scripts should be handled. + It exist 3 different modes: + 0 = never execute + 1 = from list + 2 = always execute + + @ATTENTION These methods don't check for valid or invalid values! + Our configuration server can do it ... but these implementation don't get any notifications + about wrong commits ...! + => If you set an invalid value - nothing will be changed. The information will lost. + + @seealso enum EBasicSecurityMode + + @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode! + @return An enum value, which present current mode. + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Int32 GetMacroSecurityLevel ( ) const ; + void SetMacroSecurityLevel ( sal_Int32 _nLevel ) ; + + sal_Bool IsMacroDisabled ( ) const ; + + /*-****************************************************************************************************//** + @short special method to check an URL and his referer corresponding to ouer internal security cessation + @descr Give us an URL and his referer and we will say you if these url can be scripted or not! + + @seealso - + + @param "sURL" reference to URL for checking + @param "sReferer" reference to referer which whish to run script by given URL + @return sal_True if URL is secure or security is obsolete(!) or sal_False otherwise. + + @onerror No error should occurre! + *//*-*****************************************************************************************************/ + + sal_Bool IsSecureURL( const OUString& sURL , + const OUString& sReferer ) const ; + + ::com::sun::star::uno::Sequence< Certificate > GetTrustedAuthors ( ) const ; + void SetTrustedAuthors ( const ::com::sun::star::uno::Sequence< Certificate >& rAuthors ) ; + + // for bool options only! + bool IsOptionSet ( EOption eOption ) const ; + bool SetOption ( EOption eOption, bool bValue ) ; + bool IsOptionEnabled ( EOption eOption ) const ; + + // xmlsec05 depricated methods + sal_Bool IsExecutePlugins() const; + void SetExecutePlugins( sal_Bool bSet ); + EBasicSecurityMode GetBasicMode( ) const ; + void SetBasicMode( EBasicSecurityMode eMode ) ; + sal_Bool IsWarningEnabled() const; + void SetWarningEnabled( sal_Bool bSet ); + sal_Bool IsConfirmationEnabled() const; + void SetConfirmationEnabled( sal_Bool bSet ); + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is partially threadsafe (for de-/initialization only). + All access methods are'nt safe! + We create a static mutex only for one ime and use at different times. + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetInitMutex(); + + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + + /*Attention + + Don't initialize these static member in these header! + a) Double dfined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtSecurityOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! + static sal_Int32 m_nRefCount ; /// internal ref count mechanism + +}; // class SvtSecurityOptions + +#endif // #ifndef INCLUDED_unotools_SECURITYOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/sharedunocomponent.hxx b/include/unotools/sharedunocomponent.hxx new file mode 100644 index 000000000000..5fa399dbc417 --- /dev/null +++ b/include/unotools/sharedunocomponent.hxx @@ -0,0 +1,364 @@ +/* -*- 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 UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX +#define UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX + +#include "unotoolsdllapi.h" + +#include <boost/shared_ptr.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ref.hxx> + +namespace com { namespace sun { namespace star { + namespace lang { + class XComponent; + } +} } } +//............................................................................ +namespace utl +{ +//............................................................................ + + //======================================================================== + //= DisposableComponent + //======================================================================== + /** is a class which controls lifetime of an UNO component via ->XComponent::dispose + + You'll usually never use this class directly, but only as parameter for a + ->SharedUNOComponent class. + */ + class UNOTOOLS_DLLPUBLIC DisposableComponent + { + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > + m_xComponent; + + public: + /** constructs a ->DisposableComponent instance + + @param _rxComponent + the component whose life time should be controlled by the instance. Must not be <NULL/>. + */ + DisposableComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + + /** disposes the component represented by the instance + + The component is queried for ->XComponent(which <em>must</em> be supported), + and ->XComponent::dispose is invoked. A failure of this invocation (e.g. a thrown + exception) is silenced in release builds, and reported in debug builds. + */ + ~DisposableComponent(); + + private: + DisposableComponent(); // never implemented + DisposableComponent( const DisposableComponent& ); // never implemented + DisposableComponent& operator=( const DisposableComponent& ); // never implemented + }; + + //======================================================================== + //= CloseableComponent + //======================================================================== + class CloseableComponentImpl; + /** is a class which controls lifetime of an UNO component via ->XCloseable::close + + You'll usually never use this class directly, but only as parameter for a + ->SharedUNOComponent class. + */ + class UNOTOOLS_DLLPUBLIC CloseableComponent + { + private: + /** Our IMPL class. + */ + ::rtl::Reference< CloseableComponentImpl > m_pImpl; + + public: + /** constructs a ->CloseableComponent instance + + @param _rxComponent + the component whose life time should be controlled by the instance. Must not be <NULL/>. + */ + CloseableComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); + + /** destroys resources associated with this instance, and disposes the component + + The component is queried for ->XCloseable (which <em>must</em> be supported), + and ->XCloseable::close is invoked, with delivering the ownership. + If the invocation fails with a ->CloseVetoException, this is ignored, since in + this case the vetoing instance took the ownership. + + Any other failure will be reported in a debug version via assertion mechanisms, + and silenced in release builds. + */ + ~CloseableComponent(); + + private: + CloseableComponent(); // never implemented + CloseableComponent( const CloseableComponent& ); // never implemented + CloseableComponent& operator=( const CloseableComponent& ); // never implemented + }; + + //======================================================================== + //= SharedUNOComponent + //======================================================================== + /** is a helper class for sharing ownership of a UNO component + + If you need to share an UNO component, which normally needs a dedicated owner, + and is lifetime controlled by an explicit disposal action (not necessarily ->XComponent::dispose, + but <em>any</em> explicit method call, after which the object is considered + to be disposed), between different classes, ->SharedUNOComponent is what you need. + + Instead of passing around a <code>Reference< XFoo ></code>, and bothering + with ownership and disposal, you just use a <code>SharedUNOComponent< XFoo ></code>. + This instance can be passed around, including copying, and in nearly all respects behaves + like the original <code>Reference< XFoo ></code>. However, when the last + ->SharedUNOComponent referencing a certain <code>Reference< XFoo ></code> dies, it + will automatically get rid of the object held by this reference. + + @param INTERFACE + the UNO interface type as which the component should be held + + @param COMPONENT_HOLDER + a class which can be used to represent and dispose a UNO component. + The class must support (maybe explicit only) construction from a + <code>Reference< INTERFACE ></code>, and destruction. Upon destruction, + the class must dispose (by any suitable means) the component instance it was + constructed with. + */ + template < class INTERFACE, class COMPONENT = DisposableComponent > + class SharedUNOComponent + { + private: + typedef COMPONENT Component; + typedef ::boost::shared_ptr< Component > ComponentPointer; + + private: + ComponentPointer m_pComponent; + ::com::sun::star::uno::Reference< INTERFACE > m_xTypedComponent; + + public: + enum AssignmentMode + { + TakeOwnership, + NoTakeOwnership + }; + + public: + inline SharedUNOComponent() + { + } + + explicit inline SharedUNOComponent( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode eMode = TakeOwnership ) + { + reset( _rxComponent, eMode ); + } + +#ifndef EXCEPTIONS_OFF + inline SharedUNOComponent( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + set( _pInterface, _queryThrow ); + } + + inline SharedUNOComponent( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + set( _rRef, _queryThrow ); + } + + inline SharedUNOComponent( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + set( _rAny, _queryThrow ); + } + + inline SharedUNOComponent( const SharedUNOComponent& _rxComponent, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ) + { + set( _rxComponent, _setThrow ); + } +#endif + +// SharedUNOComponent& operator=( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent ); + // This operator is intentionally not implemented. There is no canonic ownership after this operator + // would have been applied: Should the SharedUNOComponent have the ownership of the component, + // or shouldn't it? Hard to guess, and probably wrong in 50 percent of all cases, anyway. So, + // instead of tempting clients of this class to use such a dangerous operator, we do + // not offer it at all. If you need to assign a Reference< INTERFACE > to your SharedUNOComponent, + // use the ->reset method. + + /** assigns a new component, and releases the old one + */ + void reset( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode = TakeOwnership ); + + inline bool set( ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_Query _query ); + inline bool set( const ::com::sun::star::uno::BaseReference& _rRef, ::com::sun::star::uno::UnoReference_Query _query ); + inline bool set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_Query _query ); + +#ifndef EXCEPTIONS_OFF + inline void set( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ); + inline void set( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ); + inline void set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ); + + inline void set( const INTERFACE* _pInterface, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ); + inline void set( const ::com::sun::star::uno::Reference< INTERFACE >& _rRef, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ); + inline void set( const SharedUNOComponent& _rComp, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ); +#endif + + INTERFACE* SAL_CALL operator->() const; + + inline operator const ::com::sun::star::uno::Reference< INTERFACE >&() const + { + return m_xTypedComponent; + } + + inline const ::com::sun::star::uno::Reference< INTERFACE >& getTyped() const + { + return m_xTypedComponent; + } + + inline bool is() const + { + return m_xTypedComponent.is(); + } + + inline void clear() + { + m_pComponent.reset(); + m_xTypedComponent.clear(); + } + }; + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + INTERFACE* SAL_CALL SharedUNOComponent< INTERFACE, COMPONENT >::operator->() const + { + return m_xTypedComponent.operator->(); + } + + //------------------------------------------------------------------------- + // assignments + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::reset( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode ) + { + m_pComponent.reset( _eMode == TakeOwnership ? new COMPONENT( _rxComponent ) : NULL ); + m_xTypedComponent = _rxComponent; + } + + //------------------------------------------------------------------------- + // comparison operators + template < class INTERFACE, class COMPONENT > + bool operator==( const ::com::sun::star::uno::Reference< INTERFACE >& _rLHS, const SharedUNOComponent< INTERFACE, COMPONENT >& _rRHS ) + { + return _rLHS == _rRHS.getTyped(); + } + + template < class INTERFACE, class COMPONENT > + bool operator==( const SharedUNOComponent< INTERFACE, COMPONENT >& _rLHS, const ::com::sun::star::uno::Reference< INTERFACE >& _rRHS ) + { + return _rLHS.getTyped() == _rRHS; + } + + //------------------------------------------------------------------------- + // conversion to Any + template < class INTERFACE, class COMPONENT > + inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const SharedUNOComponent< INTERFACE, COMPONENT >& value ) SAL_THROW(()) + { + rAny <<= value.getTyped(); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + inline ::com::sun::star::uno::Any SAL_CALL makeAny( const SharedUNOComponent< INTERFACE, COMPONENT >& value ) SAL_THROW(()) + { + return makeAny( value.getTyped() ); + } + +#ifndef EXCEPTIONS_OFF + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _queryThrow ), TakeOwnership ); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _queryThrow ), TakeOwnership ); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _rAny, _queryThrow ), TakeOwnership ); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const INTERFACE* _pInterface, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _setThrow ), TakeOwnership ); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Reference< INTERFACE >& _rRef, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _setThrow ), TakeOwnership ); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + void SharedUNOComponent< INTERFACE, COMPONENT >::set( const SharedUNOComponent& _rComp, ::com::sun::star::uno::UnoReference_SetThrow _setThrow ) + { + *this = _rComp; + // provoke an exception in case the component is NULL + m_xTypedComponent.set( m_xTypedComponent, _setThrow ); + } +#endif + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + bool SharedUNOComponent< INTERFACE, COMPONENT >::set( ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_Query _query ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _query ) ); + return is(); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + bool SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::BaseReference& _rRef, ::com::sun::star::uno::UnoReference_Query _query ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _query ) ); + return is(); + } + + //------------------------------------------------------------------------- + template < class INTERFACE, class COMPONENT > + bool SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_Query _query ) + { + reset( ::com::sun::star::uno::Reference< INTERFACE >( _rAny, _query ) ); + return is(); + } + +//............................................................................ +} // namespace utl +//............................................................................ + +#endif // UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/streamhelper.hxx b/include/unotools/streamhelper.hxx new file mode 100644 index 000000000000..60e16a28767a --- /dev/null +++ b/include/unotools/streamhelper.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_STREAMHELPER_HXX_ +#define _UNOTOOLS_STREAMHELPER_HXX_ +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <osl/mutex.hxx> +#include <cppuhelper/implbase2.hxx> +#include <tools/stream.hxx> + +namespace utl +{ + namespace stario = ::com::sun::star::io; + namespace staruno = ::com::sun::star::uno; + +/** + * The helper implementation for a using input streams based on SvLockBytes. + * + * @author Dirk Grobler + * @since 00/28/03 + */ + typedef ::cppu::WeakImplHelper2<stario::XInputStream, stario::XSeekable> InputStreamHelper_Base; + // needed for some compilers +class UNOTOOLS_DLLPUBLIC OInputStreamHelper : public InputStreamHelper_Base +{ + ::osl::Mutex m_aMutex; + SvLockBytesRef m_xLockBytes; + sal_uInt32 m_nActPos; + sal_Int32 m_nAvailable; // this is typically the chunk(buffer) size + +public: + OInputStreamHelper(const SvLockBytesRef& _xLockBytes, + sal_uInt32 _nAvailable, + sal_uInt32 _nPos = 0) + :m_xLockBytes(_xLockBytes) + ,m_nActPos(_nPos) + ,m_nAvailable(_nAvailable){} + +// staruno::XInterface + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + +// stario::XInputStream + virtual sal_Int32 SAL_CALL readBytes( staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes( staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException); + virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(stario::NotConnectedException, stario::BufferSizeExceededException, stario::IOException, staruno::RuntimeException); + virtual sal_Int32 SAL_CALL available( ) throw(stario::NotConnectedException, stario::IOException, staruno::RuntimeException); + virtual void SAL_CALL closeInput( ) throw (stario::NotConnectedException, stario::IOException, staruno::RuntimeException); + + virtual void SAL_CALL seek( sal_Int64 location ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getPosition( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLength( ) throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); +}; + +} // namespace utl + + +#endif // _UNOTOOLS_STREAM_WRAPPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/streamsection.hxx b/include/unotools/streamsection.hxx new file mode 100644 index 000000000000..8e347eec5d4e --- /dev/null +++ b/include/unotools/streamsection.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _UNOTOOLS_STREAMSECTION_HXX_ +#define _UNOTOOLS_STREAMSECTION_HXX_ + +#include <com/sun/star/io/XMarkableStream.hpp> +#include <com/sun/star/io/XDataInputStream.hpp> +#include <com/sun/star/io/XDataOutputStream.hpp> + +namespace utl +{ + + namespace stario = ::com::sun::star::io; + namespace staruno = ::com::sun::star::uno; + +/** implements handling for compatibly reading/writing data from/into an input/output stream. + data written in a block secured by this class should be readable by older versions which + use the same mechanism. + + @author Frank Schoenheit + @since 00/26/05 +*/ + +class OStreamSection +{ + staruno::Reference< stario::XMarkableStream > m_xMarkStream; + staruno::Reference< stario::XDataInputStream > m_xInStream; + staruno::Reference< stario::XDataOutputStream > m_xOutStream; + + sal_Int32 m_nBlockStart; + sal_Int32 m_nBlockLen; + +public: + /** starts reading of a "skippable" section of data within the given input stream<BR> + @param _rxInput the stream to read from. Must support the + <type scope="com::sun::star::io">XMarkableStream</type> interface + */ + OStreamSection(const staruno::Reference< stario::XDataInputStream >& _rxInput); + + /** starts writing of a "skippable" section of data into the given output stream + @param _rxOutput the stream the stream to write to. Must support the + <type scope="com::sun::star::io">XMarkableStream</type> interface + @param _nPresumedLength estimation for the length of the upcoming section. If greater 0, this + value will be written as section length and corrected (in the dtor) only if + needed. If you know how much bytes you are about to write, you may + want to use this param, saving some stream operations this way. + */ + OStreamSection(const staruno::Reference< stario::XDataOutputStream >& _rxOutput, sal_Int32 _nPresumedLength = 0); + + /** dtor. <BR>If constructed for writing, the section "opened" by this object will be "closed".<BR> + If constructed for reading, any remaining bytes 'til the end of the section will be skipped. + */ + ~OStreamSection(); +}; + +} // namespace utl + +#endif // _UNOTOOLS_STREAMSECTION_HXX_ + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx new file mode 100644 index 000000000000..097b3dee94e3 --- /dev/null +++ b/include/unotools/streamwrap.hxx @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UTL_STREAM_WRAPPER_HXX_ +#define _UTL_STREAM_WRAPPER_HXX_ +#include <osl/mutex.hxx> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XTruncate.hpp> +#include <com/sun/star/io/XStream.hpp> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase1.hxx> + +class SvStream; + +namespace utl +{ + namespace stario = ::com::sun::star::io; + namespace staruno = ::com::sun::star::uno; + +//================================================================== +//= OInputStreamWrapper +//================================================================== +typedef ::cppu::WeakImplHelper1 < stario::XInputStream + > InputStreamWrapper_Base; +// needed for some compilers +/// helper class for wrapping an SvStream into an <type scope="com.sun.star.io">XInputStream</type> +class UNOTOOLS_DLLPUBLIC OInputStreamWrapper : public InputStreamWrapper_Base +{ +protected: + ::osl::Mutex m_aMutex; + SvStream* m_pSvStream; + sal_Bool m_bSvStreamOwner : 1; + OInputStreamWrapper() + { m_pSvStream = 0; m_bSvStreamOwner = sal_False; } + void SetStream(SvStream* _pStream, sal_Bool bOwner ) + { m_pSvStream = _pStream; m_bSvStreamOwner = bOwner; } + +public: + OInputStreamWrapper(SvStream& _rStream); + OInputStreamWrapper(SvStream* pStream, sal_Bool bOwner=sal_False); + virtual ~OInputStreamWrapper(); + +// stario::XInputStream + virtual sal_Int32 SAL_CALL readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual sal_Int32 SAL_CALL readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual sal_Int32 SAL_CALL available() throw(stario::NotConnectedException, staruno::RuntimeException); + virtual void SAL_CALL closeInput() throw(stario::NotConnectedException, staruno::RuntimeException); + +protected: + /// throws a NotConnectedException if the object is not connected anymore + void checkConnected() const; + /// throws an exception according to the error flag of m_pSvStream + void checkError() const; +}; + +//================================================================== +//= OSeekableInputStreamWrapper +//================================================================== +typedef ::cppu::ImplHelper1 < ::com::sun::star::io::XSeekable + > OSeekableInputStreamWrapper_Base; +/** helper class for wrapping an SvStream into an <type scope="com.sun.star.io">XInputStream</type> + which is seekable (i.e. supports the <type scope="com.sun.star.io">XSeekable</type> interface). +*/ +class UNOTOOLS_DLLPUBLIC OSeekableInputStreamWrapper : public ::cppu::ImplInheritanceHelper1 < OInputStreamWrapper, com::sun::star::io::XSeekable > +{ +protected: + OSeekableInputStreamWrapper() {} +public: + OSeekableInputStreamWrapper(SvStream& _rStream); + OSeekableInputStreamWrapper(SvStream* _pStream, sal_Bool _bOwner = sal_False); + + // XSeekable + virtual void SAL_CALL seek( sal_Int64 _nLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); +}; + +//================================================================== +//= OOutputStreamWrapper +//================================================================== +typedef ::cppu::WeakImplHelper1<stario::XOutputStream> OutputStreamWrapper_Base; + // needed for some compilers +class OOutputStreamWrapper : public OutputStreamWrapper_Base +{ +public: + UNOTOOLS_DLLPUBLIC OOutputStreamWrapper(SvStream& _rStream); + +protected: + virtual ~OOutputStreamWrapper(); + +// stario::XOutputStream + virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL flush() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL closeOutput() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + + /// throws an exception according to the error flag of m_pSvStream + void checkError() const; + + // TODO: thread safety! + SvStream& rStream; +}; + +//================================================================== +//= OSeekableOutputStreamWrapper +//================================================================== +typedef ::cppu::ImplHelper1 < ::com::sun::star::io::XSeekable + > OSeekableOutputStreamWrapper_Base; +/** helper class for wrapping an SvStream into an <type scope="com.sun.star.io">XOutputStream</type> + which is seekable (i.e. supports the <type scope="com.sun.star.io">XSeekable</type> interface). +*/ +class OSeekableOutputStreamWrapper + :public OOutputStreamWrapper + ,public OSeekableOutputStreamWrapper_Base +{ +public: + UNOTOOLS_DLLPUBLIC OSeekableOutputStreamWrapper(SvStream& _rStream); + +private: + virtual ~OSeekableOutputStreamWrapper(); + + // disambiguate XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire( ) throw (); + virtual void SAL_CALL release( ) throw (); + + // XSeekable + virtual void SAL_CALL seek( sal_Int64 _nLocation ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); +}; + +class UNOTOOLS_DLLPUBLIC OStreamWrapper : public ::cppu::ImplInheritanceHelper3 < OSeekableInputStreamWrapper, com::sun::star::io::XStream, com::sun::star::io::XOutputStream, com::sun::star::io::XTruncate > +{ +public: + OStreamWrapper(SvStream& _rStream); + +// stario::XStream + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) throw (::com::sun::star::uno::RuntimeException); + +// stario::XOutputStream + virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL flush() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL closeOutput() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); + virtual void SAL_CALL truncate() throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); +}; + +} +// namespace utl + +#endif // _UTL_STREAM_WRAPPER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/syslocale.hxx b/include/unotools/syslocale.hxx new file mode 100644 index 000000000000..d32a22139129 --- /dev/null +++ b/include/unotools/syslocale.hxx @@ -0,0 +1,79 @@ +/* -*- 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_UNOTOOLS_SYSLOCALE_HXX +#define INCLUDED_UNOTOOLS_SYSLOCALE_HXX + +#include "unotools/unotoolsdllapi.h" +#include <unotools/localedatawrapper.hxx> +#include <unotools/charclass.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <sal/types.h> +#include <rtl/textenc.h> + +class SvtSysLocale_Impl; +class SvtSysLocaleOptions; + +namespace osl { class Mutex; } + +/** + SvtSysLocale provides a refcounted single instance of an application wide + <type>LocaleDataWrapper</type> and <type>CharClass</type> which always + follow the locale as it is currently configured by the user. You may use + it anywhere to access the locale data elements like decimal separator and + simple date formatting and so on. Contructing and destructing a + SvtSysLocale is not expensive as long as there is at least one instance + left. + */ +class UNOTOOLS_DLLPUBLIC SvtSysLocale +{ + friend class SvtSysLocale_Impl; // access to mutex + + static SvtSysLocale_Impl* pImpl; + static sal_Int32 nRefCount; + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex(); + +public: + SvtSysLocale(); + ~SvtSysLocale(); + + const LocaleDataWrapper& GetLocaleData() const; + const CharClass& GetCharClass() const; + + /** It is safe to store the pointers locally and use them AS LONG AS THE + INSTANCE OF SvtSysLocale LIVES! + It is a faster access but be sure what you do! + */ + const LocaleDataWrapper* GetLocaleDataPtr() const; + const CharClass* GetCharClassPtr() const; + SvtSysLocaleOptions& GetOptions() const; + const LanguageTag& GetLanguageTag() const; + const LanguageTag& GetUILanguageTag() const; + + /** Get the best MIME encoding matching the system locale, or if that isn't + determinable one that matches the UI locale, or UTF8 if everything else + fails. + */ + static rtl_TextEncoding GetBestMimeEncoding(); +}; + +#endif // INCLUDED_SVTOOLS_SYSLOCALE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/syslocaleoptions.hxx b/include/unotools/syslocaleoptions.hxx new file mode 100644 index 000000000000..8c9378938ce0 --- /dev/null +++ b/include/unotools/syslocaleoptions.hxx @@ -0,0 +1,177 @@ +/* -*- 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_SVTOOLS_SYSLOCALEOPTIONS_HXX +#define INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <tools/solar.h> +#include <tools/link.hxx> +#include <i18nlangtag/lang.h> +#include <i18nlangtag/languagetag.hxx> +#include <tools/string.hxx> +#include <unotools/options.hxx> + +// bits for broadcasting hints of changes in a SfxSimpleHint, may be combined +const sal_uLong SYSLOCALEOPTIONS_HINT_LOCALE = 0x00000001; +const sal_uLong SYSLOCALEOPTIONS_HINT_CURRENCY = 0x00000002; +const sal_uLong SYSLOCALEOPTIONS_HINT_UILOCALE = 0x00000004; +const sal_uLong SYSLOCALEOPTIONS_HINT_DECSEP = 0x00000008; +const sal_uLong SYSLOCALEOPTIONS_HINT_DATEPATTERNS = 0x00000010; +const sal_uLong SYSLOCALEOPTIONS_HINT_IGNORELANG = 0x00000020; + +class SvtSysLocaleOptions_Impl; +class SvtListener; +namespace osl { class Mutex; } + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSysLocaleOptions : public utl::detail::Options +{ + static SvtSysLocaleOptions_Impl* pOptions; + static sal_Int32 nRefCount; + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex(); + virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint ); + +public: + + enum EOption + { + E_LOCALE, + E_UILOCALE, + E_CURRENCY, + E_DATEPATTERNS + }; + SvtSysLocaleOptions(); + virtual ~SvtSysLocaleOptions(); + + // ConfigItem methods + + sal_Bool IsModified(); + void Commit(); + + /** Add a listener to react on config changes + which are broadcasted in a SfxSimpleHint + @return + <TRUE/> if added + <FALSE/> if not added + */ + + /** Block broadcasts and accumulate hints. This may be useful if, for + example, the locale and currency are changed and the currency was + empty before, since changing the locale with an empty currency does + also broadcast a change hint for the currency which would result in + two currency changes broadcasted. + + @param bBlock + <TRUE/>: broadcasts are blocked until reversed. + <FALSE/>: broadcasts are not blocked anymore. Pending hints are + broadcasted if no other instance blocks the broadcast. + + @ATTENTION + All SvtSysLocaleOptions instances point to exactly one refcounted + internal representation instance and broadcast blocks are counted. + Thus if you issue a BlockBroadcasts(sal_True) you MUST issue a matching + BlockBroadcasts(sal_False) or otherwise pending hints would never be + broadcasted again. + */ + virtual void BlockBroadcasts( bool bBlock ); + + // config value access methods + + /// The config string may be empty to denote the SYSTEM locale + const OUString& GetLocaleConfigString() const; + void SetLocaleConfigString( const OUString& rStr ); + /** Get locale set, if empty denotes SYSTEM locale, not resolved + to the real locale. */ + LanguageTag GetLanguageTag() const; + /** Get locale set, always resolved to the real locale. */ + const LanguageTag& GetRealLanguageTag() const; + + /// The config string may be empty to denote the SYSTEM locale + void SetUILocaleConfigString( const OUString& rStr ); + /** Get UI locale set, always resolved to the real locale. */ + const LanguageTag& GetRealUILanguageTag() const; + + /// The config string may be empty to denote the default currency of the locale + const OUString& GetCurrencyConfigString() const; + void SetCurrencyConfigString( const OUString& rStr ); + + /** The config string may be empty to denote the default + DateAcceptancePatterns of the locale */ + const OUString& GetDatePatternsConfigString() const; + void SetDatePatternsConfigString( const OUString& rStr ); + + // determine whether the decimal separator defined in the keyboard layout is used + // or the one approriate to the locale + sal_Bool IsDecimalSeparatorAsLocale() const; + void SetDecimalSeparatorAsLocale( sal_Bool bSet); + + // determine whether to ignore changes to the system keyboard/locale/language when + // determining the language for newly entered text + sal_Bool IsIgnoreLanguageChange() const; + void SetIgnoreLanguageChange( sal_Bool bSet); + + // convenience methods + + /// Get currency abbreviation and locale from an USD-en-US or EUR-de-DE string + static void GetCurrencyAbbrevAndLanguage( + String& rAbbrev, + LanguageType& eLang, + const OUString& rConfigString ); + + /// Create an USD-en-US or EUR-de-DE string + static OUString CreateCurrencyConfigString( + const String& rAbbrev, + LanguageType eLang ); + + void GetCurrencyAbbrevAndLanguage( + String& rAbbrev, + LanguageType& eLang ) const + { + GetCurrencyAbbrevAndLanguage( rAbbrev, + eLang, GetCurrencyConfigString() ); + } + + void SetCurrencyAbbrevAndLanguage( + const String& rAbbrev, + LanguageType eLang ) + { + SetCurrencyConfigString( + CreateCurrencyConfigString( + rAbbrev, eLang ) ); + } + + /** Set a link to a method to be called whenever the default currency + changes. This can be only one method, and normally it is the static + link method which calls SvNumberFormatter::SetDefaultSystemCurrency(). + This is needed because the number formatter isn't part of the svl light + library, otherwise we could call SetDefaultSystemCurrency() directly. + */ + static void SetCurrencyChangeLink( const Link& rLink ); + static const Link& GetCurrencyChangeLink(); + + /** return the readonly state of the queried option. */ + sal_Bool IsReadOnly( EOption eOption ) const; +}; + +#endif // INCLUDED_SVTOOLS_SYSLOCALEOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/tempfile.hxx b/include/unotools/tempfile.hxx new file mode 100644 index 000000000000..6cf2cb0cd98c --- /dev/null +++ b/include/unotools/tempfile.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_TEMPFILE_HXX +#define _UNOTOOLS_TEMPFILE_HXX + +#include <tools/string.hxx> +#include <tools/stream.hxx> + +namespace utl +{ + +struct TempFile_Impl; + +/** + The class TempFile gives access to temporary files in the local file system. Sometimes they are needed because a 3rd party + code has a file name based interface, or some file access has to be done locally without transferring tons of bytes to or + from a remote system. + Creating a UCB content on a TempFile is only possible if a UCP for the local file system is present. + TempFiles can always be accessed by SvFileStreams or Sot/SvStorages using the "physical" file name ( not the URL, because + this may be a non-file URL, see below ), but if a UCB content can be created, it is also possible to take the URL and use + the UCB helper classes for streams. For convenience use UcbStreamHelper. + A Tempfile always has a "physical" file name ( a file name in the local computers host notation ) but it has a + "UCB compatible" URL only if a UCP for the local file system exists. This URL may have its own URL scheme + ( not necessarily "file://" ! ). The TempFile class methods take this into account, but other simple conversions like + the osl functions do not. + So it is a potential error to convert between the filename and the URL of a TempFile object using functions or methods + outside this class. +*/ + +class UNOTOOLS_DLLPUBLIC TempFile +{ + TempFile_Impl* pImp; + sal_Bool bKillingFileEnabled; + +protected: + +public: + /** + Create a temporary file or directory, in the default tempfile folder or if possible in a given folder. + This given folder ( the "parent" parameter ( if not NULL ) ) must be a "UCB compatible" URL. + The temporary object is created in the local file system, even if there is no UCB that can access it. + If the given folder is part of the local file system, the TempFile is created in this folder. + */ + TempFile( const String* pParent=NULL, sal_Bool bDirectory=sal_False ); + + /** + Same as above; additionally the name starts with some given characters followed by a counter ( example: + rLeadingChars="abc" means "abc0","abc1" and so on, depending on existing files in the folder ). + The extension string may be f.e. ".txt" or "", if no extension string is given, ".tmp" is used + */ + TempFile( const String& rLeadingChars, const String* pExtension=NULL, const String* pParent=NULL, + sal_Bool bDirectory=sal_False); + + /** + Same as above; additionally the name starts with some given characters followed by a counter ( example: + rLeadingChars="abc" means "abc0","abc1" and so on, depending on existing files in the folder ). + The extension string may be f.e. ".txt" or "", if no extension string is given, ".tmp" is used + @param _bStartWithZero If set to false names will be generated like "abc","abc0","abc1" + */ + TempFile( const String& rLeadingChars,sal_Bool _bStartWithZero, const String* pExtension=NULL, const String* pParent=NULL,sal_Bool bDirectory=sal_False); + + /** + TempFile will be removed from disk in dtor if EnableKillingTempFile was called before. + Temporary directories will be removed recursively in that case. + */ + ~TempFile(); + + /** + Returns sal_True if it has a valid file name. + */ + sal_Bool IsValid() const; + + /** + Returns the "UCB compatible" URL of the tempfile object. + If you want to have the "physical" file name, use the GetFileName() method of this object, because these + method uses the UCB for the conversion, but never use any external conversion functions for URLs into + "physical" names. + If no UCP is available for the local file system, an empty URL is returned. In this case you can't access + the file as a UCB content ! + */ + String GetURL() const; + + /** + Returns the "physical" name of the tempfile in host notation ( should only be used for 3rd party code + with file name interfaces ). + If you want to have the URL, use the GetURL() method of this object, but never use any external + conversion functions for "physical" names into URLs. + */ + String GetFileName() const; + + /** + Returns a stream to the tempfiles data; the stream is owned by the tempfile object, so you have to keep this + alive as long as you want to use the stream. If the TempFile object is destroyed, it also destroys the + stream object, the underlying file is only deleted if EnableKillingFile( sal_True ) has been called before! + */ + SvStream* GetStream( StreamMode eMode ); + + /** + Let the TempFile object close and destroy the owned stream object if any. + */ + void CloseStream(); + + /** + If enabled the file will be removed from disk when the dtor is called ( default is not enabled ) + */ + void EnableKillingFile( sal_Bool bEnable=sal_True ) + { bKillingFileEnabled = bEnable; } + + sal_Bool IsKillingFileEnabled() const + { return bKillingFileEnabled; } + + /** + Only create a "physical" file name for a temporary file that would be valid at that moment. + Should only be used for 3rd party code with a file name interface that wants to create the file by itself. + If you want to convert file name into a URL, always use class LocalFileHelper, but never use any + conversion functions of osl. + */ + static String CreateTempName( const String* pParent=NULL ); + + /** + The TempNameBaseDirectory is a subfolder in the folder that is passed as a "physical" file name in the + SetTempNameBaseDirectory method. + This subfolder will be used if a TempFile or TempName is created without a parent name or a parent name + that does not belong to the local file system. + The caller of the SetTempNameBase is responsible for deleting this folder and all temporary files in it. + The return value of both methods is the complete "physical" name of the tempname base folder. + It is not a URL because alle URLs must be "UCB compatible", so there may be no suitable URL at all. + */ + static String SetTempNameBaseDirectory( const String &rBaseName ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx new file mode 100644 index 000000000000..0b826102cb91 --- /dev/null +++ b/include/unotools/textsearch.hxx @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_TEXTSEARCH_HXX +#define _UNOTOOLS_TEXTSEARCH_HXX +#include <i18nlangtag/lang.h> +#include <rtl/ustring.hxx> +#include <tools/string.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/util/XTextSearch.hpp> +#include <com/sun/star/util/SearchOptions.hpp> + +class CharClass; + +namespace com { + namespace sun { + namespace star { + namespace util { + struct SearchResult; + } + } + } +} + +// ............................................................................ +namespace utl +{ +// ............................................................................ + +// Utility class for searching +class UNOTOOLS_DLLPUBLIC SearchParam +{ +public: + enum SearchType{ SRCH_NORMAL, SRCH_REGEXP, SRCH_LEVDIST }; + +private: + String sSrchStr; // the search string + String sReplaceStr; // the replace string + + SearchType m_eSrchType; // search normal/regular/LevDist + + int m_bWordOnly : 1; // used by normal search + int m_bSrchInSel : 1; // search only in the selection + int m_bCaseSense : 1; // + + // values for the "weight Levenshtein-Distance" + int bLEV_Relaxed : 1; + int nLEV_OtherX; + int nLEV_ShorterY; + int nLEV_LongerZ; + + // asian flags - used for the transliteration + long nTransliterationFlags; + +public: + SearchParam( const OUString &rText, + SearchType eSrchType = SearchParam::SRCH_NORMAL, + sal_Bool bCaseSensitive = sal_True, + sal_Bool bWordOnly = sal_False, + sal_Bool bSearchInSelection = sal_False ); + + SearchParam( const SearchParam& ); + + ~SearchParam(); + + const String& GetSrchStr() const { return sSrchStr; } + const String& GetReplaceStr() const { return sReplaceStr; } + SearchType GetSrchType() const { return m_eSrchType; } + + int IsCaseSensitive() const { return m_bCaseSense; } + int IsSrchInSelection() const { return m_bSrchInSel; } + int IsSrchWordOnly() const { return m_bWordOnly; } + + + void SetSrchStr( const String& rStr ) { sSrchStr = rStr; } + void SetReplaceStr( const String& rStr ) { sReplaceStr = rStr; } + void SetSrchType( SearchType eType ) { m_eSrchType = eType; } + + void SetCaseSensitive( int bFlag ) { m_bCaseSense = bFlag; } + void SetSrchInSelection( int bFlag ) { m_bSrchInSel = bFlag; } + void SetSrchWordOnly( int bFlag ) { m_bWordOnly = bFlag; } + + int IsSrchRelaxed() const { return bLEV_Relaxed; } + int GetLEVOther() const { return nLEV_OtherX; } + int GetLEVShorter() const { return nLEV_ShorterY; } + int GetLEVLonger() const { return nLEV_LongerZ; } + + void SetSrchRelaxed( int bFlag ) { bLEV_Relaxed = bFlag; } + void SetLEVOther( int nValue ) { nLEV_OtherX = nValue; } + void SetLEVShorter( int nValue ) { nLEV_ShorterY = nValue; } + void SetLEVLonger( int nValue ) { nLEV_LongerZ = nValue; } + + long GetTransliterationFlags() const { return nTransliterationFlags; } + void SetTransliterationFlags( long nValue ) { nTransliterationFlags = nValue; } +}; + +// Utility class for searching a substring in a string. +// The following metrics are supported +// - ordinary text (Bayer/Moore) +// - regular expressions +// - weighted Levenshtein distance +// +// This class allows forward and backward searching! + +class UNOTOOLS_DLLPUBLIC TextSearch +{ + static ::com::sun::star::uno::Reference< ::com::sun::star::util::XTextSearch > + getXTextSearch( const ::com::sun::star::util::SearchOptions& rPara ); + + com::sun::star::uno::Reference < com::sun::star::util::XTextSearch > + xTextSearch; + + void Init( const SearchParam & rParam, + const ::com::sun::star::lang::Locale& rLocale ); + +public: + // rText is the string being searched for + // this first two CTORs are deprecated! + TextSearch( const SearchParam & rPara, LanguageType nLanguage ); + TextSearch( const SearchParam & rPara, const CharClass& rCClass ); + + TextSearch( const ::com::sun::star::util::SearchOptions& rPara ); + ~TextSearch(); + + /* search in the (selected) text the search string: + rScrTxt - the text, in in which we search + pStart - start position for the search + pEnde - end position for the search + + RETURN values == sal_True: something is found + - pStart start pos of the found text, + - pStart end pos of the found text, + - pSrchResult - the search result with all found + positions. Is only filled with more positions + if the regular expression handles groups. + + == sal_False: nothing found, pStart,pEnde unchanged. + + Definitions: start pos always inclusive, end pos always exclusive! + The position must always in the right direction! + search forward: start <= end + search backward: end <= start + */ + int SearchFrwrd( const String &rStr, + xub_StrLen* pStart, xub_StrLen* pEnde, + ::com::sun::star::util::SearchResult* pSrchResult = 0 ); + sal_Bool SearchForward( const OUString &rStr, + sal_Int32* pStart, sal_Int32* pEnd, + ::com::sun::star::util::SearchResult* pRes = 0 ); + int SearchBkwrd( const String &rStr, + xub_StrLen* pStart, xub_StrLen* pEnde, + ::com::sun::star::util::SearchResult* pSrchResult = 0 ); + + void SetLocale( const ::com::sun::star::util::SearchOptions& rOpt, + const ::com::sun::star::lang::Locale& rLocale ); + + /* replace back references in the replace string by the sub expressions from the search result */ + void ReplaceBackReferences( String& rReplaceStr, const String &rStr, const ::com::sun::star::util::SearchResult& rResult ); + +}; + +// ............................................................................ +} // namespace utl +// ............................................................................ + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/transliterationwrapper.hxx b/include/unotools/transliterationwrapper.hxx new file mode 100644 index 000000000000..6d64d40a92f1 --- /dev/null +++ b/include/unotools/transliterationwrapper.hxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#include "unotools/unotoolsdllapi.h" + +#ifndef _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX +#define _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX +#include <tools/string.hxx> +#include <tools/solar.h> +#include <i18nlangtag/languagetag.hxx> +#include <com/sun/star/i18n/XExtendedTransliteration.hpp> + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +namespace utl +{ + +class UNOTOOLS_DLLPUBLIC TransliterationWrapper +{ + ::com::sun::star::uno::Reference< + ::com::sun::star::i18n::XExtendedTransliteration > xTrans; + LanguageTag aLanguageTag; + sal_uInt32 nType; + mutable sal_Bool bFirstCall; + + // not implemented, prevent usage + TransliterationWrapper( const TransliterationWrapper& ); + TransliterationWrapper& operator=( const TransliterationWrapper& ); + + void loadModuleImpl() const; + void setLanguageLocaleImpl( sal_uInt16 nLang ); + +public: + TransliterationWrapper( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & rxContext, + sal_uInt32 nType ); + + ~TransliterationWrapper(); + + // get current Locale / Language + const ::com::sun::star::lang::Locale& getLocale() const { return aLanguageTag.getLocale();} + sal_uInt16 getLanguage() const { return aLanguageTag.getLanguageType(); } + + sal_uInt32 getType() const { return nType; } + + sal_Bool needLanguageForTheMode() const; + + /** set a new language and load the corresponding transliteration module if + needed for the mode set with nType in the ctor */ + void loadModuleIfNeeded( sal_uInt16 nLang ); + + /** Load the transliteration module specified by rModuleName, which has to + be the UNO service implementation name that is expanded to the full UNO + service implementation name, for example, "NumToCharKanjiShort_ja_JP" + expands to + "com.sun.star.i18n.Transliteration.NumToCharKanjiShort_ja_JP". + @ATTENTION! + This method ignores the mode type set with the constructor and + interferes with the loadModuleIfNeeded() method and the transliterate() + method that gets a LanguageType passed as parameter. Using one of + those may load a different module and overwrite this setting. Only the + transliterate() method that takes no LanguageType parameter may be used + for a specific module loaded with this method. */ + void loadModuleByImplName( const String& rModuleName, sal_uInt16 nLang ); + + /** This transliteration method corresponds with the loadModuleByImplName() + method. It relies on a module being loaded and does not try load one. + If for any reason the string can't be transliterated the original + string is returned. */ + String transliterate( const String& rStr, + xub_StrLen nStart, xub_StrLen nLen, + ::com::sun::star::uno::Sequence <sal_Int32>* pOffset ) const; + + // Wrapper implementations of class Transliteration + String transliterate( const String& rStr, sal_uInt16 nLanguage, + xub_StrLen nStart, xub_StrLen nLen, + ::com::sun::star::uno::Sequence <sal_Int32>* pOffset ); + + /** If two strings are equal per this transliteration. + Returns the number of matched code points in any case, even if strings + are not equal, for example: + equals( "a", 0, 1, nMatch1, "aaa", 0, 3, nMatch2 ) + returns false and nMatch:=1 and nMatch2:=1 + equals( "aab", 0, 3, nMatch1, "aaa", 0, 3, nMatch2 ) + returns false and nMatch:=2 and nMatch2:=2 + */ + sal_Bool equals( + const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1, + const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const; + + sal_Int32 compareString( const String& rStr1, const String& rStr2 ) const; + + + // helpers + + /** If two strings are really equal as per this translation, and not just + one string is matching the start of the other. Use this method instead + of compareString()==0 because it is much faster. + */ + sal_Bool isEqual( const String& rStr1, const String& rStr2 ) const; + + /** If string rStr1 matches the start of string rStr2, i.e. "a" in "aaa" + */ + sal_Bool isMatch( const String& rStr1, const String& rStr2 ) const; + +}; + +// ............................................................................ +} // namespace utl +// ............................................................................ + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/ucbhelper.hxx b/include/unotools/ucbhelper.hxx new file mode 100644 index 000000000000..fad06ced5e2d --- /dev/null +++ b/include/unotools/ucbhelper.hxx @@ -0,0 +1,76 @@ +/* -*- 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 _UNOTOOLS_UCBHELPER_HXX +#define _UNOTOOLS_UCBHELPER_HXX + +#include "sal/config.h" + +#include "com/sun/star/uno/Sequence.hxx" +#include "sal/types.h" +#include "unotools/unotoolsdllapi.h" + +namespace com { namespace sun { namespace star { namespace uno { + class Any; +} } } } +namespace ucbhelper { class Content; } + +namespace utl { namespace UCBContentHelper { + +UNOTOOLS_DLLPUBLIC bool IsDocument(OUString const & url); + +UNOTOOLS_DLLPUBLIC bool IsFolder(OUString const & url); + +/// @param title must not be null +/// @return true iff title has been set (i.e., if obtaining the "Title" property +/// of the given content yields a non-void value without raising a +/// non-RuntimeException; RuntimeExceptions are passed through) +UNOTOOLS_DLLPUBLIC bool GetTitle( + OUString const & url, OUString * title); + +UNOTOOLS_DLLPUBLIC bool Kill(OUString const & url); + +UNOTOOLS_DLLPUBLIC com::sun::star::uno::Any GetProperty( + OUString const & url, OUString const & property); + +UNOTOOLS_DLLPUBLIC bool MakeFolder( + ucbhelper::Content & parent, OUString const & title, + ucbhelper::Content & result, bool exclusive = false); + +/// @return the value of the "Size" property of the given content, or zero if +/// obtaining the property yields a void value or raises a +/// non-RuntimeException (RuntimeExceptions are passed through) +UNOTOOLS_DLLPUBLIC sal_Int64 GetSize(OUString const & url); + +UNOTOOLS_DLLPUBLIC bool IsYounger( + OUString const & younger, OUString const & older); + +UNOTOOLS_DLLPUBLIC bool Exists(OUString const & url); + +UNOTOOLS_DLLPUBLIC bool IsSubPath( + OUString const & parent, OUString const & child); + +UNOTOOLS_DLLPUBLIC bool EqualURLs( + OUString const & url1, OUString const & url2); + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/ucblockbytes.hxx b/include/unotools/ucblockbytes.hxx new file mode 100644 index 000000000000..cf5d98b93583 --- /dev/null +++ b/include/unotools/ucblockbytes.hxx @@ -0,0 +1,198 @@ +/* -*- 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 _UNTOOLS_UCBLOCKBYTES_HXX +#define _UNTOOLS_UCBLOCKBYTES_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/ucb/XContent.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include "unotools/unotoolsdllapi.h" + +#include <osl/thread.hxx> +#include <osl/conditn.hxx> +#include <osl/mutex.hxx> +#include <tools/stream.hxx> +#include <tools/link.hxx> +#include <tools/errcode.hxx> +#include <tools/datetime.hxx> + +namespace com +{ + namespace sun + { + namespace star + { + namespace task + { + class XInteractionHandler; + } + namespace io + { + class XStream; + class XInputStream; + class XOutputStream; + class XSeekable; + } + namespace ucb + { + class XContent; + } + namespace beans + { + struct PropertyValue; + } + } + } +} + +namespace utl +{ +SV_DECL_REF( UcbLockBytes ) + +class UcbLockBytesHandler : public SvRefBase +{ + sal_Bool m_bActive; +public: + enum LoadHandlerItem + { + DATA_AVAILABLE, + DONE, + CANCEL + }; + + UcbLockBytesHandler() + : m_bActive( sal_True ) + {} + + virtual void Handle( LoadHandlerItem nWhich, UcbLockBytesRef xLockBytes ) = 0; + void Activate( sal_Bool bActivate = sal_True ) { m_bActive = bActivate; } + sal_Bool IsActive() const { return m_bActive; } +}; + +SV_DECL_IMPL_REF( UcbLockBytesHandler ) + +class UNOTOOLS_DLLPUBLIC UcbLockBytes : public virtual SvLockBytes +{ + osl::Condition m_aInitialized; + osl::Condition m_aTerminated; + osl::Mutex m_aMutex; + + String m_aContentType; + String m_aRealURL; + DateTime m_aExpireDate; + + ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInputStream; + ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > m_xOutputStream; + ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable; + void* m_pCommandThread; // is alive only for compatibility reasons + UcbLockBytesHandlerRef m_xHandler; + + sal_uInt32 m_nRead; + sal_uInt32 m_nSize; + ErrCode m_nError; + + sal_Bool m_bTerminated : 1; + sal_Bool m_bDontClose : 1; + sal_Bool m_bStreamValid : 1; + + DECL_LINK( DataAvailHdl, void * ); + + UcbLockBytes( UcbLockBytesHandler* pHandler=NULL ); +protected: + virtual ~UcbLockBytes (void); + +public: + // properties: Referer, PostMimeType + static UcbLockBytesRef CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XContent >& xContent, + const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rProps, + StreamMode eMode, + const ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler >& xInter, + UcbLockBytesHandler* pHandler=0 ); + + static UcbLockBytesRef CreateInputLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xContent ); + static UcbLockBytesRef CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xContent ); + + // SvLockBytes + virtual void SetSynchronMode (sal_Bool bSynchron); + virtual ErrCode ReadAt ( sal_uLong nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const; + virtual ErrCode WriteAt ( sal_uLong, const void*, sal_uLong, sal_uLong *pWritten); + virtual ErrCode Flush (void) const; + virtual ErrCode SetSize (sal_uLong); + virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const; + + void SetError( ErrCode nError ) + { m_nError = nError; } + + ErrCode GetError() const + { return m_nError; } + + // the following properties are available when and after the first DataAvailable callback has been executed + String GetContentType() const; + String GetRealURL() const; + DateTime GetExpireDate() const; + + // calling this method delegates the responsibility to call closeinput to the caller! + ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream(); + + sal_Bool setInputStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > &rxInputStream, + sal_Bool bSetXSeekable = sal_True ); + sal_Bool setStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > &rxStream ); + void terminate_Impl (void); + + ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream_Impl() const + { + osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex ); + return m_xInputStream; + } + + ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > getOutputStream_Impl() const + { + osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex ); + return m_xOutputStream; + } + + ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > getSeekable_Impl() const + { + osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex ); + return m_xSeekable; + } + + sal_Bool hasInputStream_Impl() const + { + osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex ); + return m_xInputStream.is(); + } + + void setDontClose_Impl() + { m_bDontClose = sal_True; } + + void SetContentType_Impl( const String& rType ) { m_aContentType = rType; } + void SetRealURL_Impl( const String& rURL ) { m_aRealURL = rURL; } + void SetExpireDate_Impl( const DateTime& rDateTime ) { m_aExpireDate = rDateTime; } + void SetStreamValid_Impl(); +}; + +SV_IMPL_REF( UcbLockBytes ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/ucbstreamhelper.hxx b/include/unotools/ucbstreamhelper.hxx new file mode 100644 index 000000000000..85de1f36c741 --- /dev/null +++ b/include/unotools/ucbstreamhelper.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 _UNTOOLS_UCBSTREAMHELPER_HXX +#define _UNTOOLS_UCBSTREAMHELPER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XStream.hpp> +#include "unotools/unotoolsdllapi.h" + +#include <tools/stream.hxx> + +namespace com +{ + namespace sun + { + namespace star + { + namespace task + { + class XInteractionHandler; + } + namespace io + { + class XStream; + class XInputStream; + } + } + } +} + +class String; +namespace utl +{ + class UcbLockBytesHandler; + + class UNOTOOLS_DLLPUBLIC UcbStreamHelper : public SvStream + { + public: + static SvStream* CreateStream( const String& rFileName, StreamMode eOpenMode, + UcbLockBytesHandler* pHandler=0 ); + static SvStream* CreateStream( const String& rFileName, StreamMode eOpenMode, + ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler >, + UcbLockBytesHandler* pHandler=0 ); + static SvStream* CreateStream( const String& rFileName, StreamMode eOpenMode, + sal_Bool bFileExists, + UcbLockBytesHandler* pHandler=0 ); + static SvStream* CreateStream( ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > xStream ); + static SvStream* CreateStream( ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > xStream ); + static SvStream* CreateStream( ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > xStream, sal_Bool bCloseStream ); + static SvStream* CreateStream( ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > xStream, sal_Bool bCloseStream ); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/unotoolsdllapi.h b/include/unotools/unotoolsdllapi.h new file mode 100644 index 000000000000..a08f54ce8a5a --- /dev/null +++ b/include/unotools/unotoolsdllapi.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_UNOTOOLSDLLAPI_H +#define INCLUDED_UNOTOOLSDLLAPI_H + +#include "sal/types.h" + +#if defined(UNOTOOLS_DLLIMPLEMENTATION) +#define UNOTOOLS_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define UNOTOOLS_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define UNOTOOLS_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_UNOTOOLSDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/useroptions.hxx b/include/unotools/useroptions.hxx new file mode 100644 index 000000000000..77b71ee90bd1 --- /dev/null +++ b/include/unotools/useroptions.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_unotools_USEROPTIONS_HXX +#define INCLUDED_unotools_USEROPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <unotools/configitem.hxx> +#include <osl/mutex.hxx> +#include <unotools/options.hxx> +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> + +// define ---------------------------------------------------------------- + +#define USER_OPT_CITY ((sal_uInt16)0) +#define USER_OPT_COMPANY ((sal_uInt16)1) +#define USER_OPT_COUNTRY ((sal_uInt16)2) +#define USER_OPT_EMAIL ((sal_uInt16)3) +#define USER_OPT_FAX ((sal_uInt16)4) +#define USER_OPT_FIRSTNAME ((sal_uInt16)5) +#define USER_OPT_LASTNAME ((sal_uInt16)6) +#define USER_OPT_POSITION ((sal_uInt16)7) +#define USER_OPT_STATE ((sal_uInt16)8) +#define USER_OPT_STREET ((sal_uInt16)9) +#define USER_OPT_TELEPHONEHOME ((sal_uInt16)10) +#define USER_OPT_TELEPHONEWORK ((sal_uInt16)11) +#define USER_OPT_TITLE ((sal_uInt16)12) +#define USER_OPT_ID ((sal_uInt16)13) +#define USER_OPT_ZIP ((sal_uInt16)14) +#define USER_OPT_FATHERSNAME ((sal_uInt16)15) +#define USER_OPT_APARTMENT ((sal_uInt16)16) +#define USER_OPT_CUSTOMERNUMBER ((sal_uInt16)17) + +// class SvtUserOptions -------------------------------------------------- + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtUserOptions : public utl::detail::Options +{ +public: + SvtUserOptions (); + virtual ~SvtUserOptions (); + + static osl::Mutex& GetInitMutex (); + + // get the address token + OUString GetCompany () const; + OUString GetFirstName () const; + OUString GetLastName () const; + OUString GetID () const; + OUString GetStreet () const; + OUString GetCity () const; + OUString GetState () const; + OUString GetZip () const; + OUString GetCountry () const; + OUString GetPosition () const; + OUString GetTitle () const; + OUString GetTelephoneHome () const; + OUString GetTelephoneWork () const; + OUString GetFax () const; + OUString GetEmail () const; + OUString GetCustomerNumber () const; + + OUString GetFullName () const; + + // set the address token + void SetCustomerNumber (OUString const&); + + sal_Bool IsTokenReadonly (sal_uInt16 nToken) const; + OUString GetToken (sal_uInt16 nToken) const; + void SetToken (sal_uInt16 nToken, OUString const& rNewToken); + +private: + class Impl; + boost::shared_ptr<Impl> pImpl; + static boost::weak_ptr<Impl> pSharedImpl; +private: + class ChangeListener; +}; + +#endif // #ifndef INCLUDED_unotools_USEROPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/viewoptions.hxx b/include/unotools/viewoptions.hxx new file mode 100644 index 000000000000..8c8986dd4b99 --- /dev/null +++ b/include/unotools/viewoptions.hxx @@ -0,0 +1,318 @@ +/* -*- 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_unotools_VIEWOPTIONS_HXX +#define INCLUDED_unotools_VIEWOPTIONS_HXX + +#include "unotools/unotoolsdllapi.h" +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/NamedValue.hpp> +#include <unotools/configmgr.hxx> +#include <unotools/configitem.hxx> +#include <sal/types.h> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <unotools/options.hxx> + +//_________________________________________________________________________________________________________________ +// forward declarations +//_________________________________________________________________________________________________________________ + +class SvtViewOptionsBase_Impl; + +/*-************************************************************************************************************//** + @descr Use these enum values to specify right list in configuration in which your view data are saved. +*//*-*************************************************************************************************************/ + +enum EViewType +{ + E_DIALOG = 0, + E_TABDIALOG = 1, + E_TABPAGE = 2, + E_WINDOW = 3 +}; + +/*-************************************************************************************************************//** + @short collect information about view features + @descr We support different basetypes of views like dialogs, tab-dialogs, tab-pages and normal windows. + You must specify your basetype by using right enum value and must give us a valid name for your + subkey in registry! We support some fix features for some bastypes and user data as string for all! + see also configuration package "org.openoffice.Office.Views/..." for further information. + + template of configuration: + DialogType + /WindowState [string] + /UserData [set of any scalar types] + TabDialogType + /WindowState [string] + /UserData [set of any scalar types] + /PageID [int] + TabPageType + /WindowState [string] + /UserData [set of any scalar types] + WindowType + /WindowState [string] + /UserData [set of any scalar types] + /Visible [boolean] + + structure of configuration: + + org.openoffice.Office.Views [package] + /Dialogs [set] + /Dialog_FileOpen [DialogType] + /Dialog_ImportGraphics [DialogType] + ... + /Dialog_<YourName> [DialogType] + + /TabDialogs [set] + /TabDialog_001 [TabDialogType] + /TabDialog_Blubber [TabDialogType] + ... + /TabDialog_<YourName> [TabDialogType] + + /TabPages [set] + /TabPage_XXX [TabPageType] + /TabPage_Date [TabPageType] + ... + /TabPage_<YourName> [TabPageType] + + /Windows [set] + /Window_User [WindowType] + /Window_Options [WindowType] + ... + /Window_<YourName> [WindowType] + + @implements - + @base - + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtViewOptions : public utl::detail::Options +{ + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short standard constructor and destructor + @descr This will de-/initialize an instance with default values. + You must give us the basic type of your view and a name which specify right entry + in dynamical configuration list. If entry not exist, we create a new one! + + @seealso enum EViewType + + @param "eType" specify type of your view and is used to use right data container! + @param "sViewName" specify the name of your view and is the key name in data list too. + @return - + + @onerror An assertion is thrown in debug version. Otherwise we do nothing! + *//*-*****************************************************************************************************/ + + SvtViewOptions( EViewType eType , + const OUString& sViewName ); + virtual ~SvtViewOptions(); + + /*-****************************************************************************************************//** + @short support preload of these config item + @descr Sometimes we need preloading of these configuration data without real using of it. + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + static void AcquireOptions(); + static void ReleaseOptions(); + + //--------------------------------------------------------------------------------------------------------- + // interface + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short use it to get information about existing entries in configuration + @descr The methods to set/get the position or size will create a new entry automaticly if + it not already exist and work with default values! + If this a problem for you - you MUST call these method before and + you must make up your own mind about that. + + @seealso - + + @onerror No error should occure. + *//*-*****************************************************************************************************/ + + sal_Bool Exists() const; + + /*-****************************************************************************************************//** + @short use it to delete an entry of dynamic view set + @descr You can use this method to delete anexisting node in configuration. + But if you call a Set- or Get- method again on this instance + the item is created again! If you do nothing after this call + your view will die relay in configuration ... + + @seealso method Exist() + + @return True if delete OK, False otherwise. + + @onerror We return sal_False. + *//*-*****************************************************************************************************/ + + sal_Bool Delete(); + + /*-****************************************************************************************************//** + @short use it to set/get the window state of your view + @descr These value describe position/size and some other states of a window. + Use it with right vcl methods directly. Normaly it's not neccessary to + parse given string! + + @seealso vcl methods + + @onerror - + *//*-*****************************************************************************************************/ + + OUString GetWindowState( ) const; + void SetWindowState( const OUString& sState ); + + /*-****************************************************************************************************//** + @short use it to set/get the page number which was the last active one + @descr It's only supported for: - tab-dialogs + If you call it for other ones you will get an assertion in debug version. + In a product version we do nothing! + + @seealso - + + @onerror An assertion is thrown in debug version. Otherwise we do nothing! + *//*-*****************************************************************************************************/ + + sal_Int32 GetPageID( ) const; + void SetPageID( sal_Int32 nID ); + + /*-****************************************************************************************************//** + @short use it to set/get the visual state of a window + @descr It's only supported for: - windows + If you call it for other ones you will get an assertion in debug version. + In a product version we do nothing! + + @seealso - + + @onerror An assertion is thrown in debug version. Otherwise we do nothing! + *//*-*****************************************************************************************************/ + + sal_Bool IsVisible ( ) const; + void SetVisible( sal_Bool bState ); + + /** Return true if the "Visible" property actually has a non-nil value + + (IsVisible will somewhat arbitrarily return false if the property is + nil.) + */ + bool HasVisible() const; + + /*-****************************************************************************************************//** + @short use it to set/get the extended user data (consisting of a set of named scalar values) + @descr It's supported for ALL types! + Every view can handle its own user defined data set. + + @seealso - + + @onerror In the non-product version, an assertion is made. In a product version, errors are silently ignored. + *//*-*****************************************************************************************************/ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > GetUserData( ) const; + void SetUserData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& lData ); + + /*-****************************************************************************************************//** + @short use it to set/get ONE special user data item directly + @descr Normaly you can work on full user data list by using "Set/GetUserData()". + With this function you have an access on special list entries directly without any + + @seealso - + + @onerror In the non-product version, an assertion is made. In a product version, errors are silently ignored. + *//*-*****************************************************************************************************/ + + ::com::sun::star::uno::Any GetUserItem( const OUString& sName ) const; + void SetUserItem( const OUString& sName , + const ::com::sun::star::uno::Any& aValue ); + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + /*-****************************************************************************************************//** + @short return a reference to a static mutex + @descr These class is threadsafe. + We create a static mutex only for one time and use it to protect our refcount and container + member! + + @seealso - + + @param - + @return A reference to a static mutex member. + + @onerror - + *//*-*****************************************************************************************************/ + + UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex(); + + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + + /// specify which list of views in configuration is used! This can't be a static value!!! + /// ... because we need this value to work with right static data container. + EViewType m_eViewType ; + OUString m_sViewName ; + + /// - impl. data container as dynamic pointer for smaller memory requirements! + /// - internal ref count mechanism + + /*Attention + + Don't initialize these static member in these header! + a) Double defined symbols will be detected ... + b) and unresolved externals exist at linking time. + Do it in your source only. + */ + + static SvtViewOptionsBase_Impl* m_pDataContainer_Dialogs ; /// hold data for all dialogs + static sal_Int32 m_nRefCount_Dialogs ; + static SvtViewOptionsBase_Impl* m_pDataContainer_TabDialogs ; /// hold data for all tab-dialogs + static sal_Int32 m_nRefCount_TabDialogs ; + static SvtViewOptionsBase_Impl* m_pDataContainer_TabPages ; /// hold data for all tab-pages + static sal_Int32 m_nRefCount_TabPages ; + static SvtViewOptionsBase_Impl* m_pDataContainer_Windows ; /// hold data for all windows + static sal_Int32 m_nRefCount_Windows ; + +}; // class SvtViewOptions + +#endif // #ifndef INCLUDED_unotools_VIEWOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/unotools/xmlaccelcfg.hxx b/include/unotools/xmlaccelcfg.hxx new file mode 100644 index 000000000000..d0e15dcfdbec --- /dev/null +++ b/include/unotools/xmlaccelcfg.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_unotools_XMLACCELCFG_HXX +#define INCLUDED_unotools_XMLACCELCFG_HXX + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <cppuhelper/weak.hxx> + +struct SvtAcceleratorConfigItem +{ + sal_uInt16 nCode; + sal_uInt16 nModifier; + OUString aCommand; +}; + +#include <list> +typedef ::std::list < SvtAcceleratorConfigItem > SvtAcceleratorItemList; + + +class OReadAccelatorDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler, + public ::cppu::OWeakObject +{ + public: + OReadAccelatorDocumentHandler( SvtAcceleratorItemList& aNewAcceleratorItemList ) : + m_nElementDepth( 0 ), + m_bAcceleratorMode( sal_False ), + m_bItemCloseExpected( sal_False ), + m_xLocator( 0 ), + m_aReadAcceleratorList( aNewAcceleratorItemList ) {} + virtual ~OReadAccelatorDocumentHandler() {} + + // XInterface + virtual void SAL_CALL acquire() throw() + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw() + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException ); + + // XDocumentHandler + virtual void SAL_CALL startDocument(void) + throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL endDocument(void) + throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL startElement( + const OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL endElement(const OUString& aName) throw + ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL characters(const OUString& aChars) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL processingInstruction( const OUString& aTarget, const OUString& aData ) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setDocumentLocator( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator) + throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + OUString getErrorLineString(); + + int m_nElementDepth; + sal_Bool m_bAcceleratorMode; + sal_Bool m_bItemCloseExpected; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; + SvtAcceleratorItemList& m_aReadAcceleratorList; +}; + + +class OWriteAccelatorDocumentHandler +{ + public: + OWriteAccelatorDocumentHandler( + const SvtAcceleratorItemList& aWriteAcceleratorList, + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > ); + virtual ~OWriteAccelatorDocumentHandler(); + + void WriteAcceleratorDocument() throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + private: + void WriteAcceleratorItem( const SvtAcceleratorConfigItem& aAcceleratorItem ) throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); + + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; + OUString m_aAttributeType; + const SvtAcceleratorItemList& m_aWriteAcceleratorList; +}; + +#endif // INCLUDED_unotools_XMLACCELCFG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |