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/svl | |
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/svl')
88 files changed, 12241 insertions, 0 deletions
diff --git a/include/svl/PasswordHelper.hxx b/include/svl/PasswordHelper.hxx new file mode 100644 index 000000000000..7204ebdc845b --- /dev/null +++ b/include/svl/PasswordHelper.hxx @@ -0,0 +1,46 @@ +/* -*- 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 _SVTOOLS_PASSWORDHELPER_HXX +#define _SVTOOLS_PASSWORDHELPER_HXX + +#include "svl/svldllapi.h" +#include "sal/types.h" +#include "com/sun/star/uno/Sequence.hxx" + +class SvPasswordHelper +{ + static void GetHashPasswordLittleEndian(com::sun::star::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + static void GetHashPasswordBigEndian(com::sun::star::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + +public: + SVL_DLLPUBLIC static void GetHashPassword(com::sun::star::uno::Sequence <sal_Int8>& rPassHash, const sal_Char* pPass, sal_uInt32 nLen); + + SVL_DLLPUBLIC static void GetHashPassword(com::sun::star::uno::Sequence<sal_Int8>& rPassHash, const OUString& sPass); + /** + Use this method to compare a given string with another given Hash value. + This is necessary, because in older versions exists different hashs of the same string. They were endian dependent. + We need this to handle old files. This method will compare against big and little endian. See #101326# + */ + SVL_DLLPUBLIC static bool CompareHashPassword(const com::sun::star::uno::Sequence<sal_Int8>& rOldPassHash, const OUString& sNewPass); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/adrparse.hxx b/include/svl/adrparse.hxx new file mode 100644 index 000000000000..063ba11a95a9 --- /dev/null +++ b/include/svl/adrparse.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 _ADRPARSE_HXX +#define _ADRPARSE_HXX + +#include "svl/svldllapi.h" +#include <vector> + +//============================================================================ +struct SvAddressEntry_Impl +{ + OUString m_aAddrSpec; + OUString m_aRealName; + + SvAddressEntry_Impl() + { + } + + SvAddressEntry_Impl(const OUString& rTheAddrSpec, + const OUString& rTheRealName) + : m_aAddrSpec(rTheAddrSpec) + , m_aRealName(rTheRealName) + { + } +}; + +//============================================================================ +typedef ::std::vector< SvAddressEntry_Impl* > SvAddressList_Impl; + +//============================================================================ +class SVL_DLLPUBLIC SvAddressParser +{ + friend class SvAddressParser_Impl; + + SvAddressEntry_Impl m_aFirst; + SvAddressList_Impl m_aRest; + bool m_bHasFirst; + +public: + SvAddressParser(const OUString& rInput); + + ~SvAddressParser(); + + sal_Int32 Count() const { return m_bHasFirst ? m_aRest.size() + 1 : 0; } + + const OUString& GetEmailAddress(sal_Int32 nIndex) const + { + return nIndex == 0 ? m_aFirst.m_aAddrSpec : + m_aRest[ nIndex - 1 ]->m_aAddrSpec; + } + + const OUString& GetRealName(sal_Int32 nIndex) const + { + return nIndex == 0 ? m_aFirst.m_aRealName : + m_aRest[ nIndex - 1 ]->m_aRealName; + } +}; + +#endif // _ADRPARSE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/aeitem.hxx b/include/svl/aeitem.hxx new file mode 100644 index 000000000000..7dd741592015 --- /dev/null +++ b/include/svl/aeitem.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _AEITEM_HXX +#define _AEITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/poolitem.hxx> +#include <svl/eitem.hxx> +#include <vector> + +class SfxAllEnumValueArr; + +class SVL_DLLPUBLIC SfxAllEnumItem: public SfxEnumItem +{ + SfxAllEnumValueArr* pValues; + std::vector<sal_uInt16>* pDisabledValues; + +protected: + sal_uInt16 _GetPosByValue( sal_uInt16 nValue ) const; + +public: + TYPEINFO(); + SfxAllEnumItem(); + explicit SfxAllEnumItem( sal_uInt16 nWhich); + SfxAllEnumItem( sal_uInt16 nWhich, sal_uInt16 nVal ); + SfxAllEnumItem( sal_uInt16 nWhich, SvStream &rStream ); + SfxAllEnumItem( const SfxAllEnumItem & ); + ~SfxAllEnumItem(); + + void InsertValue( sal_uInt16 nValue ); + void InsertValue( sal_uInt16 nValue, const OUString &rText ); + void RemoveValue( sal_uInt16 nValue ); + + sal_uInt16 GetPosByValue( sal_uInt16 nValue ) const; + + virtual sal_uInt16 GetValueCount() const; + virtual sal_uInt16 GetValueByPos( sal_uInt16 nPos ) const; + virtual OUString GetValueTextByPos( sal_uInt16 nPos ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nVersion) const; + virtual sal_Bool IsEnabled( sal_uInt16 ) const; + void DisableValue( sal_uInt16 ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/asiancfg.hxx b/include/svl/asiancfg.hxx new file mode 100644 index 000000000000..622b1f8ff277 --- /dev/null +++ b/include/svl/asiancfg.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 INCLUDED_SVL_ASIANCFG_HXX +#define INCLUDED_SVL_ASIANCFG_HXX + +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "boost/scoped_ptr.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "sal/types.h" +#include "svl/svldllapi.h" + +namespace com { namespace sun { namespace star { namespace lang { + struct Locale; +} } } } + +class SVL_DLLPUBLIC SvxAsianConfig: private boost::noncopyable { +public: + SvxAsianConfig(); + + ~SvxAsianConfig(); + + void Commit(); + + bool IsKerningWesternTextOnly() const; + + void SetKerningWesternTextOnly(bool value); + + sal_Int16 GetCharDistanceCompression() const; + + void SetCharDistanceCompression(sal_Int16 value); + + com::sun::star::uno::Sequence< com::sun::star::lang::Locale > + GetStartEndCharLocales() const; + + bool GetStartEndChars( + com::sun::star::lang::Locale const & locale, OUString & startChars, + OUString & endChars) const; + + void SetStartEndChars( + com::sun::star::lang::Locale const & locale, + OUString const * startChars, OUString const * endChars); + +private: + struct Impl; + + boost::scoped_ptr< Impl > impl_; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/brdcst.hxx b/include/svl/brdcst.hxx new file mode 100644 index 000000000000..258cf6066e58 --- /dev/null +++ b/include/svl/brdcst.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 _SFXBRDCST_HXX +#define _SFXBRDCST_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> +#include <vector> + +class SfxListener; +class SfxHint; + +//------------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxBroadcaster +{ + friend class SfxListener; + typedef std::vector<SfxListener*> SfxListenerArr_Impl; + + SfxListenerArr_Impl m_Listeners; + +private: + void AddListener( SfxListener& rListener ); + void RemoveListener( SfxListener& rListener ); + const SfxBroadcaster& operator=(const SfxBroadcaster &); // verboten + +protected: + void Forward(SfxBroadcaster& rBC, const SfxHint& rHint); + virtual void ListenersGone(); + +public: + TYPEINFO(); + + SfxBroadcaster(); + SfxBroadcaster( const SfxBroadcaster &rBC ); + virtual ~SfxBroadcaster(); + + void Broadcast( const SfxHint &rHint ); + bool HasListeners() const; + size_t GetListenerCount() const + { + return m_Listeners.size(); + } + SfxListener* GetListener( sal_uInt16 nNo ) const + { + return m_Listeners[nNo]; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/broadcast.hxx b/include/svl/broadcast.hxx new file mode 100644 index 000000000000..ac2931986914 --- /dev/null +++ b/include/svl/broadcast.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SVT_BROADCAST_HXX +#define _SVT_BROADCAST_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> + +class SvtListener; +class SfxHint; +class SvtListenerBase; + +//------------------------------------------------------------------------- + +class SVL_DLLPUBLIC SvtBroadcaster +{ +friend class SvtListener; +friend class SvtListenerBase; +friend class SvtListenerIter; + SvtListenerBase* pRoot; + + const SvtBroadcaster& operator=(const SvtBroadcaster &); // verboten + +protected: + virtual void ListenersGone(); + +public: + TYPEINFO(); + + SvtBroadcaster(); + SvtBroadcaster( const SvtBroadcaster &rBC ); + virtual ~SvtBroadcaster(); + + void Broadcast( const SfxHint &rHint ); + + sal_Bool HasListeners() const { return 0 != pRoot; } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cenumitm.hxx b/include/svl/cenumitm.hxx new file mode 100644 index 000000000000..35024c3a6d44 --- /dev/null +++ b/include/svl/cenumitm.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 . + */ + +#ifndef _SVTOOLS_CENUMITM_HXX +#define _SVTOOLS_CENUMITM_HXX + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <svl/poolitem.hxx> + +//============================================================================ +DBG_NAMEEX(SfxEnumItemInterface) + +class SVL_DLLPUBLIC SfxEnumItemInterface: public SfxPoolItem +{ +protected: + explicit SfxEnumItemInterface(sal_uInt16 which): SfxPoolItem(which) {} + + SfxEnumItemInterface(const SfxEnumItemInterface & rItem): + SfxPoolItem(rItem) {} + +public: + TYPEINFO(); + + virtual int operator ==(const SfxPoolItem & rItem) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any & rVal, sal_uInt8 = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any & rVal, sal_uInt8 = 0); + + virtual sal_uInt16 GetValueCount() const = 0; + + virtual OUString GetValueTextByPos(sal_uInt16 nPos) const; + + virtual sal_uInt16 GetValueByPos(sal_uInt16 nPos) const; + + /// Return the position of some value within this enumeration. + /// + /// @descr This method is implemented using GetValueCount() and + /// GetValueByPos(). Derived classes may replace this with a more + /// efficient implementation. + /// + /// @param nValue Some value. + /// + /// @return The position of nValue within this enumeration, or USHRT_MAX + /// if not included. + virtual sal_uInt16 GetPosByValue(sal_uInt16 nValue) const; + + virtual sal_Bool IsEnabled(sal_uInt16 nValue) const; + + virtual sal_uInt16 GetEnumValue() const = 0; + + virtual void SetEnumValue(sal_uInt16 nValue) = 0; + + virtual int HasBoolValue() const; + + virtual sal_Bool GetBoolValue() const; + + virtual void SetBoolValue(sal_Bool bValue); +}; + +//============================================================================ +DBG_NAMEEX(CntEnumItem) + +class SVL_DLLPUBLIC CntEnumItem: public SfxEnumItemInterface +{ + sal_uInt16 m_nValue; + +protected: + explicit CntEnumItem(sal_uInt16 which = 0, sal_uInt16 nTheValue = 0): + SfxEnumItemInterface(which), m_nValue(nTheValue) {} + + CntEnumItem(sal_uInt16 which, SvStream & rStream); + + CntEnumItem(const CntEnumItem & rItem): + SfxEnumItemInterface(rItem), m_nValue(rItem.m_nValue) {} + +public: + TYPEINFO(); + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual sal_uInt16 GetEnumValue() const; + + virtual void SetEnumValue(sal_uInt16 nTheValue); + + sal_uInt16 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt16 nTheValue); +}; + +inline void CntEnumItem::SetValue(sal_uInt16 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntEnumItem::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +//============================================================================ +DBG_NAMEEX(CntBoolItem) + +class SVL_DLLPUBLIC CntBoolItem: public SfxPoolItem +{ + sal_Bool m_bValue; + +public: + TYPEINFO(); + + explicit CntBoolItem(sal_uInt16 which = 0, sal_Bool bTheValue = sal_False): + SfxPoolItem(which), m_bValue(bTheValue) {} + + CntBoolItem(sal_uInt16 nWhich, SvStream & rStream); + + CntBoolItem(const CntBoolItem & rItem): + SfxPoolItem(rItem), m_bValue(rItem.m_bValue) {} + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 = 0); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_uInt16 GetValueCount() const; + + virtual OUString GetValueTextByVal(sal_Bool bTheValue) const; + + sal_Bool GetValue() const { return m_bValue; } + + void SetValue(sal_Bool bTheValue) { m_bValue = bTheValue; } +}; + +#endif // _SVTOOLS_CENUMITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx new file mode 100644 index 000000000000..e781ada09a35 --- /dev/null +++ b/include/svl/cintitem.hxx @@ -0,0 +1,274 @@ +/* -*- 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 _SVTOOLS_CINTITEM_HXX +#define _SVTOOLS_CINTITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <svl/poolitem.hxx> + +//============================================================================ +DBG_NAMEEX_VISIBILITY(CntByteItem, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC CntByteItem: public SfxPoolItem +{ + sal_uInt8 m_nValue; + +public: + TYPEINFO(); + + CntByteItem(sal_uInt16 which = 0, sal_uInt8 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) { DBG_CTOR(CntByteItem, 0); } + + CntByteItem(const CntByteItem & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(CntByteItem, 0); } + + virtual ~CntByteItem() { DBG_DTOR(CntByteItem, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_uInt8 GetMin() const; + + virtual sal_uInt8 GetMax() const; + + virtual SfxFieldUnit GetUnit() const; + + sal_uInt8 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt8 nTheValue); +}; + +inline void CntByteItem::SetValue(sal_uInt8 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntByteItem::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +//============================================================================ +DBG_NAMEEX_VISIBILITY(CntUInt16Item, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC CntUInt16Item: public SfxPoolItem +{ + sal_uInt16 m_nValue; + +public: + TYPEINFO(); + + CntUInt16Item(sal_uInt16 which = 0, sal_uInt16 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) + { DBG_CTOR(CntUInt16Item, 0); } + + CntUInt16Item(sal_uInt16 which, SvStream & rStream); + + CntUInt16Item(const CntUInt16Item & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(CntUInt16Item, 0); } + + virtual ~CntUInt16Item() { DBG_DTOR(CntUInt16Item, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_uInt16 GetMin() const; + + virtual sal_uInt16 GetMax() const; + + virtual SfxFieldUnit GetUnit() const; + + sal_uInt16 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt16 nTheValue); +}; + +inline void CntUInt16Item::SetValue(sal_uInt16 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntUInt16Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +//============================================================================ +DBG_NAMEEX_VISIBILITY(CntInt32Item, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC CntInt32Item: public SfxPoolItem +{ + sal_Int32 m_nValue; + +public: + TYPEINFO(); + + CntInt32Item(sal_uInt16 which = 0, sal_Int32 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) + { DBG_CTOR(CntInt32Item, 0); } + + CntInt32Item(sal_uInt16 which, SvStream & rStream); + + CntInt32Item(const CntInt32Item & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(CntInt32Item, 0); } + + virtual ~CntInt32Item() { DBG_DTOR(CntInt32Item, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream &, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_Int32 GetMin() const; + + virtual sal_Int32 GetMax() const; + + virtual SfxFieldUnit GetUnit() const; + + sal_Int32 GetValue() const { return m_nValue; } + + inline void SetValue(sal_Int32 nTheValue); +}; + +inline void CntInt32Item::SetValue(sal_Int32 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntInt32Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +//============================================================================ +DBG_NAMEEX_VISIBILITY(CntUInt32Item, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC CntUInt32Item: public SfxPoolItem +{ + sal_uInt32 m_nValue; + +public: + TYPEINFO(); + + CntUInt32Item(sal_uInt16 which = 0, sal_uInt32 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) + { DBG_CTOR(CntUInt32Item, 0); } + + CntUInt32Item(sal_uInt16 nWhich, SvStream & rStream); + + CntUInt32Item(const CntUInt32Item & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(CntUInt32Item, 0); } + + virtual ~CntUInt32Item() { DBG_DTOR(CntUInt32Item, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_uInt32 GetMin() const; + + virtual sal_uInt32 GetMax() const; + + virtual SfxFieldUnit GetUnit() const; + + sal_uInt32 GetValue() const { return m_nValue; } + + inline void SetValue(sal_uInt32 nTheValue); +}; + +inline void CntUInt32Item::SetValue(sal_uInt32 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "CntUInt32Item::SetValue(): Pooled item"); + m_nValue = nTheValue; +} + +#endif // _SVTOOLS_CINTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cjkoptions.hxx b/include/svl/cjkoptions.hxx new file mode 100644 index 000000000000..22055e404b42 --- /dev/null +++ b/include/svl/cjkoptions.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 _SVTOOLS_CJKOPTIONS_HXX +#define _SVTOOLS_CJKOPTIONS_HXX + +#include "svl/svldllapi.h" +#include <sal/types.h> +#include <unotools/options.hxx> + +class SvtCJKOptions_Impl; + +// class SvtCJKOptions -------------------------------------------------- + +class SVL_DLLPUBLIC SvtCJKOptions: public utl::detail::Options +{ +private: + SvtCJKOptions_Impl* pImp; + +public: + + enum EOption + { + E_CJKFONT, + E_VERTICALTEXT, + E_ASIANTYPOGRAPHY, + E_JAPANESEFIND, + E_RUBY, + E_CHANGECASEMAP, + E_DOUBLELINES, + E_EMPHASISMARKS, + E_VERTICALCALLOUT, + E_ALL // special one for IsAnyEnabled()/SetAll() functionality + }; + + // bDontLoad is for referencing purposes only + SvtCJKOptions(sal_Bool bDontLoad = sal_False); + virtual ~SvtCJKOptions(); + + sal_Bool IsCJKFontEnabled() const; + sal_Bool IsVerticalTextEnabled() const; + sal_Bool IsAsianTypographyEnabled() const; + sal_Bool IsJapaneseFindEnabled() const; + sal_Bool IsRubyEnabled() const; + sal_Bool IsChangeCaseMapEnabled() const; + sal_Bool IsDoubleLinesEnabled() const; + + void SetAll(sal_Bool bSet); + sal_Bool IsAnyEnabled() const; + sal_Bool IsReadOnly(EOption eOption) const; +}; + +#endif // _SVTOOLS_CJKOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cntwall.hxx b/include/svl/cntwall.hxx new file mode 100644 index 000000000000..581c558b2575 --- /dev/null +++ b/include/svl/cntwall.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CNTWALL_HXX +#define _CNTWALL_HXX + +#include "svl/svldllapi.h" + +#include <tools/shl.hxx> +#include <tools/rtti.hxx> +#include <tools/color.hxx> +#include <svl/poolitem.hxx> + +class SvStream; + +class SVL_DLLPUBLIC CntWallpaperItem : public SfxPoolItem +{ +private: + OUString _aURL; + Color _nColor; + sal_uInt16 _nStyle; + +public: + TYPEINFO(); + + CntWallpaperItem( sal_uInt16 nWhich ); + CntWallpaperItem( sal_uInt16 nWhich, SvStream& rStream, sal_uInt16 nVersion ); + CntWallpaperItem( const CntWallpaperItem& rCpy ); + ~CntWallpaperItem(); + + virtual sal_uInt16 GetVersion(sal_uInt16) const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nItemVersion ) const; + virtual SvStream& Store( SvStream&, sal_uInt16 nItemVersion ) const; + virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + + void SetBitmapURL( const OUString& rURL ) { _aURL = rURL; } + void SetColor( Color nColor ) { _nColor = nColor; } + void SetStyle( sal_uInt16 nStyle ) { _nStyle = nStyle; } + + const OUString& GetBitmapURL() const { return _aURL; } + Color GetColor() const { return _nColor; } + sal_uInt16 GetStyle() const { return _nStyle; } +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif // _CNTWALL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/cntwids.hrc b/include/svl/cntwids.hrc new file mode 100644 index 000000000000..68a9b3ab3ee5 --- /dev/null +++ b/include/svl/cntwids.hrc @@ -0,0 +1,208 @@ +/* -*- 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 _CNTWIDS_HRC +#define _CNTWIDS_HRC + +//========================================================================= +// ARGS, MSG, ALL, FOLDER, BOXALL, BOXEXT +//========================================================================= + +#define WID_CHAOS_START 500 + +//PROP MSG +#define WID_PRIORITY (WID_CHAOS_START + 15) +#define WID_REPLY_TO (WID_CHAOS_START + 19) +#define WID_IN_REPLY_TO (WID_CHAOS_START + 20) + +#define WID_MESSAGE_ID (WID_CHAOS_START + 21) +#define WID_BCC (WID_CHAOS_START + 22) +#define WID_CC (WID_CHAOS_START + 23) +#define WID_TO (WID_CHAOS_START + 24) +#define WID_FROM (WID_CHAOS_START + 25) +#define WID_TITLE (WID_CHAOS_START + 26) +#define WID_MESSAGEBODY (WID_CHAOS_START + 27) + +#define WID_REFERENCES (WID_CHAOS_START + 28) +#define WID_NEWSGROUPS (WID_CHAOS_START + 29) +#define WID_NEWS_XREFLIST (WID_CHAOS_START + 30) + +#define WID_OUTMSGINTERNALSTATE (WID_CHAOS_START + 31) +#define WID_RECIPIENTLIST (WID_CHAOS_START + 32) + +//PROP ALL +#define WID_CONTENT_TYPE (WID_CHAOS_START + 44) + +#define WID_OWN_URL (WID_CHAOS_START + 45) +#define WID_REAL_URL (WID_CHAOS_START + 46) +#define WID_FLAG_READONLY (WID_CHAOS_START + 48) + +#define WID_FLAG_IS_FOLDER (WID_CHAOS_START + 51) +#define WID_FLAG_HAS_FOLDER (WID_CHAOS_START + 52) +#define WID_FLAG_IS_MESSAGE (WID_CHAOS_START + 53) +#define WID_FLAG_HAS_MESSAGES (WID_CHAOS_START + 54) + +#define WID_DATE_CREATED (WID_CHAOS_START + 55) +#define WID_DATE_MODIFIED (WID_CHAOS_START + 56) +#define WID_IS_READ (WID_CHAOS_START + 58) +#define WID_IS_MARKED (WID_CHAOS_START + 59) + +//PROP FOLDER VIEW +#define WID_THREADING (WID_CHAOS_START + 66) +#define WID_FOLDERVIEW_MODE (WID_CHAOS_START + 69) +#define WID_MESSAGEVIEW_MODE (WID_CHAOS_START + 70) +#define WID_SENTMESSAGEVIEW_MODE (WID_CHAOS_START + 71) +#define WID_THREADED (WID_CHAOS_START + 73) +#define WID_RULES (WID_CHAOS_START + 75) +#define WID_SUBSCRNEWSGROUPCOUNT (WID_CHAOS_START + 76) +#define WID_FLAG_SUBSCRIBED (WID_CHAOS_START + 77) + +//PROP FOLDER DIR +#define WID_TOTALCONTENTCOUNT (WID_CHAOS_START + 80) + +//PROP FOLDER USER +#define WID_SEENCONTENTCOUNT (WID_CHAOS_START + 86) + +//PROP BOXALL +#define WID_USERNAME (WID_CHAOS_START + 91) +#define WID_PASSWORD (WID_CHAOS_START + 92) +#define WID_SERVERNAME (WID_CHAOS_START + 93) +#define WID_SERVERPORT (WID_CHAOS_START + 94) +#define WID_SERVERBASE (WID_CHAOS_START + 101) + +// -> ..._DEFAULT + +#define WID_AUTOUPDATE_INTERVAL (WID_CHAOS_START + 105) +#define WID_UPDATE_ENABLED (WID_CHAOS_START + 106) + +//PROP BOX RNMGR +#define WID_CONNECTION_MODE (WID_CHAOS_START + 107) +#define WID_MESSAGE_STOREMODE (WID_CHAOS_START + 109) +#define WID_DELETE_ON_SERVER (WID_CHAOS_START + 110) + +////////////////////////////////////////////////////////////////////////// +// MISC - Added after initial pool version +////////////////////////////////////////////////////////////////////////// + +// PROP FOLDER +#define WID_SHOW_MSGS_HAS_TIMELIMIT (WID_CHAOS_START + 121) +#define WID_SHOW_MSGS_TIMELIMIT (WID_CHAOS_START + 122) +#define WID_STORE_MSGS_HAS_TIMELIMIT (WID_CHAOS_START + 123) +#define WID_STORE_MSGS_TIMELIMIT (WID_CHAOS_START + 124) + +////////////////////////////////////////////////////////////////////////// +// WIDs added after SO 4.0 release +////////////////////////////////////////////////////////////////////////// + +// PROP BOXALL +#define WID_SEND_PUBLIC_PROT_ID (WID_CHAOS_START + 127) +#define WID_SEND_PRIVATE_PROT_ID (WID_CHAOS_START + 128) +#define WID_SEND_PUBLIC_OUTBOXPROPS (WID_CHAOS_START + 129) +#define WID_SEND_PRIVATE_OUTBOXPROPS (WID_CHAOS_START + 130) +#define WID_SEND_SERVERNAME (WID_CHAOS_START + 131) +#define WID_SEND_USERNAME (WID_CHAOS_START + 132) +#define WID_SEND_PASSWORD (WID_CHAOS_START + 133) +#define WID_SEND_REPLY_TO_DEFAULT (WID_CHAOS_START + 134) +#define WID_SEND_FROM_DEFAULT (WID_CHAOS_START + 135) +#define WID_VIM_POPATH (WID_CHAOS_START + 136) +#define WID_SEND_VIM_POPATH (WID_CHAOS_START + 137) +#define WID_LOCALBASE (WID_CHAOS_START + 142) + +// PROP DOCUMENT +#define WID_DOCUMENT_HEADER (WID_CHAOS_START + 143) +#define WID_DOCUMENT_BODY (WID_CHAOS_START + 144) +#define WID_DOCUMENT_SIZE (WID_CHAOS_START + 145) + +// PROP FSYS +#define WID_FSYS_DISKSPACE_LEFT (WID_CHAOS_START + 148) + +// PROP ALL +#define WID_KEYWORDS (WID_CHAOS_START + 150) + +// PROP SEARCH +#define WID_SEARCH_CRITERIA (WID_CHAOS_START + 152) +#define WID_SEARCH_LOCATIONS (WID_CHAOS_START + 153) +#define WID_SEARCH_RECURSIVE (WID_CHAOS_START + 154) + +// PROP Channel +#define WID_TARGET_URL (WID_CHAOS_START + 159) + +// PROP HTTP +#define WID_HTTP_CONNECTION_LIMIT (WID_CHAOS_START + 161) + +// PROP BOXALL +#define WID_ACCOUNT (WID_CHAOS_START + 172) + +// PROP FSYS +#define WID_FSYS_FLAGS (WID_CHAOS_START + 174) + +// PROP FSYS +#define WID_WHO_IS_MASTER (WID_CHAOS_START + 176) + +// PROP ALL +#define WID_SIZE_LIMIT (WID_CHAOS_START + 179) + +// PROP FOLDER +#define WID_MARKED_DOCUMENT_COUNT (WID_CHAOS_START + 180) +#define WID_FOLDER_COUNT (WID_CHAOS_START + 181) + +// TRASHCAN +#define WID_TRASHCAN_FLAG_AUTODELETE (WID_CHAOS_START + 184) +#define WID_TRASHCAN_FLAG_CONFIRMEMPTY (WID_CHAOS_START + 185) + +// TRASH +#define WID_TRASH_ORIGIN (WID_CHAOS_START + 189) + +// PROP ALL +#define WID_TARGET_FRAMES (WID_CHAOS_START + 191) + +// PROP ALL +#define WID_FLAG_UPDATE_ON_OPEN (WID_CHAOS_START + 213) + +// PROP HTTP +#define WID_HTTP_KEEP_EXPIRED (WID_CHAOS_START + 220) +#define WID_HTTP_VERIFY_MODE (WID_CHAOS_START + 221) +#define WID_HTTP_NOCACHE_LIST (WID_CHAOS_START + 222) +#define WID_HTTP_REFERER (WID_CHAOS_START + 223) + +// PROP HTTP +#define WID_HTTP_COOKIE (WID_CHAOS_START + 231) + +////////////////////////////////////////////////////////////////////////// +// WIDs added after SO 5.0 release +////////////////////////////////////////////////////////////////////////// + +// PROP FOLDER +#define WID_USER_SORT_CRITERIUM (WID_CHAOS_START + 233) + +// PROP FTP +#define WID_FTP_ACCOUNT (WID_CHAOS_START + 243) + +// PROP SEARCH +#define WID_SEARCH_INDIRECTIONS (WID_CHAOS_START + 250) + +// PROP ALL +#define WID_SEND_FORMATS (WID_CHAOS_START + 251) +#define WID_SEND_COPY_TARGET (WID_CHAOS_START + 252) + +// END + +#endif /* !_CNTWIDS_HRC */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/converter.hxx b/include/svl/converter.hxx new file mode 100644 index 000000000000..8f423f786307 --- /dev/null +++ b/include/svl/converter.hxx @@ -0,0 +1,36 @@ +/* -*- 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 _SV_CONVERTER_HXX_ +#define _SV_CONVERTER_HXX_ + +#include "svl/svldllapi.h" +#include <tools/solar.h> + +class SvDbaseConverter +{ +public: + SVL_DLLPUBLIC static sal_Int32 ConvertPrecisionToDbase(sal_Int32 _nLen, sal_Int32 _nScale); + SVL_DLLPUBLIC static sal_Int32 ConvertPrecisionToOdbc(sal_Int32 _nLen, sal_Int32 _nScale); +}; + +#endif //_CONVERTER_HXX_ + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ctloptions.hxx b/include/svl/ctloptions.hxx new file mode 100644 index 000000000000..525e8e73a795 --- /dev/null +++ b/include/svl/ctloptions.hxx @@ -0,0 +1,87 @@ +/* -*- 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 _SVTOOLS_CTLOPTIONS_HXX +#define _SVTOOLS_CTLOPTIONS_HXX + +#include "svl/svldllapi.h" +#include <sal/types.h> +#include <svl/brdcst.hxx> +#include <svl/lstner.hxx> +#include <unotools/options.hxx> + +class SvtCTLOptions_Impl; + +// class SvtCTLOptions -------------------------------------------------------- + +class SVL_DLLPUBLIC SvtCTLOptions : public utl::detail::Options +{ +private: + SvtCTLOptions_Impl* m_pImp; + +public: + + // bDontLoad is for referencing purposes only + SvtCTLOptions( bool bDontLoad = false ); + virtual ~SvtCTLOptions(); + + void SetCTLFontEnabled( bool _bEnabled ); + bool IsCTLFontEnabled() const; + + void SetCTLSequenceChecking( bool _bEnabled ); + bool IsCTLSequenceChecking() const; + + void SetCTLSequenceCheckingRestricted( bool _bEnable ); + bool IsCTLSequenceCheckingRestricted( void ) const; + + void SetCTLSequenceCheckingTypeAndReplace( bool _bEnable ); + bool IsCTLSequenceCheckingTypeAndReplace() const; + + enum CursorMovement + { + MOVEMENT_LOGICAL = 0, + MOVEMENT_VISUAL + }; + void SetCTLCursorMovement( CursorMovement _eMovement ); + CursorMovement GetCTLCursorMovement() const; + + enum TextNumerals + { + NUMERALS_ARABIC = 0, + NUMERALS_HINDI, + NUMERALS_SYSTEM, + NUMERALS_CONTEXT + }; + void SetCTLTextNumerals( TextNumerals _eNumerals ); + TextNumerals GetCTLTextNumerals() const; + + enum EOption + { + E_CTLFONT, + E_CTLSEQUENCECHECKING, + E_CTLCURSORMOVEMENT, + E_CTLTEXTNUMERALS, + E_CTLSEQUENCECHECKINGRESTRICTED, + E_CTLSEQUENCECHECKINGTYPEANDREPLACE + }; + bool IsReadOnly(EOption eOption) const; +}; + +#endif // _SVTOOLS_CTLOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ctypeitm.hxx b/include/svl/ctypeitm.hxx new file mode 100644 index 000000000000..1a783bca78d8 --- /dev/null +++ b/include/svl/ctypeitm.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 _SVTOOLS_CTYPEITM_HXX +#define _SVTOOLS_CTYPEITM_HXX + +#include <svl/inettype.hxx> +#include <svl/custritm.hxx> + +//========================================================================= + +class CntContentTypeItem : public CntUnencodedStringItem +{ +private: + INetContentType _eType; + OUString _aPresentation; + +public: + TYPEINFO(); + + CntContentTypeItem(); + CntContentTypeItem( sal_uInt16 nWhich, const OUString& rType ); + CntContentTypeItem( const CntContentTypeItem& rOrig ); + + virtual SfxPoolItem* Create( SvStream& rStream, + sal_uInt16 nItemVersion ) const; + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual int operator==( const SfxPoolItem& rOrig ) const; + + virtual sal_uInt16 GetVersion(sal_uInt16) const; + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = NULL ) const; + + void SetValue( const OUString& rNewVal ); + + using SfxPoolItem::Compare; + virtual int Compare( const SfxPoolItem &rWith, const IntlWrapper& rIntlWrapper ) const; + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString & rText, + const IntlWrapper* pIntlWrapper = 0 ) const; + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + INetContentType GetEnumValue() const; + + void SetValue( const INetContentType eType ); +}; + +#endif /* !_SVTOOLS_CTYPEITM_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/custritm.hxx b/include/svl/custritm.hxx new file mode 100644 index 000000000000..70948d8fbf43 --- /dev/null +++ b/include/svl/custritm.hxx @@ -0,0 +1,85 @@ +/* -*- 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 _SVTOOLS_CUSTRITM_HXX +#define _SVTOOLS_CUSTRITM_HXX + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <svl/poolitem.hxx> + +//============================================================================ +DBG_NAMEEX_VISIBILITY(CntUnencodedStringItem, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC CntUnencodedStringItem: public SfxPoolItem +{ + OUString m_aValue; + +public: + TYPEINFO(); + + CntUnencodedStringItem(sal_uInt16 which = 0): SfxPoolItem(which) + { DBG_CTOR(CntUnencodedStringItem, 0); } + + CntUnencodedStringItem(sal_uInt16 which, const OUString & rTheValue): + SfxPoolItem(which), m_aValue(rTheValue) + { DBG_CTOR(CntUnencodedStringItem, 0); } + + CntUnencodedStringItem(const CntUnencodedStringItem & rItem): + SfxPoolItem(rItem), m_aValue(rItem.m_aValue) + { DBG_CTOR(CntUnencodedStringItem, 0); } + + virtual ~CntUnencodedStringItem() { DBG_DTOR(CntUnencodedStringItem, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual int Compare(SfxPoolItem const & rWith, + IntlWrapper const & rIntlWrapper) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue(com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0) const; + + virtual bool PutValue(const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0); + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + const OUString & GetValue() const { return m_aValue; } + + inline void SetValue(const OUString & rTheValue); +}; + +inline void CntUnencodedStringItem::SetValue(const OUString & rTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, + "CntUnencodedStringItem::SetValue(): Pooled item"); + m_aValue = rTheValue; +} + +#endif // _SVTOOLS_CUSTRITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/dateitem.hxx b/include/svl/dateitem.hxx new file mode 100644 index 000000000000..043502966ffc --- /dev/null +++ b/include/svl/dateitem.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 _DATETIMEITEM_HXX +#define _DATETIMEITEM_HXX + +#include <tools/rtti.hxx> +#include <tools/datetime.hxx> + +#include <svl/poolitem.hxx> + +class SvStream; + +DBG_NAMEEX(SfxDateTimeItem) + +// class SfxDateTimeItem ------------------------------------------------- + +class SfxDateTimeItem : public SfxPoolItem +{ +private: + DateTime aDateTime; + +public: + TYPEINFO(); + + SfxDateTimeItem( sal_uInt16 nWhich, + const DateTime& rDT ); + SfxDateTimeItem( const SfxDateTimeItem& rCpy ); + + ~SfxDateTimeItem() { + DBG_DTOR(SfxDateTimeItem, 0); } + + virtual int operator==( const SfxPoolItem& ) const; + using SfxPoolItem::Compare; + virtual int Compare( const SfxPoolItem &rWith ) const; + virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nItemVersion ) const; + virtual SvStream& Store( SvStream&, sal_uInt16 nItemVersion ) const; + virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * pIntlWrapper = 0 ) + const; + + const DateTime& GetDateTime() const { return aDateTime; } + void SetDateTime( const DateTime& rDT ) { + DBG_ASSERT( GetRefCount() == 0, + "SetDateTime() with pooled item" ); + aDateTime = rDT; } + + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/documentlockfile.hxx b/include/svl/documentlockfile.hxx new file mode 100644 index 000000000000..437b59fbf127 --- /dev/null +++ b/include/svl/documentlockfile.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SVT_DOCUMENTLOCKFILE_HXX +#define _SVT_DOCUMENTLOCKFILE_HXX + +#include <svl/svldllapi.h> + +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XTruncate.hpp> + +#include <svl/lockfilecommon.hxx> + +namespace svt { + +class SVL_DLLPUBLIC DocumentLockFile : public LockFileCommon +{ + // the workaround for automated testing! + static sal_Bool m_bAllowInteraction; + + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > OpenStream(); + + void WriteEntryToStream( ::com::sun::star::uno::Sequence< OUString > aEntry, ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream ); + +public: + DocumentLockFile( const OUString& aOrigURL ); + ~DocumentLockFile(); + + sal_Bool CreateOwnLockFile(); + ::com::sun::star::uno::Sequence< OUString > GetLockData(); + sal_Bool OverwriteOwnLockFile(); + void RemoveFile(); + + // the methods allow to control whether UI interaction regarding the locked document file is allowed + // this is a workaround for automated tests + static void AllowInteraction( sal_Bool bAllow ) { m_bAllowInteraction = bAllow; } + static sal_Bool IsInteractionAllowed() { return m_bAllowInteraction; } +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx new file mode 100644 index 000000000000..c9c5e389132f --- /dev/null +++ b/include/svl/eitem.hxx @@ -0,0 +1,62 @@ +/* -*- 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 _SFXENUMITEM_HXX +#define _SFXENUMITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/cenumitm.hxx> + +//============================================================================ +class SVL_DLLPUBLIC SfxEnumItem: public CntEnumItem +{ +protected: + explicit SfxEnumItem(sal_uInt16 which = 0, sal_uInt16 nValue = 0): + CntEnumItem(which, nValue) {} + + SfxEnumItem(sal_uInt16 which, SvStream & rStream): + CntEnumItem(which, rStream) {} + +public: + TYPEINFO(); + +}; + +//============================================================================ +class SVL_DLLPUBLIC SfxBoolItem: public CntBoolItem +{ +public: + TYPEINFO(); + + explicit SfxBoolItem(sal_uInt16 which = 0, sal_Bool bValue = sal_False): + CntBoolItem(which, bValue) {} + + SfxBoolItem(sal_uInt16 which, SvStream & rStream): + CntBoolItem(which, rStream) {} + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const + { return new SfxBoolItem(Which(), rStream); } + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxBoolItem(*this); } +}; + +#endif // _SFXENUMITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/filenotation.hxx b/include/svl/filenotation.hxx new file mode 100644 index 000000000000..00c2c16ed77c --- /dev/null +++ b/include/svl/filenotation.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_FILENOTATION_HXX +#define SVTOOLS_FILENOTATION_HXX + +#include "svl/svldllapi.h" +#include <rtl/ustring.hxx> + +//......................................................................... +namespace svt +{ +//......................................................................... + + //===================================================================== + //= OFileNotation + //===================================================================== + class SVL_DLLPUBLIC OFileNotation + { + protected: + OUString m_sSystem; + OUString m_sFileURL; + + public: + enum NOTATION + { + N_SYSTEM, + N_URL + }; + + OFileNotation( const OUString& _rUrlOrPath ); + OFileNotation( const OUString& _rUrlOrPath, NOTATION _eInputNotation ); + + OUString get(NOTATION _eOutputNotation); + + private: + SVL_DLLPRIVATE void construct( const OUString& _rUrlOrPath ); + SVL_DLLPRIVATE bool implInitWithSystemNotation( const OUString& _rSystemPath ); + SVL_DLLPRIVATE bool implInitWithURLNotation( const OUString& _rURL ); + }; + +//......................................................................... +} // namespace svt +//......................................................................... + +#endif // SVTOOLS_FILENOTATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/filerec.hxx b/include/svl/filerec.hxx new file mode 100644 index 000000000000..afc5f4632fd7 --- /dev/null +++ b/include/svl/filerec.hxx @@ -0,0 +1,1031 @@ +/* -*- 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 _SFXFILEREC_HXX +#define _SFXFILEREC_HXX + +//========================================================================= + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <tools/stream.hxx> +#include <vector> + +//------------------------------------------------------------------------ + +#define SFX_REC_PRETAG_EXT sal_uInt8(0x00) // Pre-Tag f"ur Extended-Records +#define SFX_REC_PRETAG_EOR sal_uInt8(0xFF) // Pre-Tag f"ur End-Of-Records + +#define SFX_REC_TYPE_NONE sal_uInt8(0x00) // unbekannter Record-Typ +#define SFX_REC_TYPE_FIRST sal_uInt8(0x01) +#define SFX_REC_TYPE_SINGLE sal_uInt8(0x01) // Single-Content-Record +#define SFX_REC_TYPE_FIXSIZE sal_uInt8(0x02) // Fix-Size-Multi-Content-Record +#define SFX_REC_TYPE_VARSIZE_RELOC sal_uInt8(0x03) // variable Rec-Size +#define SFX_REC_TYPE_VARSIZE sal_uInt8(0x04) // alt (nicht verschiebbar) +#define SFX_REC_TYPE_MIXTAGS_RELOC sal_uInt8(0x07) // Mixed Tag Content-Record +#define SFX_REC_TYPE_MIXTAGS sal_uInt8(0x08) // alt (nicht verschiebbar) +#define SFX_REC_TYPE_LAST sal_uInt8(0x08) +#define SFX_REC_TYPE_MINI 0x100 // Mini-Record +#define SFX_REC_TYPE_DRAWENG 0x400 // Drawing-Engine-Record +#define SFX_REC_TYPE_EOR 0xF00 // End-Of-Records + +//------------------------------------------------------------------------ + +#define SFX_REC_HEADERSIZE_MINI 4 // Gr"o\se des Mini-Record-Headers +#define SFX_REC_HEADERSIZE_SINGLE 4 // zzgl. HEADERSIZE_MINI => 8 +#define SFX_REC_HEADERSIZE_MULTI 6 // zzgl. HEADERSIZE_SINGLE => 14 + +//------------------------------------------------------------------------ + +#ifndef DBG +#ifdef DBG_UTIL +#define DBG(x) x +#else +#define DBG(x) +#endif +#endif + +//------------------------------------------------------------------------ + +/* [Fileformat] + + Jeder Record beginnt mit einem Byte, dem sogenannten 'Pre-Tag'. + + Ist dieses 'Pre-Tag' == 0x00, dann handelt es sich um einen Extended- + Record, dessen Typ durch ein weiteres Byte an Position 5 n�her + beschrieben wird: + + 0x01: SfxSingleRecord + 0x02: SfxMultiFixRecord + 0x03+0x04: SfxMultiVarRecord + 0x07+0x08: SfxMultiMixRecord + (Alle weiteren Record-Typ-Kennungen sind reserviert.) + + I.d.R. werden File-Formate schon aus Performance-Gr"unden so aufgebaut, + da\s beim Lesen jeweils vorher schon feststeht, welcher Record-Typ + vorliegt. Diese Kennung dient daher hautps"achlich der "Uberpr"ufung + und File-Viewern, die das genaue File-Format (unterhalb der Records) + nicht kennen. + + Der 'SfxMiniRecordReader' verf"ugt dazu auch "uber eine statische + Methode 'ScanRecordType()', mit der festgestellt werden kann, welcher + Record-Typ in dem "ubergebenen Stream zu finden ist. + + Ein 'Pre-Tag' mit dem Wert 0xFF ist als Terminator reserviert. + Terminatoren werden verwendet, um das Suchen nach einem speziellen + Record zu terminieren, d.h. ist er bis dorthin nicht gefunden, wird + auch nicht weitergesucht. + + Bei allen anderen Werten des 'Pre-Tags' (also von 0x01 bis 0xFE) + handelt es sich um einen zum SW3 kompatbilen Record, der hier + 'SfxMiniRecord' genannt wird, er kann daher mit einem <SfxMiniRecordReader> + gelesen werden. + + Beginnt ein Record mit 0x44 k"onnte es sich um einen Drawing-Engine- + Record handeln. Dies ist dann der Fall, wenn die folgenden drei Bytes + die Zeichenkette 'RMD' bzw. 'RVW' ergeben (zusammen mit 'D'==0x44 + ergibt dies die K"urzel f"ur 'DRaw-MoDel' bzw. 'DRaw-VieW'). Records + dieser Art k"onnen von den hier dargestellten Klassen weder gelesen, + noch in irgendeiner Weise interpretiert werden. Einzig die Methode + 'ScanRecordType()' kann sie erkennen - weitere Behandlung obliegt + jedoch der Anwendungsprogrammierung. + + Diese drei Bytes an den Positionen 2 bis 4 enthalten normalerweise + die Gr"o\se des Records ohne Pre-Tag und Gr"o\sen-Bytes selbst, + also die Restgr"o\se nach diesem 4-Byte-Header. + + Struktur des Mini-Records: + + 1 sal_uInt8 Pre-Tag + 3 sal_uInt8 OffsetToEndOfRec + OffsetToEndOfRec* 1 sal_uInt8 Content + + Bei den Extended-Reords folgt auf diesen 4-Byte-Header ein erweiterter + Header, der zun"achst den o.g. Record-Typ, dann eine Versions-Kennung + sowie ein Tag enth"alt, welches den Inhalt kennzeichnet. + + Struktur des Extended-Records: + + 1 sal_uInt8 Pre-Tag (==0x00) + 3 sal_uInt8 OffsetToEndOfRec + OffsetToEndOfRec* 1 sal_uInt8 Content + 1 sal_uInt8 Record-Type + 1 sal_uInt8 Version + 2 sal_uInt8 Tag + ContentSize* 1 sal_uInt8 Content + + (ContentSize = OffsetToEndOfRec - 8) + + [Anmerkung] + + Der Aufbau der Records wird wie folgt begr"undet: + + Der SW-Record-Typ war zuerst vorhanden, mu\ste also 1:1 "ubernommen + werden. Zum Gl"uck wurden einige Record-Tags nicht verwendet, (Z.B. + 0x00 und 0xFF). + => 1. Byte 0x00 kann als Kennung f"ur erweiterten Record verwendet werden + => 1. Byte 0xFF kann f"ur besondere Zwecke verwendet werden + + Egal welcher Record-Typ vorliegt, sollte eine Erkennung des Typs, ein + Auslesen des Headers und ein "uberpspringen des Records m"oglich sein, + ohne zu"uck-seeken zu m"ussen und ohne "uberfl"ussige Daten lesen zu + m"ussen. + => die Bytes 2-4 werden bei allen Records als Offset zum Ende des + Records interpretiert, so da\s die Gesamt-Recors-Size sich wie + folgt berechnet: sizeof(sal_uInt32) + OffsetToEndOfRec + + Die Records sollten einfach zu parsen un einheitlich aufgebaut sein. + => Sie bauen aufeinander auf, so ist z.B. der SfxMiniRecord in jedem + anderen enthalten. + + Die Records sollten auch von denen der Drawing Enginge unterscheidbar + sein. Diese beginnen mit 'DRMD' und 'DRVW'. + => Mini-Records mit dem Pre-Tag 'D' d"urfen maximal 4MB gro\s sein, + um nicht in diesen Kennungs-Bereich zu reichen. + + [Erweiterungen] + + Es ist geplant das File-Format so zu erweitern, da\s das High-Nibble + des Record-Typs der erweiterten Records besondere Aufgaben "ubernehmen + soll. Zum Beispiel ist geplant, Record-Contents als 'nur aus Records + bestehend' zu kennzeichnen. Ein File-Viewer k"onnte sich dann automatisch + durch solche Strukturen 'hangeln', ohne Gefahr zu laufen, auf Daten + zu sto\sen, die sich zwar als Records interpretieren lassen, aber + tats"achlis als 'flache' Daten geschrieben wurden. Die m"ogliche + Erweiterung wird schon jetzt insofern vorbereitet, als da\s das + High-Nibble des Typs bei Vergleichen nicht ber"ucksichtigt wird. +*/ + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMiniRecordWriter + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein einfacher Record in einen Stream + geschrieben werden, der sich durch ein sal_uInt8-Tag identifiziert, sowie + seine eigene L"ange speichert und somit auch von "alteren Versionen + bzw. Readern, die diesen Record-Type (Tag) nicht kennen, "ubersprungen + werden kann. Es wird keine Version-Nummer gespeichert. + + Alternativ kann die Gr"o\se fest angegeben werden oder sie wird + automatisch aus der Differenz der Tell()-Angaben vor und nach dem + Streamen des Inhalts ermittelt. + + Um Auf- und Abw"artskompatiblit"at gew"ahrleisten zu k"onnen, m"ussen + neue Versionen die Daten der "alteren immer komplett enthalten, + es d"urfen allenfalls neue Daten hintenan geh"angt werden! + + [Fileformat] + + 1* sal_uInt8 Content-Tag (!= 0) + 1* 3-sal_uInt8 OffsetToEndOfRec in Bytes + SizeOfContent* sal_uInt8 Content + + [Beispiel] + + { + SfxMiniRecordWriter aRecord( pStream, MY_TAG_X ); + *aRecord << aMember1; + *aRecord << aMember2; + } +*/ + +{ +protected: + SvStream* _pStream; // <SvStream>, in dem der Record liegt + sal_uInt32 _nStartPos; // Start-Position des Gesamt-Records im Stream + bool _bHeaderOk; /* TRUE, wenn der Header schon geschrieben ist; */ + sal_uInt8 _nPreTag; // in den Header zu schreibendes 'Pre-Tag' + +public: + inline SfxMiniRecordWriter( SvStream *pStream, + sal_uInt8 nTag ); + inline SfxMiniRecordWriter( SvStream *pStream, sal_uInt8 nTag, + sal_uInt32 nSize ); + + inline ~SfxMiniRecordWriter(); + + inline SvStream& operator*() const; + + inline void Reset(); + + sal_uInt32 Close( bool bSeekToEndOfRec = true ); + +private: + // not implementend, not allowed + SfxMiniRecordWriter( const SfxMiniRecordWriter& ); + SfxMiniRecordWriter& operator=(const SfxMiniRecordWriter&); +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMiniRecordReader + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein einfacher Record aus einem Stream + gelesen werden, der mit der Klasse <SfxRecordWriter> geschrieben wurde. + + Es ist auch m"oglich, den Record zu "uberspringen, ohne sein internes + Format zu kennen. + + [Beispiel] + + { + SfxMiniRecordReader aRecord( pStream ); + switch ( aRecord.GetTag() ) + { + case MY_TAG_X: + *aRecord >> aMember1; + *aRecord >> aMember2; + break; + + ... + } + } +*/ + +{ +protected: + SvStream* _pStream; // <SvStream>, aus dem gelesen wird + sal_uInt32 _nEofRec; // Position direkt hinter dem Record + bool _bSkipped; // TRUE: der Record wurde explizit geskippt + sal_uInt8 _nPreTag; // aus dem Header gelesenes Pre-Tag + + // Drei-Phasen-Ctor f"ur Subklassen + SfxMiniRecordReader() {} + void Construct_Impl( SvStream *pStream, sal_uInt8 nTag ) + { + _pStream = pStream; + _bSkipped = sal_False; + _nPreTag = nTag; + } + inline bool SetHeader_Impl( sal_uInt32 nHeader ); + + // als ung"ultig markieren und zur"uck-seeken + void SetInvalid_Impl( sal_uInt32 nRecordStartPos ) + { + _nPreTag = SFX_REC_PRETAG_EOR; + _pStream->Seek( nRecordStartPos ); + } + +public: + SfxMiniRecordReader( SvStream *pStream, sal_uInt8 nTag ); + inline ~SfxMiniRecordReader(); + + inline sal_uInt8 GetTag() const; + inline bool IsValid() const; + + inline SvStream& operator*() const; + + inline void Skip(); + +private: + // not implementend, not allowed + SfxMiniRecordReader( const SfxMiniRecordReader& ); + SfxMiniRecordReader& operator=(const SfxMiniRecordReader&); +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxSingleRecordWriter: public SfxMiniRecordWriter + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein Record in einen Stream geschrieben + werden, dessen einziger Inhalt sich durch ein sal_uInt16-Tag und eine + sal_uInt8-Versions-Nummer identifiziert, sowie seine eigene L"ange speichert + und somit auch von "alteren Versionen bzw. Readern, die diesen + Record-Type (Tag) nicht kennen, "ubersprungen werden kann. + + Alternativ kann die Gr"o\se fest angegeben werden oder sie wird + automatisch aus der Differenz der Tell()-Angaben vor und nach dem + Streamen des Inhalts ermittelt. + + Um Auf- und Abw"artskompatiblit"at gew"ahrleisten zu k"onnen, m"ussen + neue Versionen die Daten der "alteren immer komplett enthalten, + es d"urfen allenfalls neue Daten hintenan geh"angt werden! + + [Fileformat] + + 1* sal_uInt8 Pre-Tag (!= 0) + 1* 3-sal_uInt8 OffsetToEndOfRec in Bytes + 1* sal_uInt8 Record-Type (==SFX_REC_TYPE_SINGLE) + 1* sal_uInt8 Content-Version + 1* sal_uInt16 Content-Tag + SizeOfContent* sal_uInt8 Content +*/ + +{ +protected: + SfxSingleRecordWriter( sal_uInt8 nRecordType, + SvStream *pStream, + sal_uInt16 nTag, sal_uInt8 nCurVer ); + +public: + inline void Reset(); + + sal_uInt32 Close( bool bSeekToEndOfRec = true ); +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxSingleRecordReader: public SfxMiniRecordReader + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein einfacher Record aus einem Stream + gelesen werden, der mit der Klasse <SfxSingleRecordWriter> geschrieben + wurde. + + Es ist auch m"oglich, den Record zu "uberspringen, ohne sein internes + Format zu kennen. +*/ + +{ +protected: + sal_uInt16 _nRecordTag; // Art des Gesamt-Inhalts + sal_uInt8 _nRecordVer; // Version des Gesamt-Inhalts + sal_uInt8 _nRecordType; // Record Type aus dem Header + + // Drei-Phasen-Ctor f"ur Subklassen + SfxSingleRecordReader() {} + void Construct_Impl( SvStream *pStream ) + { + SfxMiniRecordReader::Construct_Impl( + pStream, SFX_REC_PRETAG_EXT ); + } + bool FindHeader_Impl( sal_uInt16 nTypes, sal_uInt16 nTag ); + bool ReadHeader_Impl( sal_uInt16 nTypes ); + +public: + + inline sal_uInt16 GetTag() const; + + inline sal_uInt8 GetVersion() const; + inline bool HasVersion( sal_uInt16 nVersion ) const; +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMultiFixRecordWriter: public SfxSingleRecordWriter + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein Record in einen Stream geschrieben + werden, der seine eigene L"ange speichert und somit auch von "alteren + Versionen bzw. Readern, die diesen Record-Type (Tag) nicht kennen, + "ubersprungen werden kann. + + Er enth"alt mehrere Inhalte von demselben Typ (Tag) und derselben + Version, die einmalig (stellvertretend f"ur alle) im Header des Records + identifiziert werden. Alle Inhalte haben eine vorher bekannte und + identische L"ange. + + Um Auf- und Abw"artskompatiblit"at gew"ahrleisten zu k"onnen, m"ussen + neue Versionen die Daten der "alteren immer komplett enthalten, + es d"urfen allenfalls neue Daten hinten angeh"angt werden! Hier sind + damit selbstverst"andlich nur die Daten der einzelnen Inhalte gemeint, + die Anzahl der Inhalte ist selbstverst"andlich variabel und sollte + von lesenden Applikationen auch so behandelt werden. + + [Fileformat] + + 1* sal_uInt8 Pre-Tag (==0) + 1* 3-sal_uInt8 OffsetToEndOfRec in Bytes + 1* sal_uInt8 Record-Type (==SFX_REC_TYPE_FIXSIZE) + 1* sal_uInt8 Content-Version + 1* sal_uInt16 Content-Tag + 1* sal_uInt16 NumberOfContents + 1* sal_uInt32 SizeOfEachContent + NumberOfContents* ( + SizeOfEachContent sal_uInt8 Content + ) + + [Beispiel] + + { + SfxMultiFixRecordWriter aRecord( pStream, MY_TAG_X, MY_VERSION ); + for ( sal_uInt16 n = 0; n < Count(); ++n ) + { + aRecord.NewContent(); + *aRecord << aMember1[n]; + *aRecord << aMember2[n]; + } + } +*/ + +{ +protected: + sal_uInt32 _nContentStartPos; /* Startposition des jeweiligen + Contents - nur bei DBG_UTIL + und f"ur Subklassen */ + sal_uInt32 _nContentSize; // Gr"o\se jedes Contents + sal_uInt16 _nContentCount; // jeweilige Anzahl der Contents + + SfxMultiFixRecordWriter( sal_uInt8 nRecordType, + SvStream *pStream, + sal_uInt16 nTag, + sal_uInt8 nCurVer ); + +public: + inline ~SfxMultiFixRecordWriter(); + + inline void NewContent(); + + inline void Reset(); + + sal_uInt32 Close( bool bSeekToEndOfRec = true ); +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMultiVarRecordWriter: public SfxMultiFixRecordWriter + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein Record in einen Stream geschrieben + werden, der seine eigene L"ange speichert und somit auch von "alteren + Versionen bzw. Readern, die diesen Record-Type (Tag) nicht kennen, + "ubersprungen werden kann. + + Er enth"alt mehrere Inhalte von demselben Typ (Tag) und derselben + Version, die einmalig (stellvertretend f"ur alle) im Header des Records + identifiziert werden. Die L"ange f"ur jeden einzelnen Inhalt wird + automatisch berechnet und gespeichert, so da\s auch einzelne Inhalte + "ubersprungen werden k"onnen, ohne sie interpretieren zu m"ussen. + + Um Auf- und Abw"artskompatiblit"at gew"ahrleisten zu k"onnen, m"ussen + neue Versionen die Daten der "alteren immer komplett enthalten, + es d"urfen allenfalls neue Daten hinten angeh"angt werden! + + [Fileformat] + + 1* sal_uInt8 Pre-Tag (==0) + 1* 3-sal_uInt8 OffsetToEndOfRec in Bytes + 1* sal_uInt8 Record-Type (==SFX_FILETYPE_TYPE_VARSIZE) + 1* sal_uInt8 Content-Version + 1* sal_uInt16 Content-Tag + 1* sal_uInt16 NumberOfContents + 1* sal_uInt32 OffsetToOfsTable + NumberOfContents* ( + ContentSize* sal_uInt8 Content + ) + NumberOfContents* sal_uInt32 ContentOfs (je per <<8 verschoben) + + [Beispiel] + + { + SfxMultiVarRecordWriter aRecord( pStream, MY_TAG_X, MY_VERSION ); + for ( sal_uInt16 n = 0; n < Count(); ++n ) + { + aRecord.NewContent(); + *aRecord << aMember1[n]; + *aRecord << aMember2[n]; + } + } +*/ + +{ +protected: + std::vector<sal_uInt32> _aContentOfs; + sal_uInt16 _nContentVer; // nur f"ur SfxMultiMixRecordWriter + + SfxMultiVarRecordWriter( sal_uInt8 nRecordType, + SvStream *pStream, + sal_uInt16 nRecordTag, + sal_uInt8 nRecordVer ); + + void FlushContent_Impl(); + +public: + SfxMultiVarRecordWriter( SvStream *pStream, + sal_uInt16 nRecordTag, + sal_uInt8 nRecordVer ); + virtual ~SfxMultiVarRecordWriter(); + + void NewContent(); + + virtual sal_uInt32 Close( bool bSeekToEndOfRec = true ); +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMultiMixRecordWriter: public SfxMultiVarRecordWriter + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein Record in einen Stream geschrieben + werden, der seine eigene L"ange speichert und somit auch von "alteren + Versionen bzw. Readern, die diesen Record-Type (Tag) nicht kennen, + "ubersprungen werden kann. + + Er enth"alt mehrere Inhalte von demselben Typ (Tag) und derselben + Version, die einmalig (stellvertretend f"ur alle) im Header des Records + identifiziert werden. Alle Inhalte haben eine vorher bekannte und + identische L"ange. + + Um Auf- und Abw"artskompatiblit"at gew"ahrleisten zu k"onnen, m"ussen + neue Versionen die Daten der "alteren immer komplett enthalten, + es d"urfen allenfalls neue Daten hinten angeh"angt werden! + + [Fileformat] + + 1* sal_uInt8 Pre-Tag (==0) + 1* 3-sal_uInt8 OffsetToEndOfRec in Bytes + 1* sal_uInt8 Record-Type (==SFX_REC_TYPE_MIXTAGS) + 1* sal_uInt8 Content-Version + 1* sal_uInt16 Record-Tag + 1* sal_uInt16 NumberOfContents + 1* sal_uInt32 OffsetToOfsTable + NumberOfContents* ( + 1* sal_uInt16 Content-Tag + ContentSize* sal_uInt8 Content + ) + NumberOfContents* sal_uInt32 ( ContentOfs << 8 + Version ) +*/ + +{ +public: + inline SfxMultiMixRecordWriter( SvStream *pStream, + sal_uInt16 nRecordTag, + sal_uInt8 nRecordVer ); + + void NewContent( sal_uInt16 nTag, sal_uInt8 nVersion ); + +// private: geht nicht, da einige Compiler dann auch vorherige privat machen + void NewContent() + { OSL_FAIL( "NewContent() only allowed with args" ); } +}; + +//------------------------------------------------------------------------ + +class SVL_DLLPUBLIC SfxMultiRecordReader: public SfxSingleRecordReader + +/* [Beschreibung] + + Mit Instanzen dieser Klasse kann ein aus mehreren Contents bestehender + Record aus einem Stream gelesen werden, der mit einer der Klassen + <SfxMultiFixRecordWriter>, <SfxMultiVarRecordWriter> oder + <SfxMultiMixRecordWriter> geschrieben wurde. + + Es ist auch m"oglich, den Record oder einzelne Contents zu "uberspringen, + ohne das jeweilis interne Format zu kennen. + + [Beispiel] + + { + SfxMultiRecordReader aRecord( pStream ); + for ( sal_uInt16 nRecNo = 0; aRecord.GetContent(); ++nRecNo ) + { + switch ( aRecord.GetTag() ) + { + case MY_TAG_X: + X *pObj = new X; + *aRecord >> pObj.>aMember1; + if ( aRecord.HasVersion(2) ) + *aRecord >> pObj->aMember2; + Append( pObj ); + break; + + ... + } + } + } +*/ + +{ + sal_uInt32 _nStartPos; // Start-Position des Records + sal_uInt32* _pContentOfs; // Offsets der Startpositionen + sal_uInt32 _nContentSize; // Size jedes einzelnen / Tabellen-Pos + sal_uInt16 _nContentCount; // Anzahl der Contents im Record + sal_uInt16 _nContentNo; /* der Index des aktuellen Contents + enth"alt jeweils den Index des + Contents, der beim n"achsten + GetContent() geholt wird */ + sal_uInt16 _nContentTag; // Art-Kennung des aktuellen Contents + sal_uInt8 _nContentVer; // Versions-Kennung des akt. Contents + + bool ReadHeader_Impl(); + +public: + SfxMultiRecordReader( SvStream *pStream, sal_uInt16 nTag ); + ~SfxMultiRecordReader(); + + bool GetContent(); + inline sal_uInt16 GetContentTag(); + inline sal_uInt8 GetContentVersion() const; + inline bool HasContentVersion( sal_uInt16 nVersion ) const; + + inline sal_uInt32 ContentCount() const; +}; + +//========================================================================= + +inline SfxMiniRecordWriter::SfxMiniRecordWriter +( + SvStream* pStream, // Stream, in dem der Record angelegt wird + sal_uInt8 nTag // Record-Tag zwischen 0x01 und 0xFE +) + +/* [Beschreibung] + + Legt in 'pStream' einen 'SfxMiniRecord' an, dessen Content-Gr"o\se + nicht bekannt ist, sondern nach dam Streamen des Contents errechnet + werden soll. +*/ + +: _pStream( pStream ), + _nStartPos( pStream->Tell() ), + _bHeaderOk(false), + _nPreTag( nTag ) +{ + DBG_ASSERT( _nPreTag != 0xFF, "invalid Tag" ); + DBG( DbgOutf( "SfxFileRec: writing record to %ul", pStream->Tell() ) ); + + pStream->SeekRel( + SFX_REC_HEADERSIZE_MINI ); +} + +//------------------------------------------------------------------------- + +inline SfxMiniRecordWriter::SfxMiniRecordWriter +( + SvStream* pStream, // Stream, in dem der Record angelegt wird + sal_uInt8 nTag, // Record-Tag zwischen 0x01 und 0xFE + sal_uInt32 nSize // Gr"o\se der Daten in Bytes +) + +/* [Beschreibung] + + Legt in 'pStream' einen 'SfxMiniRecord' an, dessen Content-Gr"o\se + von vornherein bekannt ist. +*/ + +: _pStream( pStream ), + // _nTag( uninitialized ), + // _nStarPos( uninitialized ), + _bHeaderOk(true) +{ + DBG_ASSERT( nTag != 0 && nTag != 0xFF, "invalid Tag" ); + DBG(_nStartPos = pStream->Tell()); + DBG( DbgOutf( "SfxFileRec: writing record to %ul", _nStartPos ) ); + + *pStream << ( ( nTag << 24 ) | nSize ); +} + +//------------------------------------------------------------------------- + +inline SfxMiniRecordWriter::~SfxMiniRecordWriter() + +/* [Beschreibung] + + Der Dtor der Klasse <SfxMiniRecordWriter> schlie\st den Record + automatisch, falls <SfxMiniRecordWriter::Close()> nicht bereits + explizit gerufen wurde. +*/ + +{ + // wurde der Header noch nicht geschrieben oder mu\s er gepr"uft werden + if ( !_bHeaderOk ) + Close(); +} + +//------------------------------------------------------------------------- + +inline SvStream& SfxMiniRecordWriter::operator*() const + +/* [Beschreibung] + + Dieser Operator liefert den Stream, in dem der Record liegt. + Der Record darf noch nicht geschlossen worden sein. +*/ + +{ + DBG_ASSERT( !_bHeaderOk, "getting Stream of closed record" ); + return *_pStream; +} + +//------------------------------------------------------------------------- + +inline void SfxMiniRecordWriter::Reset() +{ + _pStream->Seek( _nStartPos + SFX_REC_HEADERSIZE_MINI ); + _bHeaderOk = false; +} + +//========================================================================= + +inline SfxMiniRecordReader::~SfxMiniRecordReader() + +/* [Beschreibung] + + Der Dtor der Klasse <SfxMiniRecordReader> positioniert den Stream + automatisch auf die Position direkt hinter dem Record, falls nicht + <SfxMiniRecordReader::Skip()> bereits explizit gerufen wurde. +*/ + +{ + // noch nicht explizit ans Ende gesprungen? + if ( !_bSkipped ) + Skip(); +} + +//------------------------------------------------------------------------- + +inline void SfxMiniRecordReader::Skip() + +/* [Beschreibung] + + Mit dieser Methode wird der Stream direkt hinter das Ende des Records + positioniert. +*/ + +{ + _pStream->Seek(_nEofRec); + _bSkipped = sal_True; +} + +//------------------------------------------------------------------------- + +inline sal_uInt8 SfxMiniRecordReader::GetTag() const + +/* [Beschreibung] + + Liefert des aus dem Header gelesene Pre-Tag des Records. Dieses kann + auch SFX_REC_PRETAG_EXT oder SFX_REC_PRETAG_EOR sein, im + letzteren Fall ist am Stream der Fehlercode ERRCODE_IO_WRONGFORMAT + gesetzt. SFX_REC_PRETAG_EXT ist g"ultig, da diese extended-Records + nur eine Erweiterung des SfxMiniRecord darstellen. +*/ + +{ + return _nPreTag; +} + +//------------------------------------------------------------------------- + +inline bool SfxMiniRecordReader::IsValid() const + +/* [Beschreibung] + + Hiermit kann abgefragt werden, ob der Record erfolgreich aus dem + Stream konstruiert werden konnte, der Header also f"ur diesen Record-Typ + passend war. +*/ + +{ + return _nPreTag != SFX_REC_PRETAG_EOR; +} + +//------------------------------------------------------------------------- + +inline SvStream& SfxMiniRecordReader::operator*() const + +/* [Beschreibung] + + Dieser Operator liefert den Stream in dem der Record liegt. + Die aktuelle Position des Streams mu\s innerhalb des Records liegen. +*/ + +{ + DBG_ASSERT( _pStream->Tell() < _nEofRec, "read behind record" ); + return *_pStream; +} + +//========================================================================= + +inline sal_uInt32 SfxSingleRecordWriter::Close( bool bSeekToEndOfRec ) + +// siehe <SfxMiniRecordWriter::Close(bool)> + +{ + sal_uInt32 nRet = 0; + + // wurde der Header noch nicht geschrieben? + if ( !_bHeaderOk ) + { + // Basisklassen-Header schreiben + sal_uInt32 nEndPos = SfxMiniRecordWriter::Close( bSeekToEndOfRec ); + + // ggf. ans Ende des eigenen Headers seeken oder hinter Rec bleiben + if ( !bSeekToEndOfRec ) + _pStream->SeekRel( SFX_REC_HEADERSIZE_SINGLE ); + nRet = nEndPos; + } +#ifdef DBG_UTIL + else + // Basisklassen-Header pr"ufen + SfxMiniRecordWriter::Close( bSeekToEndOfRec ); +#endif + + // Record war bereits geschlossen +// nRet = 0; + return nRet; +} + +//------------------------------------------------------------------------- + +inline void SfxSingleRecordWriter::Reset() +{ + _pStream->Seek( _nStartPos + SFX_REC_HEADERSIZE_MINI + + SFX_REC_HEADERSIZE_SINGLE ); + _bHeaderOk = false; +} + +//========================================================================= + +inline sal_uInt16 SfxSingleRecordReader::GetTag() const + +/* [Beschreibung] + + Liefert des aus dem Header gelesene Tag f"ur den Gesamt-Record. +*/ + +{ + return _nRecordTag; +} + +//------------------------------------------------------------------------- + +inline sal_uInt8 SfxSingleRecordReader::GetVersion() const + +/* [Beschreibung] + + Liefert die Version des aus dem Stream gelesenen Records. +*/ + +{ + return _nRecordVer; +} + +//------------------------------------------------------------------------- + +inline bool SfxSingleRecordReader::HasVersion( sal_uInt16 nVersion ) const + +/* [Beschreibung] + + Stellt fest, ob der aus dem Stream gelese Record in der Version + 'nVersion' oder h"oher vorliegt. +*/ + +{ + return _nRecordVer >= nVersion; +} + +//========================================================================= + +inline SfxMultiFixRecordWriter::~SfxMultiFixRecordWriter() + +/* [Beschreibung] + + Der Dtor der Klasse <SfxMultiFixRecordWriter> schlie\st den Record + automatisch, falls <SfxMutiFixRecordWriter::Close()> nicht bereits + explizit gerufen wurde. +*/ + +{ + // wurde der Header noch nicht geschrieben oder mu\s er gepr"uft werden + if ( !_bHeaderOk ) + Close(); +} + +//------------------------------------------------------------------------- + +inline void SfxMultiFixRecordWriter::NewContent() + +/* [Beschreibung] + + Mit dieser Methode wird in den Record ein neuer Content eingef"ugt. + Jeder, auch der 1. Record mu\s durch Aufruf dieser Methode eingeleitet + werden. +*/ + +{ + #ifdef DBG_UTIL + sal_uLong nOldStartPos; + // Startposition des aktuellen Contents merken - Achtung Subklassen! + nOldStartPos = _nContentStartPos; + #endif + _nContentStartPos = _pStream->Tell(); + +#ifdef DBG_UTIL + // ist ein vorhergehender Content vorhanden? + if ( _nContentCount ) + { + // pr"ufen, ob der vorhergehende die Soll-Gr"o\se eingehalten hat + DBG_ASSERT( _nContentStartPos - nOldStartPos == _nContentSize, + "wrong content size detected" ); + } +#endif + + // Anzahl mitz"ahlen + ++_nContentCount; +} + +//========================================================================= + +inline SfxMultiMixRecordWriter::SfxMultiMixRecordWriter +( + SvStream* pStream, // Stream, in dem der Record angelegt wird + sal_uInt16 nRecordTag, // Gesamt-Record-Art-Kennung + sal_uInt8 nRecordVer // Gesamt-Record-Versions-Kennung +) + +/* [Beschreibung] + + Legt in 'pStream' einen 'SfxMultiMixRecord' an, f"ur dessen Contents + je eine separate Kennung f"ur Art (Tag) und Version gespeichert wird. + Die Gr"o\sen der einzelnen Contents werden automatisch ermittelt. +*/ + +: SfxMultiVarRecordWriter( SFX_REC_TYPE_MIXTAGS, + pStream, nRecordTag, nRecordVer ) +{ +} + +//========================================================================= + +inline void SfxMultiFixRecordWriter::Reset() +{ + _pStream->Seek( _nStartPos + SFX_REC_HEADERSIZE_MINI + + SFX_REC_HEADERSIZE_SINGLE + + SFX_REC_HEADERSIZE_MULTI ); + _bHeaderOk = false; +} + +//========================================================================= + +inline sal_uInt16 SfxMultiRecordReader::GetContentTag() + +/* [Beschreibung] + + Diese Methode liefert die Art-Kennung des zuletzt mit der Methode + <SfxMultiRecordReder::GetContent()> ge"offneten Contents. +*/ + +{ + return _nContentTag; +} + +//------------------------------------------------------------------------- + +inline sal_uInt8 SfxMultiRecordReader::GetContentVersion() const + +/* [Beschreibung] + + Diese Methode liefert die Version-Kennung des zuletzt mit der Methode + <SfxMultiRecordReder::GetContent()> ge"offneten Contents. +*/ + +{ + return _nContentVer; +} + +//------------------------------------------------------------------------- + +inline bool SfxMultiRecordReader::HasContentVersion( sal_uInt16 nVersion ) const + +/* [Beschreibung] + + Diese Methode stellt fest, ob die Version 'nVersion' in der Version des + zuletzt mit der Methode <SfxMultiRecordReder::GetContent()> ge"offneten + Contents enthalten ist. +*/ + +{ + return _nContentVer >= nVersion; +} + +//------------------------------------------------------------------------- + +inline sal_uInt32 SfxMultiRecordReader::ContentCount() const + +/* [Beschreibung] + + Diese Methode liefert die Anzahl im Record befindlichen Contents. +*/ + +{ + return _nContentCount; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/flagitem.hxx b/include/svl/flagitem.hxx new file mode 100644 index 000000000000..6b0c88ef8f7e --- /dev/null +++ b/include/svl/flagitem.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SFXFLAGITEM_HXX +#define _SFXFLAGITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <tools/rtti.hxx> +#include <svl/poolitem.hxx> + +class SvStream; + +// ----------------------------------------------------------------------- + +DBG_NAMEEX_VISIBILITY(SfxFlagItem, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC SfxFlagItem: public SfxPoolItem +{ + sal_uInt16 nVal; + +public: + TYPEINFO(); + + explicit SfxFlagItem( sal_uInt16 nWhich = 0, sal_uInt16 nValue = 0 ); + SfxFlagItem( const SfxFlagItem& ); + + ~SfxFlagItem() { + DBG_DTOR(SfxFlagItem, 0); } + + virtual sal_uInt8 GetFlagCount() const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nVersion) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion) const; + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString & rText, + const IntlWrapper * = 0 ) const; + sal_uInt16 GetValue() const { return nVal; } + void SetValue( sal_uInt16 nNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + nVal = nNewVal; + } + bool GetFlag( sal_uInt8 nFlag ) const { return ( (nVal & ( 1<<nFlag))); } + void SetFlag( sal_uInt8 nFlag, bool bVal ) { if(bVal) { nVal |= (1<<nFlag); } else { nVal &= ~(1<<nFlag);};} +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/folderrestriction.hxx b/include/svl/folderrestriction.hxx new file mode 100644 index 000000000000..4ddb9d4be7bc --- /dev/null +++ b/include/svl/folderrestriction.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 SVTOOLS_FOLDER_RESTRICTION_HXX +#define SVTOOLS_FOLDER_RESTRICTION_HXX + +#include "svl/svldllapi.h" +#include <tools/string.hxx> + +#include <vector> + +//........................................................................ +namespace svt +{ +//........................................................................ + + /** retrieves a list of folders which's access is not restricted. + + <p>Note that this is not meant as security feature, but only as + method to restrict some UI presentation, such as browsing + in the file open dialog.</p> + */ + SVL_DLLPUBLIC void getUnrestrictedFolders( ::std::vector< String >& _rFolders ); + +//........................................................................ +} // namespace svt +//........................................................................ + +#endif // SVTOOLS_FOLDER_RESTRICTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/fstathelper.hxx b/include/svl/fstathelper.hxx new file mode 100644 index 000000000000..9e69c6ed28ec --- /dev/null +++ b/include/svl/fstathelper.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 . + */ + +#ifndef _SVTOOLS_FSTATHELPER_HXX +#define _SVTOOLS_FSTATHELPER_HXX + +#include "svl/svldllapi.h" +#include <rtl/ustring.hxx> +#include <tools/solar.h> + +class Date; +class Time; + +namespace FStatHelper { + +/** Return the modified time and date stamp for this URL. + + @param URL the asking URL + + @param pDate if unequal 0, the function set the date stamp + + @param pTime if unequal 0, the function set the time stamp + + @return it was be able to get the date/time stamp +*/ +SVL_DLLPUBLIC sal_Bool GetModifiedDateTimeOfFile( const OUString& rURL, + Date* pDate, Time* pTime ); + +/** Return if under the URL a document exist. This is only a wrapper for the + UCB.IsContent. +*/ +SVL_DLLPUBLIC sal_Bool IsDocument( const OUString& rURL ); + +/** Return if under the URL a folder exist. This is only a wrapper for the + UCB.isFolder. +*/ +SVL_DLLPUBLIC sal_Bool IsFolder( const OUString& rURL ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/globalnameitem.hxx b/include/svl/globalnameitem.hxx new file mode 100644 index 000000000000..618791bebb92 --- /dev/null +++ b/include/svl/globalnameitem.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _GLOBALNAMEITEM_HXX +#define _GLOBALNAMEITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <tools/rtti.hxx> +#include <tools/globname.hxx> +#include <svl/poolitem.hxx> + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxGlobalNameItem: public SfxPoolItem +{ + SvGlobalName m_aName; + +public: + TYPEINFO(); + SfxGlobalNameItem(); + SfxGlobalNameItem( sal_uInt16 nWhich, const SvGlobalName& ); + ~SfxGlobalNameItem(); + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + SvGlobalName GetValue() const { return m_aName; } + + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/hint.hxx b/include/svl/hint.hxx new file mode 100644 index 000000000000..8f5356ac9a13 --- /dev/null +++ b/include/svl/hint.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 . + */ +#ifndef _SFXHINT_HXX +#define _SFXHINT_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> + +class SVL_DLLPUBLIC SfxHint +{ +public: + TYPEINFO(); + + virtual ~SfxHint(); +}; + +//-------------------------------------------------------------------- + +#define DECL_PTRHINT(Visibility, Name, Type) \ + class Visibility Name: public SfxHint \ + { \ + Type* pObj; \ + bool bIsOwner; \ + \ + public: \ + TYPEINFO(); \ + explicit Name( Type* Object, bool bOwnedByHint = false ); \ + ~Name(); \ + \ + Type* GetObject() const { return pObj; } \ + bool IsOwner() const { return bIsOwner; } \ + } + +#define IMPL_PTRHINT(Name, Type) \ + TYPEINIT1(Name, SfxHint); \ + Name::Name( Type* pObject, bool bOwnedByHint ) \ + { pObj = pObject; bIsOwner = bOwnedByHint; } \ + Name::~Name() {} + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx new file mode 100644 index 000000000000..6c04ff239c74 --- /dev/null +++ b/include/svl/ilstitem.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SFXILSTITEM_HXX +#define _SFXILSTITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/poolitem.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <vector> + +class SVL_DLLPUBLIC SfxIntegerListItem : public SfxPoolItem +{ + ::com::sun::star::uno::Sequence < sal_Int32 > m_aList; + +public: + TYPEINFO(); + + SfxIntegerListItem(); + SfxIntegerListItem( sal_uInt16 nWhich, const ::std::vector < sal_Int32 >& rList ); + SfxIntegerListItem( sal_uInt16 nWhich, const ::com::sun::star::uno::Sequence < sal_Int32 >& rList ); + SfxIntegerListItem( const SfxIntegerListItem& rItem ); + ~SfxIntegerListItem(); + + ::com::sun::star::uno::Sequence < sal_Int32 > GetSequence() + { return m_aList; } + ::com::sun::star::uno::Sequence < sal_Int32 > GetConstSequence() const + { return (const_cast< SfxIntegerListItem * >(this))->GetSequence(); } + + void GetList( ::std::vector < sal_Int32 >& rList ) const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); + virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; +}; + +#endif // _SFXINTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/imageitm.hxx b/include/svl/imageitm.hxx new file mode 100644 index 000000000000..0a2e26f80086 --- /dev/null +++ b/include/svl/imageitm.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SVT_IMAGEITM_HXX +#define _SVT_IMAGEITM_HXX + +#include "svl/svldllapi.h" +#include <svl/intitem.hxx> + +class String; + +struct SfxImageItem_Impl; +class SVL_DLLPUBLIC SfxImageItem : public SfxInt16Item +{ + SfxImageItem_Impl* pImp; +public: + TYPEINFO(); + SfxImageItem( sal_uInt16 nWhich = 0, sal_uInt16 nImage = 0 ); + SfxImageItem( const SfxImageItem& ); + virtual ~SfxImageItem(); + + virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; + virtual int operator==( const SfxPoolItem& ) const; + virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); + + void SetRotation( long nValue ); + long GetRotation() const; + void SetMirrored( bool bSet ); + bool IsMirrored() const; +}; + +#endif // _SFX_IMAGEITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/inethist.hxx b/include/svl/inethist.hxx new file mode 100644 index 000000000000..4ee592faad16 --- /dev/null +++ b/include/svl/inethist.hxx @@ -0,0 +1,125 @@ +/* -*- 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 _INETHIST_HXX +#define _INETHIST_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <tools/string.hxx> +#include <tools/urlobj.hxx> +#include <svl/brdcst.hxx> +#include <svl/hint.hxx> + +/*======================================================================== + * + * INetURLHistory interface. + * + *=======================================================================*/ +class INetURLHistory_Impl; +class INetURLHistory : public SfxBroadcaster +{ + struct StaticInstance + { + INetURLHistory * operator()(); + }; + friend INetURLHistory * StaticInstance::operator()(); + + /** Representation. + */ + INetURLHistory_Impl *m_pImpl; + + /** Construction/Destruction. + */ + INetURLHistory (void); + virtual ~INetURLHistory (void); + + /** Implementation. + */ + static void NormalizeUrl_Impl (INetURLObject &rUrl); + + SVL_DLLPUBLIC void PutUrl_Impl (const INetURLObject &rUrl); + SVL_DLLPUBLIC sal_Bool QueryUrl_Impl (const INetURLObject &rUrl); + + /** Not implemented. + */ + INetURLHistory (const INetURLHistory&); + INetURLHistory& operator= (const INetURLHistory&); + +public: + /** GetOrCreate. + */ + SVL_DLLPUBLIC static INetURLHistory* GetOrCreate (void); + + /** QueryProtocol. + */ + sal_Bool QueryProtocol (INetProtocol eProto) const + { + return ((eProto == INET_PROT_FILE ) || + (eProto == INET_PROT_FTP ) || + (eProto == INET_PROT_HTTP ) || + (eProto == INET_PROT_HTTPS) ); + } + + /** QueryUrl. + */ + sal_Bool QueryUrl (const INetURLObject &rUrl) + { + if (QueryProtocol (rUrl.GetProtocol())) + return QueryUrl_Impl (rUrl); + else + return sal_False; + } + + sal_Bool QueryUrl (const String &rUrl) + { + INetProtocol eProto = + INetURLObject::CompareProtocolScheme (rUrl); + if (QueryProtocol (eProto)) + return QueryUrl_Impl (INetURLObject (rUrl)); + else + return sal_False; + } + + /** PutUrl. + */ + void PutUrl (const INetURLObject &rUrl) + { + if (QueryProtocol (rUrl.GetProtocol())) + PutUrl_Impl (rUrl); + } + + void PutUrl (const String &rUrl) + { + INetProtocol eProto = + INetURLObject::CompareProtocolScheme (rUrl); + if (QueryProtocol (eProto)) + PutUrl_Impl (INetURLObject (rUrl)); + } +}; + +/*======================================================================== + * + * INetURLHistoryHint (broadcasted from PutUrl()). + * + *=======================================================================*/ +DECL_PTRHINT (SVL_DLLPUBLIC, INetURLHistoryHint, const INetURLObject); + +#endif /* _INETHIST_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/inettype.hxx b/include/svl/inettype.hxx new file mode 100644 index 000000000000..48fca19aa5d6 --- /dev/null +++ b/include/svl/inettype.hxx @@ -0,0 +1,304 @@ +/* -*- 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 _INETTYPE_HXX +#define _INETTYPE_HXX + +#include "svl/svldllapi.h" +#include <tools/inetmime.hxx> +#include <i18nlangtag/languagetag.hxx> + +//============================================================================ +/** Definitions for frequently used media type names. + */ +#define CONTENT_TYPE_STR_APP_OCTSTREAM "application/octet-stream" +#define CONTENT_TYPE_STR_APP_PDF "application/pdf" +#define CONTENT_TYPE_STR_APP_RTF "application/rtf" +#define CONTENT_TYPE_STR_APP_VND_CALC "application/vnd.stardivision.calc" +#define CONTENT_TYPE_STR_APP_VND_CHART "application/vnd.stardivision.chart" +#define CONTENT_TYPE_STR_APP_VND_DRAW "application/vnd.stardivision.draw" +#define CONTENT_TYPE_STR_APP_VND_IMAGE "application/vnd.stardivision.image" +#define CONTENT_TYPE_STR_APP_VND_IMPRESSPACKED "application/vnd.stardivision.impress-packed" +#define CONTENT_TYPE_STR_APP_VND_IMPRESS "application/vnd.stardivision.impress" +#define CONTENT_TYPE_STR_APP_VND_MAIL "application/vnd.stardivision.mail" +#define CONTENT_TYPE_STR_APP_VND_MATH "application/vnd.stardivision.math" +#define CONTENT_TYPE_STR_APP_VND_NEWS "application/vnd.stardivision.news" +#define CONTENT_TYPE_STR_APP_VND_OUTTRAY "application/vnd.stardivision.outtray" +#define CONTENT_TYPE_STR_APP_VND_TEMPLATE "application/vnd.stardivision.template" +#define CONTENT_TYPE_STR_APP_VND_WRITER_GLOBAL "application/vnd.stardivision.writer-global" +#define CONTENT_TYPE_STR_APP_VND_WRITER_WEB "application/vnd.stardivision.writer-web" +#define CONTENT_TYPE_STR_APP_VND_WRITER "application/vnd.stardivision.writer" +#define CONTENT_TYPE_STR_APP_FRAMESET "application/x-frameset" +#define CONTENT_TYPE_STR_APP_GALLERY_THEME "application/x-gallery-theme" +#define CONTENT_TYPE_STR_APP_GALLERY "application/x-gallery" +#define CONTENT_TYPE_STR_APP_JAR "application/x-jar" +#define CONTENT_TYPE_STR_APP_MACRO "application/x-macro" +#define CONTENT_TYPE_STR_APP_MSEXCEL_TEMPL "application/x-msexcel-template" +#define CONTENT_TYPE_STR_APP_MSEXCEL "application/x-msexcel" +#define CONTENT_TYPE_STR_APP_MSPPOINT_TEMPL "application/x-mspowerpoint-template" +#define CONTENT_TYPE_STR_APP_MSPPOINT "application/x-mspowerpoint" +#define CONTENT_TYPE_STR_APP_MSWORD_TEMPL "application/x-msword-template" +#define CONTENT_TYPE_STR_APP_MSWORD "application/x-msword" +#define CONTENT_TYPE_STR_APP_SCHEDULE_EVT "application/x-schedule-event" +#define CONTENT_TYPE_STR_APP_SCHEDULE_FEVT "application/x-schedule-form-event" +#define CONTENT_TYPE_STR_APP_SCHEDULE_FTASK "application/x-schedule-form-task" +#define CONTENT_TYPE_STR_APP_SCHEDULE_TASK "application/x-schedule-task" +#define CONTENT_TYPE_STR_APP_SCHEDULE_CMB "application/x-schedule" +#define CONTENT_TYPE_STR_APP_STARCALC "application/x-starcalc" +#define CONTENT_TYPE_STR_APP_STARCHART "application/x-starchart" +#define CONTENT_TYPE_STR_APP_STARDRAW "application/x-stardraw" +#define CONTENT_TYPE_STR_APP_STARHELP "application/x-starhelp" +#define CONTENT_TYPE_STR_APP_STARIMAGE "application/x-starimage" +#define CONTENT_TYPE_STR_APP_STARIMPRESS "application/x-starimpress" +#define CONTENT_TYPE_STR_APP_STARMAIL_SDM "application/x-starmail-sdm" +#define CONTENT_TYPE_STR_APP_STARMAIL_SMD "application/x-starmail-smd" +#define CONTENT_TYPE_STR_APP_STARMATH "application/x-starmath" +#define CONTENT_TYPE_STR_APP_STARWRITER_GLOB "application/x-starwriter-global" +#define CONTENT_TYPE_STR_APP_STARWRITER "application/x-starwriter" +#define CONTENT_TYPE_STR_APP_CDE_CALENDAR_APP "application/x-sun-ae-file" +#define CONTENT_TYPE_STR_APP_ZIP "application/x-zip-compressed" +#define CONTENT_TYPE_STR_AUDIO_AIFF "audio/aiff" +#define CONTENT_TYPE_STR_AUDIO_BASIC "audio/basic" +#define CONTENT_TYPE_STR_AUDIO_MIDI "audio/midi" +#define CONTENT_TYPE_STR_AUDIO_VORBIS "audio/vorbis" +#define CONTENT_TYPE_STR_AUDIO_WAV "audio/wav" +#define CONTENT_TYPE_STR_AUDIO_WEBM "audio/webm" +#define CONTENT_TYPE_STR_X_CNT_FSYSBOX ".chaos/fsys-box" +#define CONTENT_TYPE_STR_X_CNT_FSYSFOLDER ".chaos/fsys-folder" +#define CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFOLDER ".chaos/fsys-special-folder" +#define CONTENT_TYPE_STR_IMAGE_GENERIC "image/generic" +#define CONTENT_TYPE_STR_IMAGE_GIF "image/gif" +#define CONTENT_TYPE_STR_IMAGE_JPEG "image/jpeg" +#define CONTENT_TYPE_STR_IMAGE_PCX "image/pcx" +#define CONTENT_TYPE_STR_IMAGE_PNG "image/png" +#define CONTENT_TYPE_STR_IMAGE_TIFF "image/tiff" +#define CONTENT_TYPE_STR_IMAGE_BMP "image/x-MS-bmp" +#define CONTENT_TYPE_STR_INET_MSG_RFC822 "message/rfc822" +#define CONTENT_TYPE_STR_INET_MULTI_ALTERNATIVE "multipart/alternative" +#define CONTENT_TYPE_STR_INET_MULTI_DIGEST "multipart/digest" +#define CONTENT_TYPE_STR_INET_MULTI_MIXED "multipart/mixed" +#define CONTENT_TYPE_STR_INET_MULTI_PARALLEL "multipart/parallel" +#define CONTENT_TYPE_STR_INET_MULTI_RELATED "multipart/related" +#define CONTENT_TYPE_STR_TEXT_ICALENDAR "text/calendar" +#define CONTENT_TYPE_STR_TEXT_HTML "text/html" +#define CONTENT_TYPE_STR_TEXT_PLAIN "text/plain" +#define CONTENT_TYPE_STR_TEXT_XMLICALENDAR "text/x-icalxml" +#define CONTENT_TYPE_STR_TEXT_URL "text/x-url" +#define CONTENT_TYPE_STR_TEXT_VCALENDAR "text/x-vCalendar" +#define CONTENT_TYPE_STR_TEXT_VCARD "text/x-vCard" +#define CONTENT_TYPE_STR_VIDEO_MSVIDEO "video/x-msvideo" +#define CONTENT_TYPE_STR_VIDEO_THEORA "video/theora" +#define CONTENT_TYPE_STR_VIDEO_VDO "video/vdo" +#define CONTENT_TYPE_STR_VIDEO_WEBM "audio/webm" +#define CONTENT_TYPE_STR_X_STARMAIL "x-starmail" +#define CONTENT_TYPE_STR_X_VRML "x-world/x-vrml" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER "application/vnd.sun.xml.writer" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_CALC "application/vnd.sun.xml.calc" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESS "application/vnd.sun.xml.impress" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_DRAW "application/vnd.sun.xml.draw" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_CHART "application/vnd.sun.xml.chart" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_MATH "application/vnd.sun.xml.math" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER_GLOBAL "application/vnd.sun.xml.writer-global" +#define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESSPACKED "application/vnd.sun.xml.impress-packed" + +//============================================================================ +/** Definitions for matching parts of URIs. + */ +#define INETTYPE_URL_PROT_COMPONENT ".component" +#define INETTYPE_URL_PROT_DATA "data" +#define INETTYPE_URL_PROT_FILE "file" +#define INETTYPE_URL_PROT_HTTP "http" +#define INETTYPE_URL_PROT_HTTPS "https" +#define INETTYPE_URL_PROT_MACRO "macro" +#define INETTYPE_URL_PROT_MAILTO "mailto" +#define INETTYPE_URL_PROT_PRIVATE "private" + +#define INETTYPE_URL_SUB_FACTORY "factory" +#define INETTYPE_URL_SUB_HELPID "helpid" + +#define INETTYPE_URL_SSUB_FRAMESET "frameset" +#define INETTYPE_URL_SSUB_SCALC "scalc" +#define INETTYPE_URL_SSUB_SCHART "schart" +#define INETTYPE_URL_SSUB_SDRAW "sdraw" +#define INETTYPE_URL_SSUB_SIMAGE "simage" +#define INETTYPE_URL_SSUB_SIMPRESS "simpress" +#define INETTYPE_URL_SSUB_SMATH "smath" +#define INETTYPE_URL_SSUB_SS "ss" +#define INETTYPE_URL_SSUB_SWRITER "swriter" + +#define INETTYPE_URL_SSSUB_GLOB "GlobalDocument" +#define INETTYPE_URL_SSSUB_WEB "web" + +#define INETTYPE_URL_SCHED_CMB "cmbview" +#define INETTYPE_URL_SCHED_FORM "formular" +#define INETTYPE_URL_SCHED_TASK "type=task" + +//============================================================================ +enum INetContentType +{ + CONTENT_TYPE_UNKNOWN, + CONTENT_TYPE_APP_OCTSTREAM, + CONTENT_TYPE_APP_PDF, + CONTENT_TYPE_APP_RTF, + CONTENT_TYPE_APP_MSWORD, + CONTENT_TYPE_APP_MSWORD_TEMPL, + CONTENT_TYPE_APP_STARCALC, + CONTENT_TYPE_APP_STARCHART, + CONTENT_TYPE_APP_STARDRAW, + CONTENT_TYPE_APP_STARHELP, + CONTENT_TYPE_APP_STARIMAGE, + CONTENT_TYPE_APP_STARIMPRESS, + CONTENT_TYPE_APP_STARMATH, + CONTENT_TYPE_APP_STARWRITER, + CONTENT_TYPE_APP_ZIP, + CONTENT_TYPE_AUDIO_AIFF, + CONTENT_TYPE_AUDIO_BASIC, + CONTENT_TYPE_AUDIO_MIDI, + CONTENT_TYPE_AUDIO_VORBIS, + CONTENT_TYPE_AUDIO_WAV, + CONTENT_TYPE_AUDIO_WEBM, + CONTENT_TYPE_IMAGE_GIF, + CONTENT_TYPE_IMAGE_JPEG, + CONTENT_TYPE_IMAGE_PCX, + CONTENT_TYPE_IMAGE_PNG, + CONTENT_TYPE_IMAGE_TIFF, + CONTENT_TYPE_IMAGE_BMP, + CONTENT_TYPE_TEXT_HTML, + CONTENT_TYPE_TEXT_PLAIN, + CONTENT_TYPE_TEXT_URL, + CONTENT_TYPE_TEXT_VCARD, + CONTENT_TYPE_VIDEO_MSVIDEO, + CONTENT_TYPE_VIDEO_THEORA, + CONTENT_TYPE_VIDEO_VDO, + CONTENT_TYPE_VIDEO_WEBM, + CONTENT_TYPE_X_CNT_FSYSBOX, + CONTENT_TYPE_X_CNT_FSYSFOLDER, + CONTENT_TYPE_X_STARMAIL, + CONTENT_TYPE_X_VRML, + CONTENT_TYPE_APP_GALLERY, + CONTENT_TYPE_APP_GALLERY_THEME, + CONTENT_TYPE_APP_STARWRITER_GLOB, + CONTENT_TYPE_APP_STARMAIL_SDM, + CONTENT_TYPE_APP_STARMAIL_SMD, + CONTENT_TYPE_APP_VND_CALC, + CONTENT_TYPE_APP_VND_CHART, + CONTENT_TYPE_APP_VND_DRAW, + CONTENT_TYPE_APP_VND_IMAGE, + CONTENT_TYPE_APP_VND_IMPRESS, + CONTENT_TYPE_APP_VND_MAIL, + CONTENT_TYPE_APP_VND_MATH, + CONTENT_TYPE_APP_VND_WRITER, + CONTENT_TYPE_APP_VND_WRITER_GLOBAL, + CONTENT_TYPE_APP_VND_WRITER_WEB, + CONTENT_TYPE_APP_SCHEDULE, + CONTENT_TYPE_APP_SCHEDULE_EVT, + CONTENT_TYPE_APP_SCHEDULE_TASK, + CONTENT_TYPE_APP_SCHEDULE_FORM_EVT, + CONTENT_TYPE_APP_SCHEDULE_FORM_TASK, + CONTENT_TYPE_APP_FRAMESET, + CONTENT_TYPE_APP_MACRO, + CONTENT_TYPE_X_CNT_FSYSSPECIALFOLDER, + CONTENT_TYPE_APP_VND_TEMPLATE, + CONTENT_TYPE_IMAGE_GENERIC, + CONTENT_TYPE_APP_VND_NEWS, + CONTENT_TYPE_APP_VND_OUTTRAY, + CONTENT_TYPE_APP_MSEXCEL, + CONTENT_TYPE_APP_MSEXCEL_TEMPL, + CONTENT_TYPE_APP_MSPPOINT, + CONTENT_TYPE_APP_MSPPOINT_TEMPL, + CONTENT_TYPE_TEXT_VCALENDAR, + CONTENT_TYPE_TEXT_ICALENDAR, + CONTENT_TYPE_TEXT_XMLICALENDAR, + CONTENT_TYPE_APP_CDE_CALENDAR_APP, + CONTENT_TYPE_INET_MESSAGE_RFC822, + CONTENT_TYPE_INET_MULTIPART_ALTERNATIVE, + CONTENT_TYPE_INET_MULTIPART_DIGEST, + CONTENT_TYPE_INET_MULTIPART_PARALLEL, + CONTENT_TYPE_INET_MULTIPART_RELATED, + CONTENT_TYPE_INET_MULTIPART_MIXED, + CONTENT_TYPE_APP_VND_IMPRESSPACKED, + CONTENT_TYPE_APP_JAR, + CONTENT_TYPE_APP_VND_SUN_XML_WRITER, + CONTENT_TYPE_APP_VND_SUN_XML_CALC, + CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS, + CONTENT_TYPE_APP_VND_SUN_XML_DRAW, + CONTENT_TYPE_APP_VND_SUN_XML_CHART, + CONTENT_TYPE_APP_VND_SUN_XML_MATH, + CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL, + CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED, + CONTENT_TYPE_LAST = CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED +}; + +//============================================================================ +class SVL_DLLPUBLIC INetContentTypes +{ +public: + static INetContentType RegisterContentType(OUString const & rTypeName, + OUString const & rPresentation, + OUString const * pExtension = 0, + OUString const * pSystemFileType = 0); + + static INetContentType GetContentType(OUString const & rTypeName); + + static OUString GetContentType(INetContentType eTypeID); + + static OUString GetPresentation(INetContentType eTypeID, + const LanguageTag& aLocale); + + static INetContentType GetContentType4Extension(OUString const & rExtension); + + static INetContentType GetContentTypeFromURL(OUString const & rURL); + + static bool GetExtensionFromURL(OUString const & rURL, OUString & rExtension); + + /** Parse the body of an RFC 2045 Content-Type header field. + + @param rMediaType The body of the Content-Type header field. It must + be of the form + + token "/" token *(";" token "=" (token / quoted-string)) + + with intervening linear white space and comments (cf. RFCs 822, 2045). + The RFC 2231 extension are supported. The encoding of rMediaType + should be US-ASCII, but any Unicode values in the range U+0080..U+FFFF + are interpretet 'as appropriate.' + + @param rType Returns the type (the first of the above tokens), in US- + ASCII encoding and converted to lower case. + + @param rSubType Returns the sub type (the second of the above + tokens), in US-ASCII encoding and converted to lower case. + + @param rParameters If not null, returns the parameters as a list of + INetContentTypeParameters (the attributes are in US-ASCII encoding and + converted to lower case, the values are in Unicode encoding). If + null, only the syntax of the parameters is checked, but they are not + returned. + + @return True if the syntax of the field body is correct. If false is + returned, none of the output parameters will be modified! + */ + static bool parse(OUString const & rMediaType, OUString & rType, + OUString & rSubType, + INetContentTypeParameterList * pParameters = 0); +}; + +#endif // _INETTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/instrm.hxx b/include/svl/instrm.hxx new file mode 100644 index 000000000000..39c3a8589be9 --- /dev/null +++ b/include/svl/instrm.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 SVTOOLS_INSTRM_HXX +#define SVTOOLS_INSTRM_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/uno/Reference.h> +#include <tools/stream.hxx> + +namespace com { namespace sun { namespace star { namespace io { + class XInputStream; + class XSeekable; +} } } } + +class SvDataPipe_Impl; + +//============================================================================ +class SVL_DLLPUBLIC SvInputStream: public SvStream +{ + com::sun::star::uno::Reference< com::sun::star::io::XInputStream > + m_xStream; + com::sun::star::uno::Reference< com::sun::star::io::XSeekable > + m_xSeekable; + SvDataPipe_Impl * m_pPipe; + sal_uLong m_nSeekedFrom; + + SVL_DLLPRIVATE bool open(); + + SVL_DLLPRIVATE virtual sal_uLong GetData(void * pData, sal_uLong nSize); + + SVL_DLLPRIVATE virtual sal_uLong PutData(void const *, sal_uLong); + + SVL_DLLPRIVATE virtual sal_uLong SeekPos(sal_uLong nPos); + + SVL_DLLPRIVATE virtual void FlushData(); + + SVL_DLLPRIVATE virtual void SetSize(sal_uLong); + +public: + SvInputStream( + com::sun::star::uno::Reference< com::sun::star::io::XInputStream > + const & + rTheStream); + + virtual ~SvInputStream(); + + virtual sal_uInt16 IsA() const; + + virtual void AddMark(sal_uLong nPos); + + virtual void RemoveMark(sal_uLong nPos); +}; + +#endif // SVTOOLS_INSTRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx new file mode 100644 index 000000000000..a9cb341aec10 --- /dev/null +++ b/include/svl/intitem.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SFXINTITEM_HXX +#define _SFXINTITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/cintitem.hxx> + +//============================================================================ +class SVL_DLLPUBLIC SfxByteItem: public CntByteItem +{ +public: + TYPEINFO(); + + explicit SfxByteItem(sal_uInt16 which = 0, sal_uInt8 nValue = 0): + CntByteItem(which, nValue) {} + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxByteItem(*this); } +}; + +//============================================================================ +DBG_NAMEEX_VISIBILITY(SfxInt16Item, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC SfxInt16Item: public SfxPoolItem +{ + sal_Int16 m_nValue; + +public: + TYPEINFO(); + + explicit SfxInt16Item(sal_uInt16 which = 0, sal_Int16 nTheValue = 0): + SfxPoolItem(which), m_nValue(nTheValue) + { DBG_CTOR(SfxInt16Item, 0); } + + SfxInt16Item(sal_uInt16 nWhich, SvStream & rStream); + + SfxInt16Item(const SfxInt16Item & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(SfxInt16Item, 0); } + + virtual ~SfxInt16Item() { DBG_DTOR(SfxInt16Item, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + + virtual bool PutValue( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_Int16 GetMin() const; + + virtual sal_Int16 GetMax() const; + + virtual SfxFieldUnit GetUnit() const; + + sal_Int16 GetValue() const { return m_nValue; } + + inline void SetValue(sal_Int16 nTheValue); +}; + +inline void SfxInt16Item::SetValue(sal_Int16 nTheValue) +{ + DBG_ASSERT(GetRefCount() == 0, "SfxInt16Item::SetValue(); Pooled item"); + m_nValue = nTheValue; +} + +//============================================================================ +class SVL_DLLPUBLIC SfxUInt16Item: public CntUInt16Item +{ +public: + TYPEINFO(); + + explicit SfxUInt16Item(sal_uInt16 which = 0, sal_uInt16 nValue = 0): + CntUInt16Item(which, nValue) {} + + SfxUInt16Item(sal_uInt16 which, SvStream & rStream): + CntUInt16Item(which, rStream) {} + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const + { return new SfxUInt16Item(Which(), rStream); } + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxUInt16Item(*this); } +}; + +//============================================================================ +class SVL_DLLPUBLIC SfxInt32Item: public CntInt32Item +{ +public: + TYPEINFO(); + + explicit SfxInt32Item(sal_uInt16 which = 0, sal_Int32 nValue = 0): + CntInt32Item(which, nValue) {} + + SfxInt32Item(sal_uInt16 which, SvStream & rStream): + CntInt32Item(which, rStream) {} + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const + { return new SfxInt32Item(Which(), rStream); } + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxInt32Item(*this); } + +}; + +//============================================================================ +class SVL_DLLPUBLIC SfxUInt32Item: public CntUInt32Item +{ +public: + TYPEINFO(); + + explicit SfxUInt32Item(sal_uInt16 which = 0, sal_uInt32 nValue = 0): + CntUInt32Item(which, nValue) {} + + SfxUInt32Item(sal_uInt16 which, SvStream & rStream): + CntUInt32Item(which, rStream) {} + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const + { return new SfxUInt32Item(Which(), rStream); } + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxUInt32Item(*this); } +}; + +#endif // _SFXINTITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/isethint.hxx b/include/svl/isethint.hxx new file mode 100644 index 000000000000..cd966f5fcc4f --- /dev/null +++ b/include/svl/isethint.hxx @@ -0,0 +1,45 @@ +/* -*- 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 _SFXISETHINT_HXX +#define _SFXISETHINT_HXX + +#include "svl/svldllapi.h" + +#include <svl/hint.hxx> + +class SfxItemSet; + +//-------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxItemSetHint: public SfxHint +{ + SfxItemSet* _pItemSet; + +public: + TYPEINFO(); + + SfxItemSetHint( const SfxItemSet &rItemSet ); + virtual ~SfxItemSetHint(); + + const SfxItemSet& GetItemSet() const { return *_pItemSet; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx new file mode 100644 index 000000000000..4dada91a42b7 --- /dev/null +++ b/include/svl/itemiter.hxx @@ -0,0 +1,61 @@ +/* -*- 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 _SFXITEMITER_HXX +#define _SFXITEMITER_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <svl/itemset.hxx> + +class SfxPoolItem; +class SfxItemSet; +class SfxItemPool; + +class SVL_DLLPUBLIC SfxItemIter +{ + // Item-Feld - Start & Ende + const SfxItemSet& _rSet; + sal_uInt16 _nStt, _nEnd, _nAkt; + +public: + SfxItemIter( const SfxItemSet& rSet ); + ~SfxItemIter(); + + // falls es diese gibt, returne sie, sonst 0 + const SfxPoolItem* FirstItem() + { _nAkt = _nStt; + return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + const SfxPoolItem* LastItem() + { _nAkt = _nEnd; + return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + const SfxPoolItem* GetCurItem() + { return _rSet._nCount ? *(_rSet._aItems+_nAkt) : 0; } + const SfxPoolItem* NextItem(); + + sal_Bool IsAtStart() const { return _nAkt == _nStt; } + sal_Bool IsAtEnd() const { return _nAkt == _nEnd; } + + sal_uInt16 GetCurPos() const { return _nAkt; } + sal_uInt16 GetFirstPos() const { return _nStt; } + sal_uInt16 GetLastPos() const { return _nEnd; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx new file mode 100644 index 000000000000..ab9ff84d173d --- /dev/null +++ b/include/svl/itempool.hxx @@ -0,0 +1,259 @@ +/* -*- 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 _SFXITEMPOOL_HXX +#define _SFXITEMPOOL_HXX + +#include "svl/svldllapi.h" + +#include <limits.h> +#include <tools/solar.h> +#include <tools/string.hxx> +#include <svl/poolitem.hxx> +#include <vector> + +class SvStream; +class SfxBroadcaster; +struct SfxItemPool_Impl; + +#define SFX_WHICH_MAX 4999 + +DBG_NAMEEX(SfxItemPool) + +//==================================================================== + +#define SFX_ITEM_POOLABLE 0x0001 +#define SFX_ITEM_NOT_POOLABLE 0x0002 + +#define SFX_ITEM_USERFLAG0 0x0100 +#define SFX_ITEM_USERFLAG1 0x0200 +#define SFX_ITEM_USERFLAG2 0x0400 +#define SFX_ITEM_USERFLAG3 0x0800 +#define SFX_ITEM_USERFLAG4 0x1000 +#define SFX_ITEM_USERFLAG5 0x2000 +#define SFX_ITEM_USERFLAG6 0x4000 +#define SFX_ITEM_USERFLAG7 0x8000 +#define SFX_ITEM_USERFLAG8 0x0010 +#define SFX_ITEM_USERFLAG9 0x0020 +#define SFX_ITEM_USERFLAGA 0x0040 +#define SFX_ITEM_USERFLAGB 0x0080 + +//==================================================================== + +struct SfxItemInfo +{ + sal_uInt16 _nSID; + sal_uInt16 _nFlags; +}; + +//==================================================================== + +class SfxStyleSheetIterator; +struct SfxPoolItemArray_Impl; +class SfxItemPool; + +class SVL_DLLPUBLIC SfxItemPoolUser +{ +public: + virtual void ObjectInDestruction(const SfxItemPool& rSfxItemPool) = 0; + +protected: + ~SfxItemPoolUser() {} +}; + +class SVL_DLLPUBLIC SfxItemPool + +/* [Beschreibung] + + Die von dieser Klasse abgeleiteten Klassen dienen der Bereitstellung von + Defaults von SfxPoolItems und halten konkrete (konstante) Instanzen, die + dann von mehreren Stellen (i.d.R. eines Dokuments) referenziert werden + k�nnen. + + Dadurch ist jeder Wert nur einmalig gespeichert, was zu wenig Konstruktor + und Destruktor-Aufrufen f�hrt, Vergleiche zwischen Items eines Dokuments + beschleunigt und ein einfaches Laden und Speichern von Attributen + bereitstellt. +*/ + +{ + friend struct SfxItemPool_Impl; + + const SfxItemInfo* pItemInfos; + SfxItemPool_Impl* pImp; + +public: + void AddSfxItemPoolUser(SfxItemPoolUser& rNewUser); + void RemoveSfxItemPoolUser(SfxItemPoolUser& rOldUser); + + //--------------------------------------------------------------------- +#ifndef _SFXITEMS_HXX + +private: + sal_uInt16 GetIndex_Impl(sal_uInt16 nWhich) const; + sal_uInt16 GetSize_Impl() const; + + SVL_DLLPRIVATE SvStream& Load1_Impl( SvStream &rStream ); + SVL_DLLPRIVATE bool IsItemFlag_Impl( sal_uInt16 nWhich, sal_uInt16 nFlag ) const; + +public: + // fuer dflt. SfxItemSet::CTOR, setze dflt. WhichRanges + void FillItemIdRanges_Impl( sal_uInt16*& pWhichRanges ) const; + const sal_uInt16* GetFrozenIdRanges() const; + +#endif + //--------------------------------------------------------------------- + +protected: + static inline void SetRefCount( SfxPoolItem& rItem, sal_uLong n ); + static inline sal_uLong AddRef( const SfxPoolItem& rItem, sal_uLong n = 1 ); + static inline sal_uLong ReleaseRef( const SfxPoolItem& rItem, sal_uLong n = 1); + static inline void SetKind( SfxPoolItem& rItem, sal_uInt16 nRef ); + +public: + SfxItemPool( const SfxItemPool &rPool, + sal_Bool bCloneStaticDefaults = sal_False ); + SfxItemPool( const OUString &rName, + sal_uInt16 nStart, sal_uInt16 nEnd, + const SfxItemInfo *pItemInfos, + SfxPoolItem **pDefaults = 0, + bool bLoadRefCounts = true ); +protected: + virtual ~SfxItemPool(); +public: + static void Free(SfxItemPool* pPool); + + SfxBroadcaster& BC(); + + void SetPoolDefaultItem( const SfxPoolItem& ); + const SfxPoolItem* GetPoolDefaultItem( sal_uInt16 nWhich ) const; + void ResetPoolDefaultItem( sal_uInt16 nWhich ); + + void SetDefaults( SfxPoolItem **pDefaults ); + void ReleaseDefaults( sal_Bool bDelete = sal_False ); + static void ReleaseDefaults( SfxPoolItem **pDefaults, sal_uInt16 nCount, sal_Bool bDelete = sal_False ); + + virtual SfxMapUnit GetMetric( sal_uInt16 nWhich ) const; + void SetDefaultMetric( SfxMapUnit eNewMetric ); + virtual SfxItemPresentation GetPresentation( const SfxPoolItem& rItem, + SfxItemPresentation ePresentation, + SfxMapUnit ePresentationMetric, + OUString& rText, + const IntlWrapper * pIntlWrapper + = 0 ) const; + virtual SfxItemPool* Clone() const; + const OUString& GetName() const; + + virtual const SfxPoolItem& Put( const SfxPoolItem&, sal_uInt16 nWhich = 0 ); + virtual void Remove( const SfxPoolItem& ); + virtual const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; + + const SfxPoolItem* LoadItem( SvStream &rStream, + bool bDirect = false, + const SfxItemPool *pRefPool = 0 ); + bool StoreItem( SvStream &rStream, + const SfxPoolItem &rItem, + bool bDirect = false ) const; + + sal_uInt32 GetSurrogate(const SfxPoolItem *) const; + const SfxPoolItem * GetItem2(sal_uInt16 nWhich, sal_uInt32 nSurrogate) const; + sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; + const SfxPoolItem* LoadSurrogate(SvStream& rStream, + sal_uInt16 &rWhich, sal_uInt16 nSlotId, + const SfxItemPool* pRefPool = 0 ); + bool StoreSurrogate(SvStream& rStream, + const SfxPoolItem *pItem ) const; + + virtual SvStream & Load(SvStream &); + virtual SvStream & Store(SvStream &) const; + bool HasPersistentRefCounts() const; + void LoadCompleted(); + + sal_uInt16 GetFirstWhich() const; + sal_uInt16 GetLastWhich() const; + bool IsInRange( sal_uInt16 nWhich ) const; + bool IsInVersionsRange( sal_uInt16 nWhich ) const; + bool IsInStoringRange( sal_uInt16 nWhich ) const; + void SetStoringRange( sal_uInt16 nFrom, sal_uInt16 nTo ); + void SetSecondaryPool( SfxItemPool *pPool ); + SfxItemPool* GetSecondaryPool() const; + SfxItemPool* GetMasterPool() const; + void FreezeIdRanges(); + + void Delete(); + + bool IsItemFlag( sal_uInt16 nWhich, sal_uInt16 nFlag ) const; + bool IsItemFlag( const SfxPoolItem &rItem, sal_uInt16 nFlag ) const + { return IsItemFlag( rItem.Which(), nFlag ); } + void SetItemInfos( const SfxItemInfo *pInfos ) + { pItemInfos = pInfos; } + sal_uInt16 GetWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const; + sal_uInt16 GetSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const; + sal_uInt16 GetTrueWhich( sal_uInt16 nSlot, sal_Bool bDeep = sal_True ) const; + sal_uInt16 GetTrueSlotId( sal_uInt16 nWhich, sal_Bool bDeep = sal_True ) const; + + void SetVersionMap( sal_uInt16 nVer, + sal_uInt16 nOldStart, sal_uInt16 nOldEnd, + const sal_uInt16 *pWhichIdTab ); + sal_uInt16 GetNewWhich( sal_uInt16 nOldWhich ) const; + sal_uInt16 GetVersion() const; + void SetFileFormatVersion( sal_uInt16 nFileFormatVersion ); + bool IsCurrentVersionLoading() const; + + static int IsWhich(sal_uInt16 nId) { + return nId && nId <= SFX_WHICH_MAX; } + static int IsSlot(sal_uInt16 nId) { + return nId && nId > SFX_WHICH_MAX; } + + static const SfxItemPool* GetStoringPool(); + +private: + const SfxItemPool& operator=(const SfxItemPool &); // n.i.!! + + static const SfxItemPool* pStoringPool_; +}; + +// --------------- Inline Implementierungen ------------------------------ + +// nur der Pool darf den Referenz-Zaehler manipulieren !!! +inline void SfxItemPool::SetRefCount( SfxPoolItem& rItem, sal_uLong n ) +{ + rItem.SetRefCount(n); +} + +// nur der Pool darf den Referenz-Zaehler manipulieren !!! +inline sal_uLong SfxItemPool::AddRef( const SfxPoolItem& rItem, sal_uLong n ) +{ + return rItem.AddRef(n); +} + +// nur der Pool darf den Referenz-Zaehler manipulieren !!! +inline sal_uLong SfxItemPool::ReleaseRef( const SfxPoolItem& rItem, sal_uLong n ) +{ + return rItem.ReleaseRef(n); +} + +inline void SfxItemPool::SetKind( SfxPoolItem& rItem, sal_uInt16 nRef ) +{ + rItem.SetKind( nRef ); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx new file mode 100644 index 000000000000..c1b7ed68b400 --- /dev/null +++ b/include/svl/itemprop.hxx @@ -0,0 +1,203 @@ +/* -*- 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 _SFX_ITEMPROP_HXX +#define _SFX_ITEMPROP_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <tools/string.hxx> +#include <svl/itemset.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <vector> + +// UNO III - Implementation +#define MAP_CHAR_LEN(cchar) cchar, sizeof(cchar) - 1 + +struct SfxItemPropertyMapEntry +{ + const char* pName; + sal_uInt16 nNameLen; + sal_uInt16 nWID; + const com::sun::star::uno::Type* pType; + long nFlags; + sal_uInt8 nMemberId; + +}; + +struct SfxItemPropertySimpleEntry +{ + sal_uInt16 nWID; + const com::sun::star::uno::Type* pType; + long nFlags; + sal_uInt8 nMemberId; + + SfxItemPropertySimpleEntry() : + nWID( 0 ), + pType( 0 ), + nFlags( 0 ), + nMemberId( 0 ){} + + SfxItemPropertySimpleEntry(sal_uInt16 _nWID, const com::sun::star::uno::Type* _pType, + long _nFlags, sal_uInt8 _nMemberId) : + nWID( _nWID ), + pType( _pType ), + nFlags( _nFlags ), + nMemberId( _nMemberId ){} + + SfxItemPropertySimpleEntry( const SfxItemPropertyMapEntry* pMapEntry ) : + nWID( pMapEntry->nWID ), + pType( pMapEntry->pType ), + nFlags( pMapEntry->nFlags ), + nMemberId( pMapEntry->nMemberId ){} + +}; +struct SfxItemPropertyNamedEntry : public SfxItemPropertySimpleEntry +{ + OUString sName; + SfxItemPropertyNamedEntry( const String& rName, const SfxItemPropertySimpleEntry& rSimpleEntry) : + SfxItemPropertySimpleEntry( rSimpleEntry ), + sName( rName ){} + +}; +typedef std::vector< SfxItemPropertyNamedEntry > PropertyEntryVector_t; +class SfxItemPropertyMap_Impl; +class SVL_DLLPUBLIC SfxItemPropertyMap +{ + SfxItemPropertyMap_Impl* m_pImpl; +public: + SfxItemPropertyMap( const SfxItemPropertyMapEntry* pEntries ); + SfxItemPropertyMap( const SfxItemPropertyMap& rSource ); + ~SfxItemPropertyMap(); + + const SfxItemPropertySimpleEntry* getByName( const OUString &rName ) const; + com::sun::star::uno::Sequence< com::sun::star::beans::Property > getProperties() const; + com::sun::star::beans::Property getPropertyByName( const OUString rName ) const + throw( ::com::sun::star::beans::UnknownPropertyException ); + sal_Bool hasPropertyByName( const OUString& rName ) const; + + void mergeProperties( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& rPropSeq ); + PropertyEntryVector_t getPropertyEntries() const; + sal_uInt32 getSize() const; + +}; + +class SVL_DLLPUBLIC SfxItemPropertySet +{ + SfxItemPropertyMap m_aMap; + mutable com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> m_xInfo; +protected: + virtual sal_Bool FillItem(SfxItemSet& rSet, sal_uInt16 nWhich, sal_Bool bGetProperty) const; + +public: + SfxItemPropertySet( const SfxItemPropertyMapEntry *pMap ) : + m_aMap(pMap) {} + virtual ~SfxItemPropertySet(); + + void getPropertyValue( const SfxItemPropertySimpleEntry& rEntry, + const SfxItemSet& rSet, + com::sun::star::uno::Any& rAny) const + throw(::com::sun::star::uno::RuntimeException); + void getPropertyValue( const OUString &rName, + const SfxItemSet& rSet, + com::sun::star::uno::Any& rAny) const + throw(::com::sun::star::uno::RuntimeException, + ::com::sun::star::beans::UnknownPropertyException); + com::sun::star::uno::Any + getPropertyValue( const OUString &rName, + const SfxItemSet& rSet ) const + throw(::com::sun::star::uno::RuntimeException, + ::com::sun::star::beans::UnknownPropertyException); + void setPropertyValue( const SfxItemPropertySimpleEntry& rEntry, + const com::sun::star::uno::Any& aVal, + SfxItemSet& rSet ) const + throw(::com::sun::star::uno::RuntimeException, + com::sun::star::lang::IllegalArgumentException); + void setPropertyValue( const OUString& rPropertyName, + const com::sun::star::uno::Any& aVal, + SfxItemSet& rSet ) const + throw(::com::sun::star::uno::RuntimeException, + com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::beans::UnknownPropertyException); + + com::sun::star::beans::PropertyState + getPropertyState(const OUString& rName, const SfxItemSet& rSet)const + throw(com::sun::star::beans::UnknownPropertyException); + com::sun::star::beans::PropertyState + getPropertyState(const SfxItemPropertySimpleEntry& rEntry, const SfxItemSet& rSet) const + throw(); + + com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> + getPropertySetInfo() const; + const SfxItemPropertyMap& getPropertyMap() const {return m_aMap;} +}; + +struct SfxItemPropertySetInfo_Impl; +class SVL_DLLPUBLIC SfxItemPropertySetInfo : public + cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo> +{ + SfxItemPropertySetInfo_Impl* m_pImpl; + +public: + SfxItemPropertySetInfo(const SfxItemPropertyMap &rMap ); + SfxItemPropertySetInfo(const SfxItemPropertyMapEntry *pEntries ); + virtual ~SfxItemPropertySetInfo(); + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL + getProperties( ) + throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::beans::Property SAL_CALL + getPropertyByName( const OUString& aName ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) + throw(::com::sun::star::uno::RuntimeException); + +}; + +class SVL_DLLPUBLIC SfxExtItemPropertySetInfo: public cppu::WeakImplHelper1<com::sun::star::beans::XPropertySetInfo > +{ + SfxItemPropertyMap aExtMap; +public: + SfxExtItemPropertySetInfo( + const SfxItemPropertyMapEntry *pMap, + const com::sun::star::uno::Sequence<com::sun::star::beans::Property>& rPropSeq ); + virtual ~SfxExtItemPropertySetInfo(); + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL + getProperties( ) + throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::beans::Property SAL_CALL + getPropertyByName( const OUString& aName ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL + hasPropertyByName( const OUString& Name ) + throw(::com::sun::star::uno::RuntimeException); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx new file mode 100644 index 000000000000..a38398ac1ce7 --- /dev/null +++ b/include/svl/itemset.hxx @@ -0,0 +1,191 @@ +/* -*- 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 _SFXITEMSET_HXX +#define _SFXITEMSET_HXX + +#include "svl/svldllapi.h" + +#include <cstdarg> // std::va_list and friends +#include <svl/poolitem.hxx> +#include <tools/rtti.hxx> +#include <tools/solar.h> + +class SfxItemPool; +class SfxPoolItem; +class SvStream; + +typedef SfxPoolItem const** SfxItemArray; + +#define USHORT_ARG int + +#ifdef DBG +#undef DBG +#endif +#define DBG(s) + +//======================================================================== + +#define SFX_ITEMSET_GET( rSet, pItem, ItemType, nSlotId, bDeep ) \ + const ItemType *pItem = (const ItemType*) \ + (rSet).GetItem( nSlotId, bDeep, TYPE(ItemType) ) + +//======================================================================== + +class SVL_DLLPUBLIC SfxItemSet +{ + friend class SfxItemIter; + + SfxItemPool* _pPool; // der verwendete Pool + const SfxItemSet* _pParent; // Ableitung + SfxItemArray _aItems; // Item-Feld + sal_uInt16* _pWhichRanges; // Array von Which-Bereichen + sal_uInt16 _nCount; // Anzahl Items + + //--------------------------------------------------------------------- +#ifndef _SFXITEMS_HXX + +friend class SfxItemPoolCache; +friend class SfxAllItemSet; +friend const char *DbgCheckItemSet( const void* ); + +private: + SVL_DLLPRIVATE void InitRanges_Impl(const sal_uInt16 *nWhichPairTable); + SVL_DLLPRIVATE void InitRanges_Impl(va_list pWhich, sal_uInt16 n1, sal_uInt16 n2, sal_uInt16 n3); + SVL_DLLPRIVATE void InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2); + +public: + SfxItemArray GetItems_Impl() const { return _aItems; } + +#endif + //--------------------------------------------------------------------- + +private: + const SfxItemSet& operator=(const SfxItemSet &); // n.i.!! + +protected: + // Notification-Callback + virtual void Changed( const SfxPoolItem& rOld, const SfxPoolItem& rNew ); + + // direkte Put-Methode + int PutDirect(const SfxPoolItem &rItem); + +public: + SfxItemSet( const SfxItemSet& ); + + SfxItemSet( SfxItemPool&, sal_Bool bTotalPoolRanges = sal_False ); + SfxItemSet( SfxItemPool&, sal_uInt16 nWhich1, sal_uInt16 nWhich2 ); + SfxItemSet( SfxItemPool&, USHORT_ARG nWh1, USHORT_ARG nWh2, USHORT_ARG nNull, ... ); + SfxItemSet( SfxItemPool&, const sal_uInt16* nWhichPairTable ); + virtual ~SfxItemSet(); + + virtual SfxItemSet * Clone(sal_Bool bItems = sal_True, SfxItemPool *pToPool = 0) const; + + // Items erfragen + sal_uInt16 Count() const { return _nCount; } + sal_uInt16 TotalCount() const; + + virtual const SfxPoolItem& Get( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True ) const; + const SfxPoolItem* GetItem( sal_uInt16 nWhich, sal_Bool bSrchInParent = sal_True, + TypeId aItemType = 0 ) const; + + // Which-Wert des Items an der Position nPos erfragen + sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const; + + // Item-Status erfragen + SfxItemState GetItemState( sal_uInt16 nWhich, + sal_Bool bSrchInParent = sal_True, + const SfxPoolItem **ppItem = 0 ) const; + + bool HasItem(sal_uInt16 nWhich, const SfxPoolItem** ppItem = NULL) const; + + virtual void DisableItem(sal_uInt16 nWhich); + virtual void InvalidateItem( sal_uInt16 nWhich ); + virtual sal_uInt16 ClearItem( sal_uInt16 nWhich = 0); + virtual void ClearInvalidItems( sal_Bool bHardDefault = sal_False ); + void InvalidateAllItems(); // HACK(via nWhich = 0) ??? + + inline void SetParent( const SfxItemSet* pNew ); + + // Items hinzufuegen, loeschen etc. + virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich ); + const SfxPoolItem* Put( const SfxPoolItem& rItem ) + { return Put(rItem, rItem.Which()); } + virtual int Put( const SfxItemSet&, + sal_Bool bInvalidAsDefault = sal_True ); + void PutExtended( const SfxItemSet&, + SfxItemState eDontCareAs = SFX_ITEM_UNKNOWN, + SfxItemState eDefaultAs = SFX_ITEM_UNKNOWN ); + + virtual int Set( const SfxItemSet&, sal_Bool bDeep = sal_True ); + + virtual void Intersect( const SfxItemSet& rSet ); + virtual void MergeValues( const SfxItemSet& rSet, sal_Bool bOverwriteDefaults = sal_False ); + virtual void Differentiate( const SfxItemSet& rSet ); + virtual void MergeValue( const SfxPoolItem& rItem, sal_Bool bOverwriteDefaults = sal_False ); + + SfxItemPool* GetPool() const { return _pPool; } + const sal_uInt16* GetRanges() const { return _pWhichRanges; } + void SetRanges( const sal_uInt16 *pRanges ); + void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo ); + const SfxItemSet* GetParent() const { return _pParent; } + + virtual SvStream & Load( SvStream &, bool bDirect = false, + const SfxItemPool *pRefPool = 0 ); + virtual SvStream & Store( SvStream &, bool bDirect = false ) const; + + virtual int operator==(const SfxItemSet &) const; +}; + +// --------------- Inline Implementierungen ------------------------ + +inline void SfxItemSet::SetParent( const SfxItemSet* pNew ) +{ + DBG( if (_pParent) --*_pChildCount(_pParent) ); + _pParent = pNew; + DBG( if (_pParent) ++*_pChildCount(_pParent) ); +} + +//======================================================================== + +class SVL_DLLPUBLIC SfxAllItemSet: public SfxItemSet + +/* versteht alle Ranges; werden durch das Putten der Items + automatisch angepasst +*/ + +{ + SfxVoidItem aDefault; + sal_uInt16 nFree; + +public: + SfxAllItemSet( SfxItemPool &rPool ); + SfxAllItemSet( const SfxItemSet & ); + SfxAllItemSet( const SfxAllItemSet & ); + + virtual SfxItemSet * Clone( sal_Bool bItems = sal_True, SfxItemPool *pToPool = 0 ) const; + virtual const SfxPoolItem* Put( const SfxPoolItem&, sal_uInt16 nWhich ); + const SfxPoolItem* Put( const SfxPoolItem& rItem ) + { return Put(rItem, rItem.Which()); } + virtual int Put( const SfxItemSet&, + sal_Bool bInvalidAsDefault = sal_True ); +}; + +#endif // #ifndef _SFXITEMSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx new file mode 100644 index 000000000000..ef8fb1b4ae5d --- /dev/null +++ b/include/svl/languageoptions.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 _SVTOOLS_LANGUAGEOPTIONS_HXX +#define _SVTOOLS_LANGUAGEOPTIONS_HXX + +#include "svl/svldllapi.h" +#include <sal/types.h> +#include <svl/brdcst.hxx> +#include <svl/lstner.hxx> +#include <unotools/configitem.hxx> +#include <unotools/options.hxx> +#include <i18nlangtag/lang.h> + +// class SvtLanguageOptions ---------------------------------------------------- + +// these defines can be ored +#define SCRIPTTYPE_LATIN 0x01 +#define SCRIPTTYPE_ASIAN 0x02 +#define SCRIPTTYPE_COMPLEX 0x04 + +class SvtCJKOptions; +class SvtCTLOptions; + +class SVL_DLLPUBLIC SvtLanguageOptions : public ::utl::detail::Options +{ +private: + SvtCJKOptions* m_pCJKOptions; + SvtCTLOptions* m_pCTLOptions; + +public: + enum EOption + { + // cjk options + E_CJKFONT, + E_VERTICALTEXT, + E_ASIANTYPOGRAPHY, + E_JAPANESEFIND, + E_RUBY, + E_CHANGECASEMAP, + E_DOUBLELINES, + E_EMPHASISMARKS, + E_VERTICALCALLOUT, + E_ALLCJK, + // ctl options + E_CTLFONT, + E_CTLSEQUENCECHECKING, + E_CTLCURSORMOVEMENT, + E_CTLTEXTNUMERALS + }; + + // bDontLoad is for referencing purposes only + SvtLanguageOptions( sal_Bool _bDontLoad = sal_False ); + ~SvtLanguageOptions(); + + // CJK options + sal_Bool IsCJKFontEnabled() const; + sal_Bool IsVerticalTextEnabled() const; + sal_Bool IsAsianTypographyEnabled() const; + sal_Bool IsJapaneseFindEnabled() const; + void SetAll( sal_Bool _bSet ); + sal_Bool IsAnyEnabled() const; + + // CTL options + void SetCTLFontEnabled( sal_Bool _bEnabled ); + sal_Bool IsCTLFontEnabled() const; + + void SetCTLSequenceChecking( sal_Bool _bEnabled ); + + void SetCTLSequenceCheckingRestricted( sal_Bool _bEnable ); + + void SetCTLSequenceCheckingTypeAndReplace( sal_Bool _bEnable ); + + sal_Bool IsReadOnly(EOption eOption) const; + + // returns for a language the scripttype + static sal_uInt16 GetScriptTypeOfLanguage( sal_uInt16 nLang ); +}; +/** #i42730# Gives access to the Windows 16bit system locale + */ +class SVL_DLLPUBLIC SvtSystemLanguageOptions : public utl::ConfigItem +{ +private: + OUString m_sWin16SystemLocale; + +public: + SvtSystemLanguageOptions(); + ~SvtSystemLanguageOptions(); + + virtual void Commit(); + virtual void Notify( const com::sun::star::uno::Sequence< OUString >& rPropertyNames ); + + LanguageType GetWin16SystemLanguage(); +}; + +#endif // _SVTOOLS_LANGUAGEOPTIONS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lckbitem.hxx b/include/svl/lckbitem.hxx new file mode 100644 index 000000000000..163c2168c4c0 --- /dev/null +++ b/include/svl/lckbitem.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _LCKBITEM_HXX +#define _LCKBITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <tools/rtti.hxx> +#include <tools/stream.hxx> +#include <svl/poolitem.hxx> + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxLockBytesItem : public SfxPoolItem +{ + SvLockBytesRef _xVal; + +public: + TYPEINFO(); + SfxLockBytesItem(); + SfxLockBytesItem( sal_uInt16 nWhich, SvStream & ); + SfxLockBytesItem( const SfxLockBytesItem& ); + ~SfxLockBytesItem(); + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nItemVersion) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const; + + SvLockBytes* GetValue() const { return _xVal; } + + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/listener.hxx b/include/svl/listener.hxx new file mode 100644 index 000000000000..eeb275e302aa --- /dev/null +++ b/include/svl/listener.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SVT_LISTENER_HXX +#define _SVT_LISTENER_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> + +class SvtBroadcaster; +class SfxHint; +class SvtListenerBase; + +//------------------------------------------------------------------------- + +class SVL_DLLPUBLIC SvtListener +{ + friend class SvtListenerBase; + SvtListenerBase *pBrdCastLst; + + const SvtListener& operator=(const SvtListener &); // n.i., ist verboten + +public: + TYPEINFO(); + + SvtListener(); + SvtListener( const SvtListener &rCopy ); + virtual ~SvtListener(); + + sal_Bool StartListening( SvtBroadcaster& rBroadcaster ); + sal_Bool EndListening( SvtBroadcaster& rBroadcaster ); + void EndListeningAll(); + sal_Bool IsListening( SvtBroadcaster& rBroadcaster ) const; + + sal_Bool HasBroadcaster() const { return 0 != pBrdCastLst; } + + virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/listeneriter.hxx b/include/svl/listeneriter.hxx new file mode 100644 index 000000000000..9a621d80e244 --- /dev/null +++ b/include/svl/listeneriter.hxx @@ -0,0 +1,65 @@ +/* -*- 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_LISTENERITER_HXX +#define _SVT_LISTENERITER_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> + +class SvtListener; +class SvtListenerBase; +class SvtBroadcaster; + +//------------------------------------------------------------------------- + +class SVL_DLLPUBLIC SvtListenerIter +{ + friend class SvtListenerBase; + + SvtBroadcaster& rRoot; + SvtListenerBase *pAkt, *pDelNext; + + // for the update of all iterator's, if a listener is added or removed + // at the same time. + static SvtListenerIter *pListenerIters; + SvtListenerIter *pNxtIter; + + SVL_DLLPRIVATE static void RemoveListener( SvtListenerBase& rDel, + SvtListenerBase* pNext ); + +public: + SvtListenerIter( SvtBroadcaster& ); + ~SvtListenerIter(); + + const SvtBroadcaster& GetBroadcaster() const { return rRoot; } + SvtBroadcaster& GetBroadcaster() { return rRoot; } + + SvtListener* GoNext(); // to the next + + SvtListener* GoStart(); // to the start of the list + + SvtListener* GetCurr() const; // returns the current + + int IsChanged() const { return pDelNext != pAkt; } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lngmisc.hxx b/include/svl/lngmisc.hxx new file mode 100644 index 000000000000..c1b4a0160277 --- /dev/null +++ b/include/svl/lngmisc.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SVTOOLS_LNGMISC_HXX_ +#define _SVTOOLS_LNGMISC_HXX_ + +#include "svl/svldllapi.h" + +#include <rtl/ustring.hxx> + +#define SVT_SOFT_HYPHEN (static_cast<sal_Unicode>(0x00AD)) +#define SVT_HARD_HYPHEN (static_cast<sal_Unicode>(0x2011)) + +// the non-breaking space +#define SVT_HARD_SPACE (static_cast<sal_Unicode>(0x00A0)) + +namespace linguistic +{ + inline bool IsHyphen(sal_Unicode cChar) + { + return cChar == SVT_SOFT_HYPHEN || cChar == SVT_HARD_HYPHEN; + } + + inline bool IsControlChar(sal_Unicode cChar) + { + // TODO: why doesn't this include 0x0F DEL? + return cChar < static_cast<sal_Unicode>(' '); + } + + SVL_DLLPRIVATE sal_Int32 GetNumControlChars( const OUString &rTxt ); + + SVL_DLLPUBLIC bool RemoveHyphens(OUString &rTxt); + SVL_DLLPUBLIC bool RemoveControlChars(OUString &rTxt); + SVL_DLLPUBLIC bool ReplaceControlChars(OUString &rTxt); + SVL_DLLPUBLIC OUString GetThesaurusReplaceText(const OUString &rText); +} // namespace linguistic + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lockfilecommon.hxx b/include/svl/lockfilecommon.hxx new file mode 100644 index 000000000000..b9f62cd78504 --- /dev/null +++ b/include/svl/lockfilecommon.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SVT_LOCKFILECOMMON_HXX +#define _SVT_LOCKFILECOMMON_HXX + +#include <svl/svldllapi.h> + +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XTruncate.hpp> + +#include <osl/mutex.hxx> +#include <tools/urlobj.hxx> + +#define LOCKFILE_OOOUSERNAME_ID 0 +#define LOCKFILE_SYSUSERNAME_ID 1 +#define LOCKFILE_LOCALHOST_ID 2 +#define LOCKFILE_EDITTIME_ID 3 +#define LOCKFILE_USERURL_ID 4 +#define LOCKFILE_ENTRYSIZE 5 + +namespace svt { + +// This is a general implementation that is used in document lock file implementation and in sharing control file implementation +class SVL_DLLPUBLIC LockFileCommon +{ +protected: + ::osl::Mutex m_aMutex; + OUString m_aURL; + + INetURLObject ResolveLinks( const INetURLObject& aDocURL ); + +public: + LockFileCommon( const OUString& aOrigURL, const OUString& aPrefix ); + ~LockFileCommon(); + + static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > ParseList( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer ); + static ::com::sun::star::uno::Sequence< OUString > ParseEntry( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos ); + static OUString ParseName( const ::com::sun::star::uno::Sequence< sal_Int8 >& aBuffer, sal_Int32& o_nCurPos ); + static OUString EscapeCharacters( const OUString& aSource ); + static OUString GetOOOUserName(); + static OUString GetCurrentLocalTime(); + static ::com::sun::star::uno::Sequence< OUString > GenerateOwnEntry(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/lstner.hxx b/include/svl/lstner.hxx new file mode 100644 index 000000000000..e54368abb557 --- /dev/null +++ b/include/svl/lstner.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SFXLSTNER_HXX +#define _SFXLSTNER_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> +#include <deque> + +class SfxBroadcaster; +class SfxHint; + +typedef std::deque<SfxBroadcaster*> SfxBroadcasterArr_Impl; + +#define SFX_NOTIFY( rBC, rBCT, rHint, rHintT ) \ + Notify( rBC, rHint ) + +//------------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxListener +{ + SfxBroadcasterArr_Impl aBCs; + +private: + const SfxListener& operator=(const SfxListener &); // n.i., ist verboten + +public: + TYPEINFO(); + + SfxListener(); + SfxListener( const SfxListener &rCopy ); + virtual ~SfxListener(); + + sal_Bool StartListening( SfxBroadcaster& rBroadcaster, sal_Bool bPreventDups = sal_False ); + sal_Bool EndListening( SfxBroadcaster& rBroadcaster, sal_Bool bAllDups = sal_False ); + void EndListeningAll(); + sal_Bool IsListening( SfxBroadcaster& rBroadcaster ) const; + + sal_uInt16 GetBroadcasterCount() const + { return aBCs.size(); } + SfxBroadcaster* GetBroadcasterJOE( sal_uInt16 nNo ) const + { return aBCs[nNo]; } + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + +#ifndef _NOTIFY_HXX + void RemoveBroadcaster_Impl( SfxBroadcaster& rBC ); +#endif +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/macitem.hxx b/include/svl/macitem.hxx new file mode 100644 index 000000000000..9d73f6a3ded3 --- /dev/null +++ b/include/svl/macitem.hxx @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * 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 _SFXMACITEM_HXX +#define _SFXMACITEM_HXX + +// class SvxMacroItem ---------------------------------------------------- + +#include "svl/svldllapi.h" +#include <svl/poolitem.hxx> +#include <tools/rtti.hxx> +#include <tools/debug.hxx> +#include <tools/string.hxx> +#include <map> + +class SvStream; + +#define SVX_MACRO_LANGUAGE_JAVASCRIPT "JavaScript" +#define SVX_MACRO_LANGUAGE_STARBASIC "StarBasic" +#define SVX_MACRO_LANGUAGE_SF "Script" + +DBG_NAMEEX(SvxMacroItem) + +// ----------------------------------------------------------------------- + +//Ein Macro + +enum ScriptType +{ + STARBASIC, + JAVASCRIPT, + EXTENDED_STYPE +}; + +// Basisklasse fuer SjJSbxObject mit virtuellem Destruktor +class SjJSbxObjectBase +{ +public: + virtual ~SjJSbxObjectBase(); + virtual SjJSbxObjectBase* Clone( void ); + //virtual SjJSbxObjectBase& operator=( const SjJSbxObjectBase& rBase ); +}; + +class SjJSbxObject; + +class SVL_DLLPUBLIC SvxMacro +{ + OUString aMacName; + OUString aLibName; + // Fuer JavaScript muss ein Function-Objekt gehalten werden + SjJSbxObjectBase* pFunctionObject; + ScriptType eType; + +public: + + SvxMacro( const OUString &rMacName, const OUString &rLanguage); + + SvxMacro( const OUString &rMacName, const OUString &rLibName, + ScriptType eType); // = STARBASIC entfernt + + SvxMacro( SjJSbxObjectBase* _pFunctionObject, const OUString &rSource ); + ~SvxMacro(); // noetig fuer pFunctionObject + + const OUString &GetLibName() const { return aLibName; } + const OUString &GetMacName() const { return aMacName; } + OUString GetLanguage()const; + + ScriptType GetScriptType() const { return eType; } + + bool HasMacro() const { return !aMacName.isEmpty(); } + +#ifdef SOLAR_JAVA + // JavaScript-Function-Objekt holen + // ACHTUNG: Implementation in SJ, Source/JScript/sjimpl.cxx + SjJSbxObjectBase* GetFunctionObject( SjJSbxObject* pParent ); +#endif + + SvxMacro& operator=( const SvxMacro& rBase ); +}; + +inline SvxMacro::SvxMacro( const OUString &rMacName, const OUString &rLibName, + ScriptType eTyp ) + : aMacName( rMacName ), aLibName( rLibName ), pFunctionObject(NULL), eType( eTyp ) +{} + +inline SvxMacro::SvxMacro( SjJSbxObjectBase* _pFunctionObject, const OUString &rSource ) + : aMacName( rSource ), pFunctionObject( _pFunctionObject ), eType( JAVASCRIPT ) +{} + +//Macro Table, zerstoert die Pointer im DTor! + +typedef std::map<sal_uInt16, SvxMacro> SvxMacroTable; + +#define SVX_MACROTBL_VERSION31 0 +#define SVX_MACROTBL_VERSION40 1 + +#define SVX_MACROTBL_AKTVERSION SVX_MACROTBL_VERSION40 + +class SVL_DLLPUBLIC SvxMacroTableDtor +{ +private: + SvxMacroTable aSvxMacroTable; +public: + inline SvxMacroTableDtor() {} + inline SvxMacroTableDtor( const SvxMacroTableDtor &rCpy ) : aSvxMacroTable(rCpy.aSvxMacroTable) { } + + SvxMacroTableDtor& operator=( const SvxMacroTableDtor &rCpy ); + int operator==( const SvxMacroTableDtor& rOther ) const; + + // loescht alle Eintraege + void clear() { aSvxMacroTable.clear(); } + + SvStream& Read( SvStream &, sal_uInt16 nVersion = SVX_MACROTBL_AKTVERSION ); + SvStream& Write( SvStream & ) const; + + sal_uInt16 GetVersion() const { return SVX_MACROTBL_AKTVERSION; } + + SvxMacroTable::iterator begin() { return aSvxMacroTable.begin(); } + SvxMacroTable::const_iterator begin() const { return aSvxMacroTable.begin(); } + SvxMacroTable::iterator end() { return aSvxMacroTable.end(); } + SvxMacroTable::const_iterator end () const { return aSvxMacroTable.end(); } + SvxMacroTable::size_type size() const { return aSvxMacroTable.size(); } + bool empty() const { return aSvxMacroTable.empty(); } + + // returns NULL if no entry exists, or a pointer to the internal value + const SvxMacro* Get(sal_uInt16 nEvent) const; + // returns NULL if no entry exists, or a pointer to the internal value + SvxMacro* Get(sal_uInt16 nEvent); + // return true if the key exists + bool IsKeyValid(sal_uInt16 nEvent) const; + // This stores a copy of the rMacro parameter + SvxMacro& Insert(sal_uInt16 nEvent, const SvxMacro& rMacro); + // If the entry exists, remove it from the map and release it's storage + sal_Bool Erase(sal_uInt16 nEvent); +}; + + +/* +[Beschreibung] +Dieses Item beschreibt eine Makro-Tabelle. +*/ + +class SVL_DLLPUBLIC SvxMacroItem: public SfxPoolItem +{ +public: + TYPEINFO(); + + explicit inline SvxMacroItem ( const sal_uInt16 nId /*= ITEMID_MACRO*/ ); + + // "pure virtual Methoden" vom SfxPoolItem + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const; + virtual sal_uInt16 GetVersion( sal_uInt16 nFileFormatVersion ) const; + + inline const SvxMacroTableDtor& GetMacroTable() const { return aMacroTable;} + inline void SetMacroTable( const SvxMacroTableDtor& rTbl ) { aMacroTable = rTbl; } + + inline const SvxMacro& GetMacro( sal_uInt16 nEvent ) const; + inline sal_Bool HasMacro( sal_uInt16 nEvent ) const; + void SetMacro( sal_uInt16 nEvent, const SvxMacro& ); + inline sal_Bool DelMacro( sal_uInt16 nEvent ); + +private: + SvxMacroTableDtor aMacroTable; + + inline SvxMacroItem( const SvxMacroItem& ); + SvxMacroItem &operator=( const SvxMacroItem & ); +}; + +inline SvxMacroItem::SvxMacroItem( const sal_uInt16 nId ) + : SfxPoolItem( nId ) +{} +inline SvxMacroItem::SvxMacroItem( const SvxMacroItem &rCpy ) + : SfxPoolItem( rCpy ), + aMacroTable( rCpy.GetMacroTable() ) +{} + +inline sal_Bool SvxMacroItem::HasMacro( sal_uInt16 nEvent ) const +{ + return aMacroTable.IsKeyValid( nEvent ); +} +inline const SvxMacro& SvxMacroItem::GetMacro( sal_uInt16 nEvent ) const +{ + return *(aMacroTable.Get(nEvent)); +} +inline sal_Bool SvxMacroItem::DelMacro( sal_uInt16 nEvent ) +{ + return aMacroTable.Erase(nEvent); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/mailenum.hxx b/include/svl/mailenum.hxx new file mode 100644 index 000000000000..a01c6bc109ed --- /dev/null +++ b/include/svl/mailenum.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _MAILENUM_HXX +#define _MAILENUM_HXX + +// enum ------------------------------------------------------------------ + +enum MailState +{ + MAIL_STATE_SUCCESS = 0, + MAIL_STATE_FAILURE, + MAIL_STATE_ATTACHED_NOT_FOUND, + MAIL_STATE_NO_MEMORY, + MAIL_STATE_LOGIN_FAILURE, + MAIL_STATE_RECEIVER_NOT_FOUND, + MAIL_STATE_TOO_MANY_FILES, + MAIL_STATE_TOO_MANY_RECEIVERS, + MAIL_STATE_NO_RECEIVERS, + MAIL_STATE_USER_CANCEL, + MAIL_STATE_DRIVER_NOT_AVAILABLE +}; + +enum MailDriver +{ + MAIL_DRIVER_DETECT = 0, + MAIL_DRIVER_BEGIN, + MAIL_DRIVER_VIM = MAIL_DRIVER_BEGIN, + MAIL_DRIVER_MAPI, + MAIL_DRIVER_CMC, + MAIL_DRIVER_SMP, + MAIL_DRIVER_UNIX, + MAIL_DRIVER_SMTP, + MAIL_DRIVER_END +}; + +enum MailPriority +{ + MAIL_PRIORITY_LOW = 0, + MAIL_PRIORITY_NORMAL, + MAIL_PRIORITY_URGENT +}; + +enum MailReceiverRole +{ + MAIL_RECEIVER_TO = 0, + MAIL_RECEIVER_CC, + MAIL_RECEIVER_BCC, + MAIL_RECEIVER_NEWSGROUP +}; + +enum MailAction +{ + MAIL_ACTION_DYING, // Server stirbt + MAIL_ACTION_SEND, // Mail wurde versendet + MAIL_ACTION_READ, // Mail wurde als gelesen gekennzeichnet + MAIL_ACTION_REMOVED, // Mail wurde gel"oscht + MAIL_ACTION_UPDATED, // alle Mails wurden neu eingelesen + MAIL_ACTION_NEXT, // Sprung zur n"achsten Mail + MAIL_ACTION_PREV // Sprung zur vorherigen Mail +}; + +// Textformat zum Versenden von Nachrichten ------------------------------ + +#define TXTFORMAT_ASCII ((sal_uInt8)0x01) +#define TXTFORMAT_HTML ((sal_uInt8)0x02) +#define TXTFORMAT_RTF ((sal_uInt8)0x04) +#define TXTFORMAT_OFFICE ((sal_uInt8)0x08) + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/memberid.hrc b/include/svl/memberid.hrc new file mode 100644 index 000000000000..4d501b5ae2ab --- /dev/null +++ b/include/svl/memberid.hrc @@ -0,0 +1,61 @@ +/* -*- 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 _MEMBERID_HRC +#define _MEMBERID_HRC + + +#define MID_X 1 +#define MID_Y 2 +#define MID_RECT_LEFT 3 +#define MID_RECT_TOP 4 +#define MID_WIDTH 5 +#define MID_HEIGHT 6 +#define MID_RECT_RIGHT 7 + +// SvxSizeItem +#define MID_SIZE_SIZE 0 +#define MID_SIZE_WIDTH 1 +#define MID_SIZE_HEIGHT 2 + +// SvxSearchItem +#define MID_SEARCH_STYLEFAMILY 1 +#define MID_SEARCH_CELLTYPE 2 +#define MID_SEARCH_ROWDIRECTION 3 +#define MID_SEARCH_ALLTABLES 4 +#define MID_SEARCH_SEARCHFILTERED 5 +#define MID_SEARCH_BACKWARD 6 +#define MID_SEARCH_PATTERN 7 +#define MID_SEARCH_CONTENT 8 +#define MID_SEARCH_ASIANOPTIONS 9 +#define MID_SEARCH_ALGORITHMTYPE 10 +#define MID_SEARCH_FLAGS 11 +#define MID_SEARCH_SEARCHSTRING 12 +#define MID_SEARCH_REPLACESTRING 13 +#define MID_SEARCH_LOCALE 14 +#define MID_SEARCH_CHANGEDCHARS 15 +#define MID_SEARCH_DELETEDCHARS 16 +#define MID_SEARCH_INSERTEDCHARS 17 +#define MID_SEARCH_TRANSLITERATEFLAGS 18 +#define MID_SEARCH_COMMAND 19 + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/metitem.hxx b/include/svl/metitem.hxx new file mode 100644 index 000000000000..090d95450159 --- /dev/null +++ b/include/svl/metitem.hxx @@ -0,0 +1,46 @@ +/* -*- 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 _SFXMETRICITEM_HXX +#define _SFXMETRICITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/intitem.hxx> + +DBG_NAMEEX_VISIBILITY(SfxMetricItem, SVL_DLLPUBLIC) + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxMetricItem: public SfxInt32Item +{ +public: + TYPEINFO(); + explicit SfxMetricItem( sal_uInt16 nWhich = 0, sal_uInt32 nValue = 0 ); + SfxMetricItem( sal_uInt16 nWhich, SvStream & ); + SfxMetricItem( const SfxMetricItem& ); + ~SfxMetricItem() { + DBG_DTOR(SfxMetricItem, 0); } + + virtual bool ScaleMetrics( long lMult, long lDiv ); + virtual bool HasMetrics() const; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/nfkeytab.hxx b/include/svl/nfkeytab.hxx new file mode 100644 index 000000000000..fdedea036d00 --- /dev/null +++ b/include/svl/nfkeytab.hxx @@ -0,0 +1,122 @@ +/* -*- 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_NFKEYTAB_HXX +#define INCLUDED_SVTOOLS_NFKEYTAB_HXX + +#include <vector> +#include <tools/string.hxx> + +//! For ImpSvNumberformatScan: first the short symbols, then the long symbols! +//! e.g. first TT then TTTT +//! The internal order is essentially for the format code string scanner! +//! New keywords MUST NOT be inserted, only the NF_KEY_UNUSEDn may be used, +//! NF_KEY_LASTKEYWORD must be adjusted accordingly. Otherwise old versions +//! will fail upon reading these entries. Nevertheless, old versions are NOT +//! able to display those new keywords => blank display. +// +// Note: 2005-09-02: the above applies to the binary file format. +// +// ER 15.12.99: This table is externally only to be used with method +// String SvNumberformat::GetMappedFormatstring( const NfKeywordTable&, const LocaleDataWrapper& ); +// and method +// void SvNumberFormatter::FillKeywordTable( NfKeywordTable&, LanguageType ); +enum NfKeywordIndex +{ + NF_KEY_NONE = 0, + NF_KEY_E, // exponential symbol + NF_KEY_AMPM, // AM/PM + NF_KEY_AP, // a/p + NF_KEY_MI, // minute (!) + NF_KEY_MMI, // minute 02 (!) + NF_KEY_M, // month (!) + NF_KEY_MM, // month 02 (!) + NF_KEY_MMM, // month short name + NF_KEY_MMMM, // month long name + NF_KEY_H, // hour + NF_KEY_HH, // hour 02 + NF_KEY_S, // second + NF_KEY_SS, // second 02 + NF_KEY_Q, // quarter + NF_KEY_QQ, // quarter 02 + NF_KEY_D, // day of month + NF_KEY_DD, // day of month 02 + NF_KEY_DDD, // day of week short + NF_KEY_DDDD, // day of week long + NF_KEY_YY, // year two digits + NF_KEY_YYYY, // year four digits + NF_KEY_NN, // day of week short + NF_KEY_NNNN, // day of week long with separator + NF_KEY_CCC, // currency bank symbol (old version) + NF_KEY_GENERAL, // General / Standard + NF_KEY_LASTOLDKEYWORD = NF_KEY_GENERAL, + NF_KEY_NNN, // day of week long without separator, as of version 6, 10.10.97 + NF_KEY_WW, // week of year, as of version 8, 19.06.98 + NF_KEY_MMMMM, // first letter of month name + NF_KEY_LASTKEYWORD = NF_KEY_MMMMM, + NF_KEY_UNUSED4, + NF_KEY_QUARTER, // was quarter word, not used anymore from SRC631 on (26.04.01) + NF_KEY_TRUE, // boolean true + NF_KEY_FALSE, // boolean false + NF_KEY_BOOLEAN, // boolean + NF_KEY_COLOR, // color + NF_KEY_FIRSTCOLOR, + NF_KEY_BLACK = NF_KEY_FIRSTCOLOR, // you do know colors, don't you? + NF_KEY_BLUE, + NF_KEY_GREEN, + NF_KEY_CYAN, + NF_KEY_RED, + NF_KEY_MAGENTA, + NF_KEY_BROWN, + NF_KEY_GREY, + NF_KEY_YELLOW, + NF_KEY_WHITE, + NF_KEY_LASTCOLOR = NF_KEY_WHITE, + NF_KEY_LASTKEYWORD_SO5 = NF_KEY_LASTCOLOR, + //! Keys from here on can't be saved in SO5 file format and MUST be + //! converted to string which means losing any information. + NF_KEY_AAA, // abbreviated day name from Japanese Xcl, same as DDD or NN English + NF_KEY_AAAA, // full day name from Japanese Xcl, same as DDDD or NNN English + NF_KEY_EC, // E non-gregorian calendar year without preceding 0 + NF_KEY_EEC, // EE non-gregorian calendar year with preceding 0 (two digit) + NF_KEY_G, // abbreviated era name, latin characters M T S or H for Gengou calendar + NF_KEY_GG, // abbreviated era name + NF_KEY_GGG, // full era name + NF_KEY_R, // acts as EE (Xcl) => GR==GEE, GGR==GGEE, GGGR==GGGEE + NF_KEY_RR, // acts as GGGEE (Xcl) + NF_KEY_THAI_T, // Thai T modifier, speciality of Thai Excel, only used with Thai locale and converted to [NatNum1] + NF_KEYWORD_ENTRIES_COUNT +}; + +class NfKeywordTable +{ + typedef ::std::vector<OUString> Keywords_t; + Keywords_t m_keywords; + +public: + NfKeywordTable() : m_keywords(NF_KEYWORD_ENTRIES_COUNT) {}; + virtual ~NfKeywordTable() {} + + OUString & operator[] (Keywords_t::size_type n) { return m_keywords[n]; } + const OUString & operator[] (Keywords_t::size_type n) const { return m_keywords[n]; } +}; + +#endif // INCLUDED_SVTOOLS_NFKEYTAB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/nfsymbol.hxx b/include/svl/nfsymbol.hxx new file mode 100644 index 000000000000..0edfc33e112d --- /dev/null +++ b/include/svl/nfsymbol.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SVTOOLS_NFSYMBOL_HXX +#define INCLUDED_SVTOOLS_NFSYMBOL_HXX + +/* ATTENTION! If new types arrive that had its content previously handled as + * SYMBOLTYPE_STRING, they have to be added at several places in zforscan.cxx + * and/or zformat.cxx, and in xmloff/source/style/xmlnumfe.cxx. Mostly these + * are places where already NF_SYMBOLTYPE_STRING together with + * NF_SYMBOLTYPE_CURRENCY or NF_SYMBOLTYPE_DATESEP are used in the same case of + * a switch respectively an if-condition. + */ + +namespace svt { + +/// Number formatter's symbol types of a token, if not key words, which are >0 +enum NfSymbolType +{ + NF_SYMBOLTYPE_STRING = -1, // literal string in output + NF_SYMBOLTYPE_DEL = -2, // special character + NF_SYMBOLTYPE_BLANK = -3, // blank for '_' + NF_SYMBOLTYPE_STAR = -4, // *-character + NF_SYMBOLTYPE_DIGIT = -5, // digit place holder + NF_SYMBOLTYPE_DECSEP = -6, // decimal separator + NF_SYMBOLTYPE_THSEP = -7, // group AKA thousand separator + NF_SYMBOLTYPE_EXP = -8, // exponent E + NF_SYMBOLTYPE_FRAC = -9, // fraction / + NF_SYMBOLTYPE_EMPTY = -10, // deleted symbols + NF_SYMBOLTYPE_FRACBLANK = -11, // delimiter between integer and fraction + NF_SYMBOLTYPE_CURRENCY = -12, // currency symbol + NF_SYMBOLTYPE_CURRDEL = -13, // currency symbol delimiter [$] + NF_SYMBOLTYPE_CURREXT = -14, // currency symbol extension -xxx + NF_SYMBOLTYPE_CALENDAR = -15, // calendar ID + NF_SYMBOLTYPE_CALDEL = -16, // calendar delimiter [~] + NF_SYMBOLTYPE_DATESEP = -17, // date separator + NF_SYMBOLTYPE_TIMESEP = -18, // time separator + NF_SYMBOLTYPE_TIME100SECSEP = -19, // time 100th seconds separator + NF_SYMBOLTYPE_PERCENT = -20, // percent % + NF_SYMBOLTYPE_FRAC_FDIV = -21 // forced divisors +}; + +} // namespace svt + +#endif // INCLUDED_SVTOOLS_NFSYMBOL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/nfversi.hxx b/include/svl/nfversi.hxx new file mode 100644 index 000000000000..3e86af078fe4 --- /dev/null +++ b/include/svl/nfversi.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef NF_NFVERSI_HXX +#define NF_NFVERSI_HXX + +// file IDs + +#define SV_NUMBERFORMATTER_VERSION_SYSTORE 0x0004 +#define SV_NUMBERFORMATTER_VERSION_KEYWORDS 0x0005 +#define SV_NUMBERFORMATTER_VERSION_NEWSTANDARD 0x0006 +#define SV_NUMBERFORMATTER_VERSION_NF_TIME_HH_MMSS00 0x0007 +#define SV_NUMBERFORMATTER_VERSION_NF_DATE_WW 0x0008 +#define SV_NUMBERFORMATTER_VERSION_NEW_CURR 0x0009 +#define SV_NUMBERFORMATTER_VERSION_YEAR2000 0x000a +#define SV_NUMBERFORMATTER_VERSION_TWODIGITYEAR 0x000b +#define SV_NUMBERFORMATTER_VERSION_NF_DATETIME_SYS_DDMMYYYY_HHMMSS 0x000c +#define SV_NUMBERFORMATTER_VERSION_CALENDAR 0x000d +#define SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS 0x000e +#define SV_NUMBERFORMATTER_VERSION_FIXED_FRACTION 0x000f + +#define SV_NUMBERFORMATTER_VERSION 0x000f + +// 1 to 1996-01-18 +// 2 1996-01-19 added TT.MM.JJJJ +// 3 1996-02-13 (not emergency) added #.##0,00 CCC +// 4 1997-07-30 364i store what SYSTEM actually was (using existing +// Dummy field, no change of file format) +// 5 1997-08-07 non-German is not always English +// convert older non-German user defined formats on load +// 6 1997-10-17 new keyword NNN for long weekday without separator +// not evaluated in older versions! +// New standard date formats, DIN, EN etc. +// 7 1998-05-25 Standard format [HH]:MM:SS,00 (NF_TIME_HH_MMSS00) for +// automatic input recognition of 100th seconds with hours +// 8 1998-06-10 Standard format WW (NF_DATE_WW) for calendar week +// 9 1998-12-17 new currency formats [$DM-xxx] +// A 1999-01-25 store/load Year2000 +// B 1999-02-12 Year2000 is general TwoDigitYearStart +// C ????-??-?? date/time format of system variables +// D 2000-11-23 new calendar +// E 2001-01-19 additional formats provided by i18n +// F 2012-04-27 fixed fraction formats ?/4 and ??/100, actually added +// already 2010/2011 but without versioning + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/nranges.hxx b/include/svl/nranges.hxx new file mode 100644 index 000000000000..364bf59a44f2 --- /dev/null +++ b/include/svl/nranges.hxx @@ -0,0 +1,65 @@ +/* -*- 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 . + */ +#ifdef MACOSX +// We need an empty block in here. Otherwise, if the #ifndef _SFXNRANGES_HXX +// line is the first line, the Mac OS X version of the gcc preprocessor will +// incorrectly optimize the inclusion process and will never include this file +// a second time +#endif + +#ifndef _SFXNRANGES_HXX +#define _SFXNRANGES_HXX + +#include <tools/solar.h> + +//======================================================================== + +class SfxUShortRanges +{ + sal_uInt16* _pRanges; // 0-terminated array of sal_uInt16-pairs + +public: + SfxUShortRanges() : _pRanges( 0 ) {} + SfxUShortRanges( const SfxUShortRanges &rOrig ); + SfxUShortRanges( sal_uInt16 nWhich1, sal_uInt16 nWhich2 ); + SfxUShortRanges( const sal_uInt16* nNumTable ); + ~SfxUShortRanges() + { delete [] _pRanges; } + + sal_Bool operator == ( const SfxUShortRanges & ) const; + sal_Bool operator != ( const SfxUShortRanges & rRanges ) const + { return !( *this == rRanges ); } + + SfxUShortRanges& operator = ( const SfxUShortRanges & ); + + SfxUShortRanges& operator += ( const SfxUShortRanges & ); + SfxUShortRanges& operator -= ( const SfxUShortRanges & ); + SfxUShortRanges& operator /= ( const SfxUShortRanges & ); + + sal_uInt16 Count() const; + sal_Bool IsEmpty() const + { return !_pRanges || 0 == *_pRanges; } + + operator const sal_uInt16* () const + { return _pRanges; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/numuno.hxx b/include/svl/numuno.hxx new file mode 100644 index 000000000000..515a73fb26a6 --- /dev/null +++ b/include/svl/numuno.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _NUMUNO_HXX +#define _NUMUNO_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <cppuhelper/implbase2.hxx> + +class SvNumberFormatter; +class SvNumFmtSuppl_Impl; + +namespace comphelper +{ + class SharedMutex; +} + +//------------------------------------------------------------------ + +// SvNumberFormatterServiceObj must be registered as service somewhere + +com::sun::star::uno::Reference<com::sun::star::uno::XInterface> SAL_CALL + SvNumberFormatterServiceObj_NewInstance( + const com::sun::star::uno::Reference< + com::sun::star::lang::XMultiServiceFactory>& rSMgr ); + +//------------------------------------------------------------------ + +// SvNumberFormatsSupplierObj: aggregate to document, +// construct with SvNumberFormatter + +class SVL_DLLPUBLIC SvNumberFormatsSupplierObj : public cppu::WeakAggImplHelper2< + com::sun::star::util::XNumberFormatsSupplier, + com::sun::star::lang::XUnoTunnel> +{ +private: + SvNumFmtSuppl_Impl* pImpl; + +public: + SvNumberFormatsSupplierObj(); + SvNumberFormatsSupplierObj(SvNumberFormatter* pForm); + virtual ~SvNumberFormatsSupplierObj(); + + void SetNumberFormatter(SvNumberFormatter* pNew); + SvNumberFormatter* GetNumberFormatter() const; + + // ueberladen, um Attribute im Dokument anzupassen + virtual void NumberFormatDeleted(sal_uInt32 nKey); + // ueberladen, um evtl. neu zu formatieren + virtual void SettingsChanged(); + + // XNumberFormatsSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL + getNumberFormatSettings() + throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats > SAL_CALL + getNumberFormats() + throw(::com::sun::star::uno::RuntimeException); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< + sal_Int8 >& aIdentifier ) + throw(::com::sun::star::uno::RuntimeException); + + static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); + static SvNumberFormatsSupplierObj* getImplementation( const com::sun::star::uno::Reference< + com::sun::star::util::XNumberFormatsSupplier> xObj ); + + ::comphelper::SharedMutex& getSharedMutex() const; +}; + +#endif // #ifndef _NUMUNO_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ondemand.hxx b/include/svl/ondemand.hxx new file mode 100644 index 000000000000..b3a2c42e11e6 --- /dev/null +++ b/include/svl/ondemand.hxx @@ -0,0 +1,384 @@ +/* -*- 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_ONDEMAND_HXX +#define INCLUDED_SVTOOLS_ONDEMAND_HXX + +#include <unotools/syslocale.hxx> +#include <i18nlangtag/lang.h> +#include <unotools/localedatawrapper.hxx> +#include <unotools/calendarwrapper.hxx> +#include <unotools/collatorwrapper.hxx> +#include <com/sun/star/i18n/CollatorOptions.hpp> +#include <unotools/transliterationwrapper.hxx> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <unotools/nativenumberwrapper.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <comphelper/processfactory.hxx> + +/* + On demand instanciation and initialization of several i18n wrappers, + helping the number formatter to not perform worse than it already does. + */ + +/** @short + Switch between LANGUAGE_SYSTEM and LANGUAGE_ENGLISH_US and any other + LocaleDataWrapper. + SvNumberformatter uses it upon switching locales. + + @descr + Avoids reloading and analysing of locale data again and again. + + @ATTENTION + If the default ctor is used the init() method MUST be called before + accessing any locale data. The passed parameters Locale and LanguageType + must match each other. + */ + +class OnDemandLocaleDataWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + SvtSysLocale aSysLocale; + LanguageType eCurrentLanguage; + LanguageType eLastAnyLanguage; + const LocaleDataWrapper* pSystem; + const LocaleDataWrapper* pEnglish; + LocaleDataWrapper* pAny; + const LocaleDataWrapper* pCurrent; + bool bInitialized; + +public: + OnDemandLocaleDataWrapper() + : eLastAnyLanguage( LANGUAGE_DONTKNOW ) + , pEnglish(0) + , pAny(0) + , bInitialized(false) + { + pCurrent = pSystem = aSysLocale.GetLocaleDataPtr(); + eCurrentLanguage = LANGUAGE_SYSTEM; + } + OnDemandLocaleDataWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const LanguageTag& rLanguageTag + ) + : pEnglish(0) + , pAny(0) + , pCurrent(0) + , bInitialized(false) + { + pSystem = aSysLocale.GetLocaleDataPtr(); + init( rxContext, rLanguageTag ); + } + ~OnDemandLocaleDataWrapper() + { + delete pEnglish; + delete pAny; + } + + bool isInitialized() const { return bInitialized; } + + bool is() const { return pCurrent != NULL; } + + void init( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const LanguageTag& rLanguageTag + ) + { + m_xContext = rxContext; + changeLocale( rLanguageTag ); + bInitialized = true; + } + + void changeLocale( const LanguageTag& rLanguageTag ) + { + LanguageType eLang = rLanguageTag.getLanguageType( false); + switch ( eLang ) + { + case LANGUAGE_SYSTEM : + pCurrent = pSystem; + break; + case LANGUAGE_ENGLISH_US : + if ( !pEnglish ) + pEnglish = new LocaleDataWrapper( m_xContext, rLanguageTag ); + pCurrent = pEnglish; + break; + default: + if ( !pAny ) + { + pAny = new LocaleDataWrapper( m_xContext, rLanguageTag ); + eLastAnyLanguage = eLang; + } + else if ( eLastAnyLanguage != eLang ) + { + pAny->setLanguageTag( rLanguageTag ); + eLastAnyLanguage = eLang; + } + pCurrent = pAny; + } + eCurrentLanguage = eLang; + } + + LanguageType getCurrentLanguage() const + { return eCurrentLanguage; } + + LocaleDataWrapper* getAnyLocale() + { + if ( !pAny ) + { + pAny = new LocaleDataWrapper( m_xContext, pCurrent->getLanguageTag() ); + eLastAnyLanguage = eCurrentLanguage; + } + else if ( pCurrent != pAny ) + { + pAny->setLanguageTag( pCurrent->getLanguageTag() ); + eLastAnyLanguage = eCurrentLanguage; + } + return pAny; + } + + const LocaleDataWrapper* get() const { return pCurrent; } + const LocaleDataWrapper* operator->() const { return get(); } + const LocaleDataWrapper& operator*() const { return *get(); } +}; + +/** Load a calendar only if it's needed. + SvNumberformatter uses it upon switching locales. + @ATTENTION If the default ctor is used the init() method MUST be called + before accessing the calendar. + */ +class OnDemandCalendarWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::lang::Locale aLocale; + mutable CalendarWrapper* pPtr; + mutable bool bValid; + bool bInitialized; + +public: + OnDemandCalendarWrapper() + : pPtr(0) + , bValid(false) + , bInitialized(false) + {} + OnDemandCalendarWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + ::com::sun::star::lang::Locale& rLocale + ) + : bValid(false) + , bInitialized(false) + { + init( rxContext, rLocale ); + } + ~OnDemandCalendarWrapper() + { + delete pPtr; + } + + bool isInitialized() const { return bInitialized; } + + bool is() const { return pPtr != NULL; } + + void init( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + const ::com::sun::star::lang::Locale& rLocale + ) + { + m_xContext = rxContext; + changeLocale( rLocale ); + if ( pPtr ) + { + delete pPtr; + pPtr = NULL; + } + bInitialized = true; + } + + void changeLocale( const ::com::sun::star::lang::Locale& rLocale ) + { + bValid = false; + aLocale = rLocale; + } + + CalendarWrapper* get() const + { + if ( !bValid ) + { + if ( !pPtr ) + pPtr = new CalendarWrapper( m_xContext ); + pPtr->loadDefaultCalendar( aLocale ); + bValid = true; + } + return pPtr; + } + + CalendarWrapper* operator->() { return get(); } + CalendarWrapper& operator*() { return *get(); } +}; + +/** Load a transliteration only if it's needed. + SvNumberformatter uses it upon switching locales. + @ATTENTION If the default ctor is used the init() method MUST be called + before accessing the transliteration. + */ +class OnDemandTransliterationWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + LanguageType eLanguage; + ::com::sun::star::i18n::TransliterationModules nType; + mutable ::utl::TransliterationWrapper* pPtr; + mutable bool bValid; + bool bInitialized; + +public: + OnDemandTransliterationWrapper() + : eLanguage( LANGUAGE_SYSTEM ) + , pPtr(0) + , bValid(false) + , bInitialized(false) + {} + OnDemandTransliterationWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + LanguageType eLang, + ::com::sun::star::i18n::TransliterationModules nTypeP + ) + : bValid(false) + , bInitialized(false) + { + init( rxContext, eLang, nTypeP ); + } + ~OnDemandTransliterationWrapper() + { + delete pPtr; + } + + bool isInitialized() const { return bInitialized; } + + bool is() const { return pPtr != NULL; } + + void init( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + LanguageType eLang, + ::com::sun::star::i18n::TransliterationModules nTypeP + ) + { + m_xContext = rxContext; + nType = nTypeP; + changeLocale( eLang ); + if ( pPtr ) + { + delete pPtr; + pPtr = NULL; + } + bInitialized = true; + } + + void changeLocale( LanguageType eLang ) + { + bValid = false; + eLanguage = eLang; + } + + const ::utl::TransliterationWrapper* get() const + { + if ( !bValid ) + { + if ( !pPtr ) + pPtr = new ::utl::TransliterationWrapper( m_xContext, nType ); + pPtr->loadModuleIfNeeded( eLanguage ); + bValid = true; + } + return pPtr; + } + + const ::utl::TransliterationWrapper* getForModule( const String& rModule, LanguageType eLang ) const + { + if ( !pPtr ) + pPtr = new ::utl::TransliterationWrapper( m_xContext, nType ); + pPtr->loadModuleByImplName( rModule, eLang ); + bValid = false; // reforce settings change in get() + return pPtr; + } + + const ::utl::TransliterationWrapper* operator->() const { return get(); } + const ::utl::TransliterationWrapper& operator*() const { return *get(); } +}; + +/** Load a native number service wrapper only if it's needed. + SvNumberformatter uses it. + + @ATTENTION + If the default ctor is used the init() method MUST be called + before accessing the native number supplier. + */ +class OnDemandNativeNumberWrapper +{ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + mutable NativeNumberWrapper* pPtr; + bool bInitialized; + +public: + OnDemandNativeNumberWrapper() + : pPtr(0) + , bInitialized(false) + {} + OnDemandNativeNumberWrapper( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + ) + : pPtr(0) + , bInitialized(false) + { + init( rxContext ); + } + ~OnDemandNativeNumberWrapper() + { + delete pPtr; + } + + bool isInitialized() const { return bInitialized; } + + void init( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + ) + { + m_xContext = rxContext; + if ( pPtr ) + { + delete pPtr; + pPtr = NULL; + } + bInitialized = true; + } + + bool is() const { return pPtr != NULL; } + + NativeNumberWrapper* get() const + { + if ( !pPtr ) + pPtr = new NativeNumberWrapper( m_xContext ); + return pPtr; + } + + NativeNumberWrapper* operator->() { return get(); } + NativeNumberWrapper& operator*() { return *get(); } +}; + +#endif // INCLUDED_SVTOOLS_ONDEMAND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/outstrm.hxx b/include/svl/outstrm.hxx new file mode 100644 index 000000000000..31899599fc90 --- /dev/null +++ b/include/svl/outstrm.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 . + */ + +#ifndef SVTOOLS_OUTSTRM_HXX +#define SVTOOLS_OUTSTRM_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/uno/Reference.h> +#include <tools/stream.hxx> + +namespace com { namespace sun { namespace star { namespace io { + class XOutputStream; +} } } } + +//============================================================================ +class SVL_DLLPUBLIC SvOutputStream: public SvStream +{ + com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > + m_xStream; + + SVL_DLLPRIVATE virtual sal_uLong GetData(void *, sal_uLong); + + SVL_DLLPRIVATE virtual sal_uLong PutData(void const * pData, sal_uLong nSize); + + SVL_DLLPRIVATE virtual sal_uLong SeekPos(sal_uLong); + + SVL_DLLPRIVATE virtual void FlushData(); + + SVL_DLLPRIVATE virtual void SetSize(sal_uLong); + +public: + SvOutputStream(com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > const & + rTheStream); + + virtual ~SvOutputStream(); + + virtual sal_uInt16 IsA() const; +}; + +#endif // SVTOOLS_OUTSTRM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ownlist.hxx b/include/svl/ownlist.hxx new file mode 100644 index 000000000000..e4cead159c8b --- /dev/null +++ b/include/svl/ownlist.hxx @@ -0,0 +1,90 @@ +/* -*- 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 _OWNLIST_HXX +#define _OWNLIST_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/uno/Sequence.hxx> +#include <vector> + +namespace com { namespace sun { namespace star { + namespace beans { + struct PropertyValue; + } +}}} + +//========================================================================= +class SvCommand +/* [Beschreibung] + + Enth"alt einen String, welcher das Kommando angibt und eine weiteren + String, der das Argument des Kommandos bildet. W"urde solch ein + Kommando "uber die Kommandozeile angegeben werden, s"ahe es wie folgt + aus: Kommando = Argument. +*/ +{ + OUString aCommand; + OUString aArgument; +public: + SvCommand() {} + SvCommand( const OUString & rCommand, const OUString & rArg ) + { + aCommand = rCommand; + aArgument = rArg; + } + const OUString & GetCommand() const { return aCommand; } + const OUString & GetArgument() const { return aArgument; } +}; + +typedef ::std::vector< SvCommand > SvCommandList_impl; + +//========================================================================= +class SVL_DLLPUBLIC SvCommandList +/* [Beschreibung] + + Die Liste enth"alt Objekte vom Typ SvCommand. Wird ein Objekt + eingef"ugt, dann wird es kopiert und das neue Objekt wird + in die Liste gestellt. +*/ +{ +private: + SvCommandList_impl aCommandList; + +public: + SvCommand& Append( const OUString & rCommand, const OUString & rArg ); + bool AppendCommands( const OUString & rCmd, sal_Int32 * pEaten ); + + bool FillFromSequence( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& ); + void FillSequence( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& ); + + size_t size() const { return aCommandList.size(); } + + SvCommand operator[]( size_t i) { + return aCommandList[ i ]; + } + + void clear() { + aCommandList.clear(); + } +}; + +#endif // _OWNLIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/pickerhistoryaccess.hxx b/include/svl/pickerhistoryaccess.hxx new file mode 100644 index 000000000000..5f91d3578f9a --- /dev/null +++ b/include/svl/pickerhistoryaccess.hxx @@ -0,0 +1,45 @@ +/* -*- 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 SVTOOLS_PICKERHISTORYACCESS_HXX +#define SVTOOLS_PICKERHISTORYACCESS_HXX + +#include "svl/svldllapi.h" + +#include <com/sun/star/uno/Reference.hxx> + +//......................................................................... +namespace svt +{ +//......................................................................... + + // -------------------------------------------------------------------- + SVL_DLLPUBLIC void addFolderPicker( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxPicker ); + + SVL_DLLPUBLIC void addFilePicker( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxPicker ); + +//......................................................................... +} // namespace svt +//......................................................................... + +#endif // SVTOOLS_PICKERHISTORYACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/poolcach.hxx b/include/svl/poolcach.hxx new file mode 100644 index 000000000000..eaf6ad3deef9 --- /dev/null +++ b/include/svl/poolcach.hxx @@ -0,0 +1,62 @@ +/* -*- 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 _SFXPOOLCACH_HXX +#define _SFXPOOLCACH_HXX + +#include "svl/svldllapi.h" +#include <tools/solar.h> +#include <vector> + +//------------------------------------------------------------------------ + +class SfxItemPool; +class SfxItemSet; +class SfxPoolItem; +class SfxSetItem; + +struct SfxItemModifyImpl +{ + const SfxSetItem *pOrigItem; + SfxSetItem *pPoolItem; +}; + +typedef std::vector<SfxItemModifyImpl> SfxItemModifyArr_Impl; + + +class SVL_DLLPUBLIC SfxItemPoolCache +{ + SfxItemPool *pPool; + SfxItemModifyArr_Impl *pCache; + const SfxItemSet *pSetToPut; + const SfxPoolItem *pItemToPut; + +public: + SfxItemPoolCache( SfxItemPool *pPool, + const SfxPoolItem *pPutItem ); + SfxItemPoolCache( SfxItemPool *pPool, + const SfxItemSet *pPutSet ); + ~SfxItemPoolCache(); + + const SfxSetItem& ApplyTo( const SfxSetItem& rSetItem, sal_Bool bNew = sal_False ); +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx new file mode 100644 index 000000000000..5e041825186a --- /dev/null +++ b/include/svl/poolitem.hxx @@ -0,0 +1,415 @@ +/* -*- 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 _SFXPOOLITEM_HXX +#define _SFXPOOLITEM_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/uno/Any.hxx> + +#include <sal/config.h> +#include <tools/rtti.hxx> +#include <limits.h> +#include <tools/solar.h> +#include <tools/debug.hxx> +#include <tools/string.hxx> +#include <svl/hint.hxx> + +typedef long SfxArgumentError; + +class SbxVariable; +class SbxObject; +class SvStream; +class Color; +class IntlWrapper; + +namespace com { namespace sun { namespace star { namespace uno { class Any; } } } } + +static const sal_uInt32 SFX_ITEMS_DIRECT= 0xffffffff; +static const sal_uInt32 SFX_ITEMS_NULL= 0xfffffff0; // instead StoreSurrogate +static const sal_uInt32 SFX_ITEMS_DEFAULT= 0xfffffffe; + +#define SFX_ITEMS_POOLDEFAULT 0xffff +#define SFX_ITEMS_STATICDEFAULT 0xfffe +#define SFX_ITEMS_DELETEONIDLE 0xfffd + +#define SFX_ITEMS_OLD_MAXREF 0xffef +#define SFX_ITEMS_MAXREF 0xfffffffe +#define SFX_ITEMS_SPECIAL 0xffffffff + +#define CONVERT_TWIPS 0x80 //Uno-Konvertierung fuer Massangaben (fuer MemberId) + +// ----------------------------------------------------------------------- + +// UNO3 shortcuts + +// warning, if there is no boolean inside the any this will always return the value false +inline sal_Bool Any2Bool( const ::com::sun::star::uno::Any&rValue ) +{ + sal_Bool nValue = sal_False; + if( rValue.hasValue() ) + { + if( rValue.getValueType() == ::getCppuBooleanType() ) + { + nValue = *(sal_Bool*)rValue.getValue(); + } + else + { + sal_Int32 nNum = 0; + if( rValue >>= nNum ) + nValue = nNum != 0; + } + } + + return nValue; +} + +inline ::com::sun::star::uno::Any Bool2Any( sal_Bool bValue ) +{ + return ::com::sun::star::uno::Any( &bValue, ::getCppuBooleanType() ); +} + +// ----------------------------------------------------------------------- + +//! Notloesung!!! +enum SfxFieldUnit +{ + SFX_FUNIT_NONE, SFX_FUNIT_MM, SFX_FUNIT_CM, SFX_FUNIT_M, SFX_FUNIT_KM, + SFX_FUNIT_TWIP, SFX_FUNIT_POINT, SFX_FUNIT_PICA, + SFX_FUNIT_INCH, SFX_FUNIT_FOOT, SFX_FUNIT_MILE, SFX_FUNIT_CHAR, SFX_FUNIT_LINE, SFX_FUNIT_CUSTOM +}; + +enum SfxMapUnit +{ + SFX_MAPUNIT_100TH_MM, + SFX_MAPUNIT_10TH_MM, + SFX_MAPUNIT_MM, + SFX_MAPUNIT_CM, + SFX_MAPUNIT_1000TH_INCH, + SFX_MAPUNIT_100TH_INCH, + SFX_MAPUNIT_10TH_INCH, + SFX_MAPUNIT_INCH, + SFX_MAPUNIT_POINT, + SFX_MAPUNIT_TWIP, + SFX_MAPUNIT_PIXEL, + SFX_MAPUNIT_SYSFONT, + SFX_MAPUNIT_APPFONT, + SFX_MAPUNIT_RELATIVE, + SFX_MAPUNIT_ABSOLUTE +}; + +// ----------------------------------------------------------------------- + +enum SfxItemPresentation + +/* [Beschreibung] + + Die Werte dieses Enums bezeichnen den Grad der textuellen + Presentation eines Items nach Aufruf der virtuellen Methode + <SfxPoolItem::GetPresentation()const>. +*/ + +{ + SFX_ITEM_PRESENTATION_NONE, + SFX_ITEM_PRESENTATION_NAMEONLY, + SFX_ITEM_PRESENTATION_NAMELESS, + SFX_ITEM_PRESENTATION_COMPLETE +}; + +// ----------------------------------------------------------------------- + +typedef sal_uInt16 SfxItemState; + +#define SFX_ITEM_UNKNOWN 0x0000 + +#define SFX_ITEM_DISABLED 0x0001 +#define SFX_ITEM_READONLY 0x0002 + +#define SFX_ITEM_DONTCARE 0x0010 +#define SFX_ITEM_DEFAULT 0x0020 +#define SFX_ITEM_SET 0x0030 + +// old stuff - dont use!!! +#define SFX_ITEM_AVAILABLE SFX_ITEM_DEFAULT +#define SFX_ITEM_OFF SFX_ITEM_DEFAULT +#define SFX_ITEM_ON SFX_ITEM_SET + +DBG_NAMEEX_VISIBILITY(SfxPoolItem, SVL_DLLPUBLIC) +DBG_NAMEEX(SfxVoidItem) +DBG_NAMEEX(SfxItemHandle) + +class SvXMLUnitConverter; +class SfxItemPool; +class SfxItemSet; + + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxPoolItem +{ +friend class SfxItemPool; +friend class SfxItemDesruptor_Impl; +friend class SfxItemPoolCache; +friend class SfxItemSet; +friend class SfxVoidItem; + + sal_uLong m_nRefCount; + sal_uInt16 m_nWhich; + sal_uInt16 m_nKind; + +private: + inline void SetRefCount( sal_uLong n ); + inline void SetKind( sal_uInt16 n ); +public: + inline sal_uLong AddRef( sal_uLong n = 1 ) const; +private: + inline sal_uLong ReleaseRef( sal_uLong n = 1 ) const; + SVL_DLLPRIVATE long Delete_Impl(void*); + +protected: + explicit SfxPoolItem( sal_uInt16 nWhich = 0 ); + SfxPoolItem( const SfxPoolItem& ); + +public: + TYPEINFO(); + virtual ~SfxPoolItem(); + + void SetWhich( sal_uInt16 nId ) { + DBG_CHKTHIS(SfxPoolItem, 0); + m_nWhich = nId; } + sal_uInt16 Which() const { + DBG_CHKTHIS(SfxPoolItem, 0); + return m_nWhich; } + virtual int operator==( const SfxPoolItem& ) const = 0; + int operator!=( const SfxPoolItem& rItem ) const + { return !(*this == rItem); } + virtual int Compare( const SfxPoolItem &rWith ) const; + virtual int Compare( const SfxPoolItem &rWith, const IntlWrapper& rIntlWrapper ) const; + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePresentation, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresentationMetric, + OUString &rText, + const IntlWrapper * pIntlWrapper = 0 ) const; + + virtual sal_uInt16 GetVersion( sal_uInt16 nFileFormatVersion ) const; + virtual bool ScaleMetrics( long lMult, long lDiv ); + virtual bool HasMetrics() const; + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); + + virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nItemVersion ) const; + virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const = 0; + + sal_uLong GetRefCount() const { return m_nRefCount; } + inline sal_uInt16 GetKind() const { return m_nKind; } + + /** Read in a Unicode string from a streamed byte string representation. + + @param rStream Some (input) stream. Its Stream/TargetCharSets must + be set to correct values! + + @param rString On success, returns the reconstructed Unicode string. + + @return True if the string was successfully read and reconstructed. + */ + static OUString readByteString(SvStream & rStream); + + /** Write a byte string representation of a Unicode string into a stream. + + @param rStream Some (output) stream. Its Stream/TargetCharSets must + be set to correct values! + + @param rString Some Unicode string. + */ + static void writeByteString(SvStream & rStream, + const OUString& rString); + + /** Read in a Unicode string from either a streamed Unicode or byte string + representation. + + @param rStream Some (input) stream. If bUnicode is false, its + Stream/TargetCharSets must be set to correct values! + + @param bUnicode Whether to read in a stream Unicode (true) or byte + string (false) representation. + + @return On success, returns the reconstructed Unicode string. + */ + static OUString readUnicodeString(SvStream & rStream, bool bUnicode); + + /** Write a Unicode string representation of a Unicode string into a + stream. + + @param rStream Some (output) stream. + + @param rString Some Unicode string. + */ + static void writeUnicodeString(SvStream & rStream, + const OUString& rString); + +private: + SfxPoolItem& operator=( const SfxPoolItem& ); // n.i.!! +}; + +// ----------------------------------------------------------------------- + +inline void SfxPoolItem::SetRefCount( sal_uLong n ) +{ + DBG_CHKTHIS( SfxPoolItem, 0 ); + m_nRefCount = n; + m_nKind = 0; +} + +inline void SfxPoolItem::SetKind( sal_uInt16 n ) +{ + DBG_CHKTHIS( SfxPoolItem, 0 ); + m_nRefCount = SFX_ITEMS_SPECIAL; + m_nKind = n; +} + +inline sal_uLong SfxPoolItem::AddRef( sal_uLong n ) const +{ + DBG_CHKTHIS( SfxPoolItem, 0 ); + DBG_ASSERT(m_nRefCount <= SFX_ITEMS_MAXREF, "AddRef with non-Pool-Item"); + DBG_ASSERT(ULONG_MAX - m_nRefCount > n, "AddRef: refcount overflow"); + return (const_cast<SfxPoolItem *>(this)->m_nRefCount += n); +} + +inline sal_uLong SfxPoolItem::ReleaseRef( sal_uLong n ) const +{ + DBG_CHKTHIS( SfxPoolItem, 0 ); + DBG_ASSERT(m_nRefCount <= SFX_ITEMS_MAXREF, "AddRef with non-Pool-Item"); + DBG_ASSERT(m_nRefCount >= n, "AddRef: refcount underflow"); + const_cast<SfxPoolItem *>(this)->m_nRefCount -= n; + return m_nRefCount; +} + +// ----------------------------------------------------------------------- + +inline int IsPoolDefaultItem(const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetKind() == SFX_ITEMS_POOLDEFAULT; +} + +inline int IsStaticDefaultItem(const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetKind() == SFX_ITEMS_STATICDEFAULT; +} + +inline int IsDefaultItem( const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetKind() >= SFX_ITEMS_STATICDEFAULT; +} + +inline int IsPooledItem( const SfxPoolItem *pItem ) +{ + return pItem && pItem->GetRefCount() > 0 && pItem->GetRefCount() <= SFX_ITEMS_MAXREF; +} + +inline int IsInvalidItem(const SfxPoolItem *pItem) +{ + return pItem == (SfxPoolItem *)-1; +} + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxVoidItem: public SfxPoolItem +{ + SfxVoidItem & operator=( const SfxVoidItem& ); // not implemented. +public: + TYPEINFO(); + explicit SfxVoidItem( sal_uInt16 nWhich ); + SfxVoidItem( sal_uInt16 nWhich, SvStream & ); + SfxVoidItem( const SfxVoidItem& ); + ~SfxVoidItem(); + + virtual int operator==( const SfxPoolItem& ) const; + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + + // von sich selbst eine Kopie erzeugen + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + void SetWhich(sal_uInt16 nWh) { m_nWhich = nWh; } +}; + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxSetItem: public SfxPoolItem +{ + SfxItemSet *pSet; + + SfxSetItem & operator=( const SfxSetItem& ); // not implemented. + +public: + TYPEINFO(); + SfxSetItem( sal_uInt16 nWhich, SfxItemSet *pSet ); + SfxSetItem( sal_uInt16 nWhich, const SfxItemSet &rSet ); + SfxSetItem( const SfxSetItem&, SfxItemPool *pPool = 0 ); + ~SfxSetItem(); + + virtual int operator==( const SfxPoolItem& ) const; + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + + // von sich selbst eine Kopie erzeugen + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const = 0; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nVersion) const = 0; + virtual SvStream& Store(SvStream &, sal_uInt16 nVer) const; + + const SfxItemSet& GetItemSet() const + { return *pSet; } + SfxItemSet& GetItemSet() + { return *pSet; } +}; + +// ----------------------------------------------------------------------- +// Handle Klasse fuer PoolItems + +class SVL_DLLPUBLIC SfxItemHandle +{ + sal_uInt16 *pRef; + SfxPoolItem *pItem; +public: + explicit SfxItemHandle( SfxPoolItem& ); + SfxItemHandle( const SfxItemHandle& ); + ~SfxItemHandle(); + + const SfxItemHandle &operator=(const SfxItemHandle &); + const SfxPoolItem &GetItem() const { return *pItem; } +}; + +// ----------------------------------------------------------------------- + +DECL_PTRHINT(SVL_DLLPUBLIC, SfxPoolItemHint, SfxPoolItem); + +// ----------------------------------------------------------------------- + +#endif // #ifndef _SFXPOOLITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx new file mode 100644 index 000000000000..6906e24baaf7 --- /dev/null +++ b/include/svl/ptitem.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 _SFXPTITEM_HXX +#define _SFXPTITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/poolitem.hxx> +#include <tools/gen.hxx> + +class SvStream; + +DBG_NAMEEX_VISIBILITY(SfxPointItem, SVL_DLLPUBLIC) + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxPointItem: public SfxPoolItem +{ + Point aVal; + +public: + TYPEINFO(); + SfxPointItem(); + SfxPointItem( sal_uInt16 nWhich, const Point& rVal ); + SfxPointItem( const SfxPointItem& ); + ~SfxPointItem() { + DBG_DTOR(SfxPointItem, 0); } + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + + virtual int operator==( const SfxPoolItem& ) const; + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nItemVersion) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion) const; + + const Point& GetValue() const { return aVal; } + void SetValue( const Point& rNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + aVal = rNewVal; + } + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/rectitem.hxx b/include/svl/rectitem.hxx new file mode 100644 index 000000000000..b9f0f950eb63 --- /dev/null +++ b/include/svl/rectitem.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SFXRECTITEM_HXX +#define _SFXRECTITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <tools/gen.hxx> +#include <svl/poolitem.hxx> + +class SvStream; + +DBG_NAMEEX_VISIBILITY(SfxRectangleItem, SVL_DLLPUBLIC) + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxRectangleItem: public SfxPoolItem +{ + Rectangle aVal; + +public: + TYPEINFO(); + SfxRectangleItem(); + SfxRectangleItem( sal_uInt16 nWhich, const Rectangle& rVal ); + SfxRectangleItem( const SfxRectangleItem& ); + ~SfxRectangleItem() { + DBG_DTOR(SfxRectangleItem, 0); } + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nItemVersion) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion) const; + + const Rectangle& GetValue() const { return aVal; } + void SetValue( const Rectangle& rNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + aVal = rNewVal; + } + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/restrictedpaths.hxx b/include/svl/restrictedpaths.hxx new file mode 100644 index 000000000000..85326a569654 --- /dev/null +++ b/include/svl/restrictedpaths.hxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_RESTRICTEDPATHS_HXX +#define SVTOOLS_RESTRICTEDPATHS_HXX + +#include <svl/urlfilter.hxx> +#include <svl/svldllapi.h> + +#include <vector> + +namespace svt +{ + class SVL_DLLPUBLIC RestrictedPaths : public IUrlFilter + { + private: + ::std::vector< OUString > m_aUnrestrictedURLs; + bool m_bFilterIsEnabled; + + public: + RestrictedPaths(); + virtual ~RestrictedPaths(); + + inline bool hasFilter() const { return !m_aUnrestrictedURLs.empty(); } + inline const ::std::vector< OUString >& getFilter() const { return m_aUnrestrictedURLs; } + + inline void enableFilter( bool _bEnable ) { m_bFilterIsEnabled = _bEnable; } + inline bool isFilterEnabled() const { return m_bFilterIsEnabled; } + + public: + /** checks URL access permissions + + <p>with the "restriction" feature we have in the file dialog, it's possible that + only certain URLs can be browsed. This method checks whether a given URL belongs + to this set of permitted URLs.</p> + + <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p> + */ + virtual bool isUrlAllowed( const OUString& _rURL ) const; + + /** checks URL access permissions + + <p>with the "restriction" feature we have in the file dialog, it's possible that + only certain URLs can be browsed. This method checks whether a given URL belongs + to this set of permitted URLs.</p> + + <p>Default behavior allows access to parent folder of a restricted folder (but not to its siblings). + If allowParents is set to <FALSE/> parent folders will be treated as forbidden. + + <p>If no "access restriction" is effective, this method always returns <TRUE/>.</p> + */ + bool isUrlAllowed( const OUString& _rURL, bool allowParents ) const; + }; + +} // namespace svt + +#endif // SVTOOLS_RESTRICTEDPATHS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/rngitem.hxx b/include/svl/rngitem.hxx new file mode 100644 index 000000000000..450e958ec179 --- /dev/null +++ b/include/svl/rngitem.hxx @@ -0,0 +1,83 @@ +/* -*- 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 _SFXRNGITEM_HXX +#define _SFXRNGITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/poolitem.hxx> + +class SvStream; + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxRangeItem : public SfxPoolItem +{ +private: + sal_uInt16 nFrom; + sal_uInt16 nTo; +public: + TYPEINFO(); + SfxRangeItem(); + SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo ); + SfxRangeItem( const SfxRangeItem& rItem ); + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + inline sal_uInt16& From() { return nFrom; } + inline sal_uInt16 From() const { return nFrom; } + inline sal_uInt16& To() { return nTo; } + inline sal_uInt16 To() const { return nTo; } + inline sal_Bool HasRange() const { return nTo>nFrom; } + virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nVersion ) const; + virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; +}; + +// ----------------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxUShortRangesItem : public SfxPoolItem +{ +private: + sal_uInt16* _pRanges; + +public: + TYPEINFO(); + SfxUShortRangesItem(); + SfxUShortRangesItem( sal_uInt16 nWID, SvStream &rStream ); + SfxUShortRangesItem( const SfxUShortRangesItem& rItem ); + virtual ~SfxUShortRangesItem(); + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + inline const sal_uInt16* GetRanges() const { return _pRanges; } + virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nVersion ) const; + virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sfontitm.hxx b/include/svl/sfontitm.hxx new file mode 100644 index 000000000000..f9bcbdc7f917 --- /dev/null +++ b/include/svl/sfontitm.hxx @@ -0,0 +1,207 @@ +/* -*- 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 _SFONTITM_HXX +#define _SFONTITM_HXX + +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <i18nlangtag/lang.h> +#include <svl/poolitem.hxx> + +//============================================================================ +class SfxFontItem: public SfxPoolItem +{ + XubString m_aName; + XubString m_aStyleName; + Size m_aSize; + Color m_aColor; + Color m_aFillColor; + rtl_TextEncoding m_nCharSet; + LanguageType m_nLanguage; + sal_Int16 m_nFamily; + sal_Int16 m_nPitch; + sal_Int16 m_nWeight; + sal_Int16 m_nWidthType; + sal_Int16 m_nItalic; + sal_Int16 m_nUnderline; + sal_Int16 m_nStrikeout; + sal_Int16 m_nOrientation; + unsigned m_bWordLine: 1; + unsigned m_bOutline: 1; + unsigned m_bShadow: 1; + unsigned m_bKerning: 1; + unsigned m_bHasFont: 1; + unsigned m_bHasColor: 1; + unsigned m_bHasFillColor: 1; + +public: + TYPEINFO(); + + inline SfxFontItem(sal_uInt16 nWhich); + + virtual int operator ==(const SfxPoolItem & rItem) const; + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const + { return new SfxFontItem(*this); } + + sal_Bool hasFont() const { return m_bHasFont; } + sal_Bool hasColor() const { return m_bHasColor; } + sal_Bool hasFillColor() const { return m_bHasFillColor; } + + const XubString & getName() const { return m_aName; } + const XubString & getStyleName() const { return m_aStyleName; } + + const Size & getSize() const { return m_aSize; } + const Color & getColor() const { return m_aColor; } + const Color & getFillColor() const { return m_aFillColor; } + + rtl_TextEncoding getCharSet() const { return m_nCharSet; } + + LanguageType getLanguage() const { return m_nLanguage; } + + sal_Int16 getFamily() const { return m_nFamily; } + sal_Int16 getPitch() const { return m_nPitch; } + sal_Int16 getWeight() const { return m_nWeight; } + sal_Int16 getWidthType() const { return m_nWidthType; } + sal_Int16 getItalic() const { return m_nItalic; } + sal_Int16 getUnderline() const { return m_nUnderline; } + sal_Int16 getStrikeout() const { return m_nStrikeout; } + sal_Int16 getOrientation() const { return m_nOrientation; } + sal_Bool getWordLine() const { return m_bWordLine; } + sal_Bool getOutline() const { return m_bOutline; } + sal_Bool getShadow() const { return m_bShadow; } + sal_Bool getKerning() const { return m_bKerning; } + + inline void setFont(sal_Int16 nTheFamily, const XubString & rTheName, + const XubString & rTheStyleName, sal_Int16 nThePitch, + rtl_TextEncoding nTheCharSet); + inline void setWeight(sal_Int16 nTheWeight); + inline void setItalic(sal_Int16 nTheItalic); + inline void setHeight(sal_Int32 nHeight); + inline void setColor(const Color & rTheColor); + inline void setFillColor(const Color & rTheFillColor); + inline void setUnderline(sal_Int16 nTheUnderline); + inline void setStrikeout(sal_Int16 nTheStrikeout); + inline void setOutline(sal_Bool bTheOutline); + inline void setShadow(sal_Bool bTheShadow); + inline void setLanguage(LanguageType nTheLanguage); +}; + +inline SfxFontItem::SfxFontItem(sal_uInt16 which): + SfxPoolItem(which), + m_nCharSet(RTL_TEXTENCODING_DONTKNOW), + m_nLanguage(LANGUAGE_DONTKNOW), + m_nFamily(0), // FAMILY_DONTKNOW + m_nPitch(0), // PITCH_DONTKNOW + m_nWeight(0), // WEIGHT_DONTKNOW + m_nWidthType(0), // WIDTH_DONTKNOW + m_nItalic(3), // ITALIC_DONTKNOW + m_nUnderline(4), // UNDERLINE_DONTKNOW + m_nStrikeout(3), // STRIKEOUT_DONTKNOW + m_nOrientation(0), + m_bWordLine(sal_False), + m_bOutline(sal_False), + m_bShadow(sal_False), + m_bKerning(sal_False), + m_bHasFont(sal_False), + m_bHasColor(sal_False), + m_bHasFillColor(sal_False) +{} + +inline void SfxFontItem::setFont(sal_Int16 nTheFamily, + const XubString & rTheName, + const XubString & rTheStyleName, + sal_Int16 nThePitch, + rtl_TextEncoding nTheCharSet) +{ + m_nFamily = nTheFamily; + m_aName = rTheName; + m_aStyleName = rTheStyleName; + m_nPitch = nThePitch; + m_nCharSet = nTheCharSet; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setWeight(sal_Int16 nTheWeight) +{ + m_nWeight = nTheWeight; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setItalic(sal_Int16 nTheItalic) +{ + m_nItalic = nTheItalic; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setHeight(sal_Int32 nHeight) +{ + m_aSize.setHeight(nHeight); + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setColor(const Color & rTheColor) +{ + m_aColor = rTheColor; + m_bHasColor = sal_True; +} + +inline void SfxFontItem::setFillColor(const Color & rTheFillColor) +{ + m_aFillColor = rTheFillColor; + m_bHasFillColor = sal_True; +} + +inline void SfxFontItem::setUnderline(sal_Int16 nTheUnderline) +{ + m_nUnderline = nTheUnderline; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setStrikeout(sal_Int16 nTheStrikeout) +{ + m_nStrikeout = nTheStrikeout; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setOutline(sal_Bool bTheOutline) +{ + m_bOutline = bTheOutline; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setShadow(sal_Bool bTheShadow) +{ + m_bShadow = bTheShadow; + m_bHasFont = sal_True; +} + +inline void SfxFontItem::setLanguage(LanguageType nTheLanguage) +{ + m_nLanguage = nTheLanguage; + m_bHasFont = sal_True; +} + +#endif // _SFONTITM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/sharecontrolfile.hxx b/include/svl/sharecontrolfile.hxx new file mode 100644 index 000000000000..d2c842d98ebb --- /dev/null +++ b/include/svl/sharecontrolfile.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SVT_SHARECONTROLFILE_HXX +#define _SVT_SHARECONTROLFILE_HXX + +#include <svl/svldllapi.h> + +#include <com/sun/star/io/XStream.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/io/XTruncate.hpp> + +#include <svl/lockfilecommon.hxx> + +#define SHARED_OOOUSERNAME_ID LOCKFILE_OOOUSERNAME_ID +#define SHARED_SYSUSERNAME_ID LOCKFILE_SYSUSERNAME_ID +#define SHARED_LOCALHOST_ID LOCKFILE_LOCALHOST_ID +#define SHARED_EDITTIME_ID LOCKFILE_EDITTIME_ID +#define SHARED_USERURL_ID LOCKFILE_USERURL_ID +#define SHARED_ENTRYSIZE LOCKFILE_ENTRYSIZE + +namespace svt { + +class SVL_DLLPUBLIC ShareControlFile : public LockFileCommon +{ + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream; + ::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; + ::com::sun::star::uno::Reference< ::com::sun::star::io::XTruncate > m_xTruncate; + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > m_aUsersData; + + void OpenStream(); + void Close(); + sal_Bool IsValid() + { + return ( m_xStream.is() && m_xInputStream.is() && m_xOutputStream.is() && m_xSeekable.is() && m_xTruncate.is() ); + } + +public: + + // The constructor will throw exception in case the stream can not be opened + ShareControlFile( const OUString& aOrigURL ); + ~ShareControlFile(); + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > > GetUsersData(); + void SetUsersDataAndStore( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< OUString > >& aUserNames ); + ::com::sun::star::uno::Sequence< OUString > InsertOwnEntry(); + bool HasOwnEntry(); + void RemoveEntry( const ::com::sun::star::uno::Sequence< OUString >& aOptionalSpecification = ::com::sun::star::uno::Sequence< OUString >() ); + void RemoveFile(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/slstitm.hxx b/include/svl/slstitm.hxx new file mode 100644 index 000000000000..90c873119b80 --- /dev/null +++ b/include/svl/slstitm.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 _SFXSLSTITM_HXX +#define _SFXSLSTITM_HXX + +#include <vector> + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> +#include <svl/poolitem.hxx> +#include <com/sun/star/uno/Sequence.h> + +class SfxImpStringList; + +class SVL_DLLPUBLIC SfxStringListItem : public SfxPoolItem +{ +protected: + SfxImpStringList* pImp; + +public: + TYPEINFO(); + + SfxStringListItem(); + SfxStringListItem( sal_uInt16 nWhich, const std::vector<String> *pList=NULL ); + SfxStringListItem( sal_uInt16 nWhich, SvStream& rStream ); + SfxStringListItem( const SfxStringListItem& rItem ); + ~SfxStringListItem(); + + std::vector<String>& GetList(); + + const std::vector<String>& GetList() const; + + // String-Separator: \n + virtual void SetString( const XubString& ); + virtual XubString GetString(); + + void SetStringList( const com::sun::star::uno::Sequence< OUString >& rList ); + void GetStringList( com::sun::star::uno::Sequence< OUString >& rList ) const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create( SvStream &, sal_uInt16 nVersion ) const; + virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; + + virtual bool PutValue ( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/smplhint.hxx b/include/svl/smplhint.hxx new file mode 100644 index 000000000000..5c74a3dc4f6e --- /dev/null +++ b/include/svl/smplhint.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 _SFXSMPLHINT_HXX +#define _SFXSMPLHINT_HXX + +#include "svl/svldllapi.h" +#include <svl/hint.hxx> +#include <tools/rtti.hxx> + +#define SFX_HINT_DYING 0x00000001 +#define SFX_HINT_NAMECHANGED 0x00000002 +#define SFX_HINT_TITLECHANGED 0x00000004 +#define SFX_HINT_DATACHANGED 0x00000008 +#define SFX_HINT_DOCCHANGED 0x00000010 +#define SFX_HINT_UPDATEDONE 0x00000020 +#define SFX_HINT_DEINITIALIZING 0x00000040 +#define SFX_HINT_MODECHANGED 0x00000080 + // unused, formerly SFX_HINT_CANCELLABLE + // unused, formerly SFX_HINT_DATAAVAILABLE + // unused, formerly SFX_HINT_SAVECOMPLETED + // unused, formerly SFX_HINT_RELEASEREF +#define SFX_HINT_COLORS_CHANGED 0x00001000 +#define SFX_HINT_CTL_SETTINGS_CHANGED 0x00002000 +#define SFX_HINT_ACCESSIBILITY_CHANGED 0x00004000 + // unused, formerly SFX_HINT_VIEWCREATED +#define SFX_HINT_USER00 0x00010000 +#define SFX_HINT_USER01 0x00020000 +#define SFX_HINT_USER02 0x00040000 +#define SFX_HINT_USER03 0x00080000 +#define SFX_HINT_USER04 0x00100000 +#define SFX_HINT_USER05 0x00200000 +#define SFX_HINT_USER06 0x00400000 +#define SFX_HINT_USER07 0x00800000 +#define SFX_HINT_USER08 0x01000000 +#define SFX_HINT_USER09 0x02000000 +#define SFX_HINT_USER10 0x04000000 +#define SFX_HINT_USER11 0x08000000 +#define SFX_HINT_USER12 0x10000000 +#define SFX_HINT_USER13 0x20000000 +#define SFX_HINT_UNDO_OPTIONS_CHANGED 0x40000000 +#define SFX_HINT_USER_OPTIONS_CHANGED 0x80000000 +#define SFX_HINT_ALL 0xFFFFFFFF + +class SVL_DLLPUBLIC SfxSimpleHint: public SfxHint +{ +private: + sal_uLong nId; +public: + TYPEINFO(); + SfxSimpleHint( sal_uLong nId ); + sal_uLong GetId() const { return nId; } +}; + +//-------------------------------------------------------------------- + +#define DECL_OBJHINT(Name, Type) \ + class Name: public SfxSimpleHint \ + { \ + Type aObj; \ + \ + public: \ + TYPEINFO(); \ + Name( sal_uInt16 nId, const Type& rObject ); \ + ~Name(); \ + const Type& GetObject() const { return aObj; } \ + } + +#define IMPL_OBJHINT(Name, Type) \ + TYPEINIT1(Name, SfxSimpleHint); \ + Name::Name( sal_uInt16 nID, const Type& rObject ): \ + SfxSimpleHint( nID ), aObj(rObject) \ + { } \ + Name::~Name() {} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc new file mode 100644 index 000000000000..05d2cedc533a --- /dev/null +++ b/include/svl/solar.hrc @@ -0,0 +1,207 @@ +/* -*- 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 _SOLAR_HRC +#define _SOLAR_HRC + +// defines ------------------------------------------------------------------ + +#define OWN_ATTR_VALUE_START 3900 +#define OWN_ATTR_VALUE_END 3990 + +#define CREATERESMGR_NAME( Name ) #Name +#define CREATERESMGR( Name ) ResMgr::CreateResMgr( CREATERESMGR_NAME( Name ) ) + +#define RID_SFX_START 260 +// RID_SFX_END 9999 + +#define RID_LIB_START 10000 +#define RID_LIB_END 19999 + +#define RID_SVX_START (RID_LIB_START) +// RID_SVX_END (RID_LIB_START+499) + +// free: 500-2999 + +#define RID_BASIC_START (RID_LIB_START+3000) +// RID_BASIC_END (RID_LIB_START+4499) + +#define RID_UUI_START (RID_LIB_START+4500) +// RID_UUI_END (RID_LIB_START+4599) + +// free: 4600-4849 + +#define RID_BASICIDE_START (RID_LIB_START+4850) +// RID_BASICIDE_END (RID_LIB_START+4949) + +#define RID_SVXITEMS_START (RID_LIB_START+4950) +#define RID_SVXITEMS_END (RID_LIB_START+5599) + +// free: 5600-5699 + +#define RID_EXTENSIONS_START (RID_LIB_START+5700) +// RID_EXTENSIONS_END (RID_LIB_START+5799) + +#define RID_EDIT_START (RID_LIB_START+5800) +#define RID_EDIT_END (RID_LIB_START+6369) + +#define RID_FPICKER_START (RID_LIB_START+6370) +// RID_FPICKER_END (RID_LIB_START+6389) + +#define RID_SVTOOLS_START (RID_LIB_START+6390) +// RID_SVTOOLS_END (RID_LIB_START+6499) + +// free: 6500-6799 + +#define RID_DLG_START (RID_LIB_START+6800) +// RID_DLG_END (RID_LIB_START+6899) + +#define RID_OFA_START (RID_LIB_START+6900) +// RID_OFA_END (RID_LIB_START+7399) + +// free: RID_LIB_START+7400 to +7449 + +#define RID_SVL_START (RID_LIB_START+7450) +// RID_SVL_END (RID_LIB_START+7899) + +#define RID_CHAOS_START (RID_LIB_START+7900) +// RID_CHAOS_END (RID_LIB_START+7999) + +#define RID_FORMS_START (RID_LIB_START+8000) +// RID_FORMS_END (RID_LIB_START+8999) + +#define RID_FORMLAYER_START (RID_LIB_START+9000) +// RID_FORMLAYER_END (RID_LIB_START+9199) + +#define RID_DBACCESS_START (RID_LIB_START+9200) +#define RID_DBACCESS_END (RID_LIB_START+9699) + +#define RID_MORE_EXTENSIONS_START (RID_LIB_START+9700) +#define RID_MORE_EXTENSIONS_END (RID_LIB_START+9999) + +// free: 10000-10199 + +#define RID_FILTER_START (RID_LIB_START+10200) +// RID_FILTER_END (RID_LIB_START+10299) + +// do *NOT* add more ranges here, RID_LIB_END is (RID_LIB_START + 10000) + +#define RID_APP_START 20000 +// RID_APP_END 31999 + +#define RID_SW_START (20000) +// RID_SW_END (25999) + +// free: 26000-26999 + +#define RID_SD_START (27000) +// RID_SD_END (27999) + +#define RID_OBJ_START (30000) +// RID_OBJ_END (32767) + +#define RID_RPT_START (RID_OBJ_START+768) +// RID_RPT_END (RID_OBJ_START+1000) + +#define RID_FORMULA_START (RID_OBJ_START+1001) +// RID_FORMULA_END (RID_OBJ_START+1200) + +// Help-Ids -------------------------------------------------------------- + +#define HID_START 32768 + +#define HID_VCL_START (HID_START+100) +// HID_VCL_END (HID_START+150) + +// free: 200-299 + +#define HID_SFX_START (HID_START+300) +// HID_SFX_END (HID_START+999) + +#define HID_LIB_START (HID_START+1000) +// HID_LIB_END (HID_START+19999) + +// free: HID_LIB_START 0-1699 + +// HID_OFA_START (HID_LIB_START+1760) +#define HID_OFA_END (HID_LIB_START+1999) + +// free: HID_LIB_START 2000-2050 + +#define HID_CHAOS_START (HID_LIB_START+2051) +// HID_CHAOS_END (HID_LIB_START+2069) + +// free: HID_LIB_START 2070-9999 + +// free: HID_START 20000-24999 + +#define HID_SC_START (HID_START+25000) +// HID_SC_END (HID_START+26999) + +#define HID_SD_START (HID_START+27000) +// HID_SD_END (HID_START+27999) + +// free: HID_START 28000-29999 + +#define HID_OBJ_START (HID_START+30000) +// HID_OBJ_END (HID_START+32767) + +// free: HID_OBJ_START+2281 to HID_OBJ_START+2800 + +// Slot Ids + +#define SID_SFX_START 5000 +// SID_SFX_END 8999 +#define SID_DOCKWIN_START 9800 +// SID_DOCKWIN_END 9999 + +#define SID_LIB_START 10000 +// SID_LIB_END 19999 +// free: 20000-29999 +#define SID_OBJ_START 30000 + +#define SID_SW_START 20000 +// SID_SW_END 25999 +#define SID_SC_START 26000 +// SID_SC_END 26999 +#define SID_SD_START 27000 +// SID_SD_END 27999 + +#define SID_SMA_START (SID_OBJ_START + 256) +// SID_SMA_END (SID_OBJ_START + 511) +// free: SID_OBJ_START + 512 to SID_OBJ_START + 767 +#define SID_BASICIDE_START (SID_OBJ_START + 768) +// SID_BASICIDE_END (SID_BASICIDE_START + 255) + +#define SID_SVX_START SID_LIB_START // 10000 +#define SID_SVX_END (SID_SVX_START + 1499) +#define SID_EDIT_START (SID_SVX_END + 1) // 11500 +#define SID_EDIT_END (SID_EDIT_START + 499) +#define SID_OPTIONS_START (SID_EDIT_END + 1) // 12000 +#define SID_OPTIONS_END (SID_OPTIONS_START + 100) +#define SID_SBA_START (SID_OPTIONS_END + 1) // 12101 +#define SID_SBA_END (SID_SBA_START + 149) +#define SID_DBACCESS_START (SID_SBA_END + 1) // 12251 +#define SID_DBACCESS_END (SID_DBACCESS_START + 200) +#define SID_RPTUI_START (SID_DBACCESS_END + 1) // 12452 +// SID_RPTUI_END (SID_RPTUI_START + 199) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/srchdefs.hxx b/include/svl/srchdefs.hxx new file mode 100644 index 000000000000..f339ebff9273 --- /dev/null +++ b/include/svl/srchdefs.hxx @@ -0,0 +1,42 @@ +/* -*- 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 _SFX_SRCHDEFS_HXX_ +#define _SFX_SRCHDEFS_HXX_ + + +#define SEARCH_OPTIONS_SEARCH ((sal_uInt16)0x0001) +#define SEARCH_OPTIONS_SEARCH_ALL ((sal_uInt16)0x0002) +#define SEARCH_OPTIONS_REPLACE ((sal_uInt16)0x0004) +#define SEARCH_OPTIONS_REPLACE_ALL ((sal_uInt16)0x0008) +#define SEARCH_OPTIONS_WHOLE_WORDS ((sal_uInt16)0x0010) +#define SEARCH_OPTIONS_BACKWARDS ((sal_uInt16)0x0020) +#define SEARCH_OPTIONS_REG_EXP ((sal_uInt16)0x0040) +#define SEARCH_OPTIONS_EXACT ((sal_uInt16)0x0080) +#define SEARCH_OPTIONS_SELECTION ((sal_uInt16)0x0100) +#define SEARCH_OPTIONS_FAMILIES ((sal_uInt16)0x0200) +#define SEARCH_OPTIONS_FORMAT ((sal_uInt16)0x0400) +#define SEARCH_OPTIONS_MORE ((sal_uInt16)0x0800) +#define SEARCH_OPTIONS_SIMILARITY ((sal_uInt16)0x1000) +#define SEARCH_OPTIONS_CONTENT ((sal_uInt16)0x2000) + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx new file mode 100644 index 000000000000..5d4413ea8cab --- /dev/null +++ b/include/svl/srchitem.hxx @@ -0,0 +1,287 @@ +/* -*- 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 _SFX_SRCHITEM_HXX +#define _SFX_SRCHITEM_HXX + +#include "sal/config.h" +#include "svl/svldllapi.h" +#include <com/sun/star/util/XSearchDescriptor.hpp> +#include <com/sun/star/util/SearchOptions.hpp> +#include <com/sun/star/util/SearchFlags.hpp> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <unotools/configitem.hxx> +#include <rsc/rscsfx.hxx> +#include <tools/string.hxx> +#include <svl/poolitem.hxx> +#include <svl/srchdefs.hxx> + +// defines --------------------------------------------------------------- + +// commands +#define SVX_SEARCHCMD_FIND ((sal_uInt16)0) +#define SVX_SEARCHCMD_FIND_ALL ((sal_uInt16)1) +#define SVX_SEARCHCMD_REPLACE ((sal_uInt16)2) +#define SVX_SEARCHCMD_REPLACE_ALL ((sal_uInt16)3) + +// search flags +#define SVX_SEARCHIN_FORMULA ((sal_uInt16)0) +#define SVX_SEARCHIN_VALUE ((sal_uInt16)1) +#define SVX_SEARCHIN_NOTE ((sal_uInt16)2) +#define SVX_SEARCHAPP_WRITER ((sal_uInt16)0) +#define SVX_SEARCHAPP_CALC ((sal_uInt16)1) +#define SVX_SEARCHAPP_DRAW ((sal_uInt16)2) +#define SVX_SEARCHAPP_BASE ((sal_uInt16)3) + +// class SvxSearchItem --------------------------------------------------- + +class SVL_DLLPUBLIC SvxSearchItem : + public SfxPoolItem, + public utl::ConfigItem +{ + com::sun::star::util::SearchOptions aSearchOpt; + + SfxStyleFamily eFamily; // Vorlagen-Familie + + sal_uInt16 nCommand; // Kommando (Suchen, Alle Suchen, Ersetzen, Alle Ersetzen) + + // Calc-Spezifische Daten + sal_uInt16 nCellType; // Suche in Formeln/Werten/Notizen + sal_uInt16 nAppFlag; // Fuer welche Applikation ist der Dialog ueberhaupt + bool bRowDirection; // Suchrichtung Zeilenweise/Spaltenweise + bool bAllTables; // in alle Tabellen suchen + bool bSearchFiltered; // search filtered cells. + + // Writer-spezifisch + bool bNotes; + + bool bBackward; // Suche Rueckwaerts + bool bPattern; // Suche nach Vorlagen + bool bContent; // Suche im Inhalt + bool bAsianOptions; // use asian options? + +public: + TYPEINFO(); + + explicit SvxSearchItem( const sal_uInt16 nId ); + SvxSearchItem( const SvxSearchItem& rItem ); + virtual ~SvxSearchItem(); + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); + virtual int operator == ( const SfxPoolItem& ) const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, const IntlWrapper * = 0 ) const; + + // ConfigItem + virtual void Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames ); + virtual void Commit(); + + sal_uInt16 GetCommand() const { return nCommand; } + void SetCommand(sal_uInt16 nNewCommand) { nCommand = nNewCommand; } + + inline const String GetSearchString() const; + inline void SetSearchString(const String& rNewString); + + inline const String GetReplaceString() const; + inline void SetReplaceString(const String& rNewString); + + inline bool GetWordOnly() const; + void SetWordOnly(bool bNewWordOnly); + + inline bool GetExact() const; + void SetExact(bool bNewExact); + + bool GetBackward() const { return bBackward; } + void SetBackward(bool bNewBackward) { bBackward = bNewBackward; } + + inline bool GetSelection() const; + void SetSelection(bool bNewSelection); + + inline bool GetRegExp() const; + void SetRegExp( bool bVal ); + + bool GetPattern() const { return bPattern; } + void SetPattern(bool bNewPattern) { bPattern = bNewPattern; } + + bool IsContent() const { return bContent; } + void SetContent( bool bNew ) { bContent = bNew; } + + SfxStyleFamily GetFamily() const { return eFamily; } + void SetFamily( SfxStyleFamily eNewFamily ) + { eFamily = eNewFamily; } + + bool GetRowDirection() const { return bRowDirection; } + void SetRowDirection(bool bNewRowDirection) { bRowDirection = bNewRowDirection; } + + bool IsAllTables() const { return bAllTables; } + void SetAllTables(bool bNew) { bAllTables = bNew; } + + bool IsSearchFiltered() const { return bSearchFiltered; } + void SetSearchFiltered(bool b) { bSearchFiltered = b; } + + sal_uInt16 GetCellType() const { return nCellType; } + void SetCellType(sal_uInt16 nNewCellType) { nCellType = nNewCellType; } + + bool GetNotes() const { return bNotes; } + void SetNotes(bool bNew) { bNotes = bNew; } + + sal_uInt16 GetAppFlag() const { return nAppFlag; } + void SetAppFlag(sal_uInt16 nNewAppFlag) { nAppFlag = nNewAppFlag; } + + inline bool IsLevenshtein() const; + void SetLevenshtein( bool bVal ); + + inline bool IsLEVRelaxed() const; + void SetLEVRelaxed(bool bSet); + + inline sal_uInt16 GetLEVOther() const; + inline void SetLEVOther(sal_uInt16 nSet); + + inline sal_uInt16 GetLEVShorter() const; + inline void SetLEVShorter(sal_uInt16 nSet); + + inline sal_uInt16 GetLEVLonger() const; + inline void SetLEVLonger(sal_uInt16 nSet); + + inline const com::sun::star::util::SearchOptions & + GetSearchOptions() const; + inline void SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt ); + + inline sal_Int32 GetTransliterationFlags() const; + void SetTransliterationFlags( sal_Int32 nFlags ); + + inline bool IsMatchFullHalfWidthForms() const; + void SetMatchFullHalfWidthForms( bool bVal ); + + inline bool IsUseAsianOptions() const { return bAsianOptions; } + inline void SetUseAsianOptions( bool bVal ) { bAsianOptions = bVal; } +}; + +const String SvxSearchItem::GetSearchString() const +{ + return aSearchOpt.searchString; +} + +void SvxSearchItem::SetSearchString(const String& rNewString) +{ + aSearchOpt.searchString = rNewString; +} + +const String SvxSearchItem::GetReplaceString() const +{ + return aSearchOpt.replaceString; +} + +void SvxSearchItem::SetReplaceString(const String& rNewString) +{ + aSearchOpt.replaceString = rNewString; +} + +bool SvxSearchItem::GetWordOnly() const +{ + return 0 != (aSearchOpt.searchFlag & + com::sun::star::util::SearchFlags::NORM_WORD_ONLY); +} + +bool SvxSearchItem::GetExact() const +{ + return 0 == (aSearchOpt.transliterateFlags & + com::sun::star::i18n::TransliterationModules_IGNORE_CASE); +} + +bool SvxSearchItem::GetSelection() const +{ + return 0 != (aSearchOpt.searchFlag & + com::sun::star::util::SearchFlags::REG_NOT_BEGINOFLINE); +} + +bool SvxSearchItem::GetRegExp() const +{ + return aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_REGEXP ; +} + +bool SvxSearchItem::IsLEVRelaxed() const +{ + return 0 != (aSearchOpt.searchFlag & + com::sun::star::util::SearchFlags::LEV_RELAXED); +} + +sal_uInt16 SvxSearchItem::GetLEVOther() const +{ + return (sal_Int16) aSearchOpt.changedChars; +} + +void SvxSearchItem::SetLEVOther( sal_uInt16 nVal ) +{ + aSearchOpt.changedChars = nVal; +} + +sal_uInt16 SvxSearchItem::GetLEVShorter() const +{ + return (sal_Int16) aSearchOpt.insertedChars; +} + +void SvxSearchItem::SetLEVShorter( sal_uInt16 nVal ) +{ + aSearchOpt.insertedChars = nVal; +} + +sal_uInt16 SvxSearchItem::GetLEVLonger() const +{ + return (sal_Int16) aSearchOpt.deletedChars; +} + +void SvxSearchItem::SetLEVLonger( sal_uInt16 nVal ) +{ + aSearchOpt.deletedChars = nVal; +} + +bool SvxSearchItem::IsLevenshtein() const +{ + return aSearchOpt.algorithmType == com::sun::star::util::SearchAlgorithms_APPROXIMATE; +} + +const com::sun::star::util::SearchOptions & SvxSearchItem::GetSearchOptions() const +{ + return aSearchOpt; +} + +void SvxSearchItem::SetSearchOptions( const com::sun::star::util::SearchOptions &rOpt ) +{ + aSearchOpt = rOpt; +} + +sal_Int32 SvxSearchItem::GetTransliterationFlags() const +{ + return aSearchOpt.transliterateFlags; +} + +bool SvxSearchItem::IsMatchFullHalfWidthForms() const +{ + return 0 != (aSearchOpt.transliterateFlags & + com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH); +} + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stritem.hxx b/include/svl/stritem.hxx new file mode 100644 index 000000000000..a4109218c79e --- /dev/null +++ b/include/svl/stritem.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _SFXSTRITEM_HXX +#define _SFXSTRITEM_HXX + +#include "svl/svldllapi.h" +#include <svl/custritm.hxx> + +//============================================================================ +class SVL_DLLPUBLIC SfxStringItem: public CntUnencodedStringItem +{ +public: + TYPEINFO(); + + SfxStringItem() {} + + SfxStringItem(sal_uInt16 which, const OUString & rValue): + CntUnencodedStringItem(which, rValue) {} + + SfxStringItem(sal_uInt16 nWhich, SvStream & rStream); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; +}; + +#endif // _SFXSTRITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/strmadpt.hxx b/include/svl/strmadpt.hxx new file mode 100644 index 000000000000..167d3696d3a2 --- /dev/null +++ b/include/svl/strmadpt.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_STRMADPT_HXX +#define SVTOOLS_STRMADPT_HXX + +#include "svl/svldllapi.h" +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <cppuhelper/weak.hxx> +#include <tools/stream.hxx> + +//============================================================================ +class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes +{ + com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > + m_xOutputStream; + sal_uInt32 m_nPosition; + +public: + TYPEINFO(); + + SvOutputStreamOpenLockBytes( + const com::sun::star::uno::Reference< + com::sun::star::io::XOutputStream > & + rTheOutputStream): + m_xOutputStream(rTheOutputStream), m_nPosition(0) {} + + virtual ErrCode ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *) const; + + virtual ErrCode WriteAt(sal_uLong nPos, const void * pBuffer, sal_uLong nCount, + sal_uLong * pWritten); + + virtual ErrCode Flush() const; + + virtual ErrCode SetSize(sal_uLong); + + virtual ErrCode Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag) const; + + virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount, + sal_uLong * pWritten); + + virtual sal_uLong Tell() const; + + virtual sal_uLong Seek(sal_uLong); + + virtual void Terminate(); +}; + +//============================================================================ +class SVL_DLLPUBLIC SvLockBytesInputStream: public cppu::OWeakObject, + public com::sun::star::io::XInputStream, + public com::sun::star::io::XSeekable +{ + SvLockBytesRef m_xLockBytes; + sal_Int64 m_nPosition; + +public: + SvLockBytesInputStream(SvLockBytes * pTheLockBytes): + m_xLockBytes(pTheLockBytes), m_nPosition(0) {} + + 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(); + + virtual sal_Int32 SAL_CALL + readBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData, + sal_Int32 nBytesToRead) + throw (com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL + readSomeBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData, + sal_Int32 nMaxBytesToRead) + throw (com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) + throw (com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL available() + throw (com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL closeInput() + throw (com::sun::star::io::IOException, + com::sun::star::uno::RuntimeException); + + 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); +}; + +#endif // SVTOOLS_STRMADPT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/style.hrc b/include/svl/style.hrc new file mode 100644 index 000000000000..352cfe18e2b0 --- /dev/null +++ b/include/svl/style.hrc @@ -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 SFX_STYLE_HRC +#define SFX_STYLE_HRC + +#define SFXSTYLEBIT_AUTO 0x0000 ///< automatic: flags from application +#define SFXSTYLEBIT_HIDDEN 0x0200 ///< hidden styles (search mask) +#define SFXSTYLEBIT_HIERARCHY 0x1000 ///< hierarchical view - just for dialog +#define SFXSTYLEBIT_READONLY 0x2000 ///< readonly styles (search mask) +#define SFXSTYLEBIT_USED 0x4000 ///< used styles (search mask) +#define SFXSTYLEBIT_USERDEF 0x8000 ///< user defined styles (search mask) +#define SFXSTYLEBIT_ALL_VISIBLE 0xFDFF ///< all styles +#define SFXSTYLEBIT_ALL 0xFFFF ///< all styles + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/style.hxx b/include/svl/style.hxx new file mode 100644 index 000000000000..af58cbc44327 --- /dev/null +++ b/include/svl/style.hxx @@ -0,0 +1,386 @@ +/* -*- 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 _SFXSTYLE_HXX +#define _SFXSTYLE_HXX + +#include <com/sun/star/style/XStyle.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <rtl/ref.hxx> +#include <vector> +#include <comphelper/weak.hxx> +#include <cppuhelper/implbase2.hxx> +#include "svl/svldllapi.h" +#include <rsc/rscsfx.hxx> +#include <tools/string.hxx> +#include <svl/hint.hxx> +#include <svl/lstner.hxx> +#include <svl/brdcst.hxx> +#include <svl/poolitem.hxx> +#include <svl/stylesheetuser.hxx> + +#include <svl/style.hrc> +#include <boost/shared_ptr.hpp> + +class SfxItemSet; +class SfxItemPool; +class SfxStyleSheetBasePool; +class SvStream; + +/* +Everyone changing instances of SfxStyleSheetBasePool or SfxStyleSheetBase +must broadcast this using <SfxStyleSheetBasePool::GetBroadcaster()> broadcasts. +The class <SfxStyleSheetHint> is used for this, it contains an Action-Id and a +pointer to the <SfxStyleSheetBase>. The actions are: + +#define SFX_STYLESHEET_CREATED // style is created +#define SFX_STYLESHEET_MODIFIED // style is modified +#define SFX_STYLESHEET_CHANGED // style is replaced +#define SFX_STYLESHEET_ERASED // style is deleted + +The following methods already broadcast themself + +SfxSimpleHint(SFX_HINT_DYING) from: + SfxStyleSheetBasePool::~SfxStyleSheetBasePool() + +SfxStyleSheetHint( SFX_STYLESHEET_CREATED, *p ) from: + SfxStyleSheetBasePool::Make( const String& rName, + SfxStyleFamily eFam, sal_uInt16 mask, sal_uInt16 nPos) + +SfxStyleSheetHint( SFX_STYLESHEET_CHANGED, *pNew ) from: + SfxStyleSheetBasePool::Add( SfxStyleSheetBase& rSheet ) + +SfxStyleSheetHint( SFX_STYLESHEET_ERASED, *p ) from: + SfxStyleSheetBasePool::Erase( SfxStyleSheetBase* p ) + SfxStyleSheetBasePool::Clear() +*/ + +class SVL_DLLPUBLIC SfxStyleSheetBase : public comphelper::OWeakTypeObject +{ +private: + friend class SfxStyleSheetBasePool; + SVL_DLLPRIVATE static SfxStyleSheetBasePool& implGetStaticPool(); + +protected: + SfxStyleSheetBasePool* pPool; // zugehoeriger Pool + SfxStyleFamily nFamily; // Familie + + UniString aName, aParent, aFollow; + OUString maDisplayName; + OUString aHelpFile; // Name der Hilfedatei + SfxItemSet* pSet; // ItemSet + sal_uInt16 nMask; // Flags + + sal_uLong nHelpId; // Hilfe-ID + + bool bMySet; // sal_True: Set loeschen im dtor + bool bHidden; + + SfxStyleSheetBase( const UniString&, SfxStyleSheetBasePool*, SfxStyleFamily eFam, sal_uInt16 mask ); + SfxStyleSheetBase( const SfxStyleSheetBase& ); + virtual ~SfxStyleSheetBase(); + virtual void Load( SvStream&, sal_uInt16 ); + virtual void Store( SvStream& ); + +public: + TYPEINFO(); + + // returns the internal name of this style + virtual const UniString& GetName() const; + + // sets the internal name of this style + virtual bool SetName( const UniString& ); + + /** returns the display name of this style, it is used at the user interface. + If the display name is empty, this method returns the internal name. */ + virtual OUString GetDisplayName() const; + + // sets the display name of this style + virtual void SetDisplayName( const OUString& ); + + virtual const UniString& GetParent() const; + virtual bool SetParent( const UniString& ); + virtual const UniString& GetFollow() const; + virtual bool SetFollow( const UniString& ); + virtual bool HasFollowSupport() const; // Default true + virtual bool HasParentSupport() const; // Default true + virtual bool HasClearParentSupport() const; // Default false + virtual bool IsUsed() const; // Default true + // Default aus dem Itemset; entweder dem uebergebenen + // oder aus dem per GetItemSet() zurueckgelieferten Set + virtual UniString GetDescription(); + virtual UniString GetDescription( SfxMapUnit eMetric ); + + SfxStyleSheetBasePool& GetPool() { return *pPool; } + SfxStyleFamily GetFamily() const { return nFamily; } + sal_uInt16 GetMask() const { return nMask; } + void SetMask( sal_uInt16 mask) { nMask = mask; } + bool IsUserDefined() const + { return ( nMask & SFXSTYLEBIT_USERDEF) != 0; } + + virtual sal_Bool IsHidden() const { return bHidden; } + virtual void SetHidden( sal_Bool bValue ); + + virtual sal_uLong GetHelpId( OUString& rFile ); + virtual void SetHelpId( const OUString& r, sal_uLong nId ); + + virtual SfxItemSet& GetItemSet(); + virtual sal_uInt16 GetVersion() const; +}; + +//========================================================================= + +typedef std::vector< rtl::Reference< SfxStyleSheetBase > > SfxStyles; + +//========================================================================= + +class SVL_DLLPUBLIC SfxStyleSheetIterator + +/* [Beschreibung] + + Klasse zum Iterieren und Suchen auf einem SfxStyleSheetBasePool. + +*/ + +{ +public: + SfxStyleSheetIterator(SfxStyleSheetBasePool *pBase, + SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); + virtual sal_uInt16 GetSearchMask() const; + virtual SfxStyleFamily GetSearchFamily() const; + virtual sal_uInt16 Count(); + virtual SfxStyleSheetBase *operator[](sal_uInt16 nIdx); + virtual SfxStyleSheetBase* First(); + virtual SfxStyleSheetBase* Next(); + virtual SfxStyleSheetBase* Find(const OUString& rStr); + virtual ~SfxStyleSheetIterator(); + +protected: + + SfxStyleSheetBasePool* pBasePool; + SfxStyleFamily nSearchFamily; + sal_uInt16 nMask; + + bool SearchUsed() const { return bSearchUsed; } + +private: + sal_uInt16 GetPos() { return nAktPosition; } + SVL_DLLPRIVATE bool IsTrivialSearch(); + SVL_DLLPRIVATE bool DoesStyleMatch(SfxStyleSheetBase *pStyle); + + SfxStyleSheetBase* pAktStyle; + sal_uInt16 nAktPosition; + bool bSearchUsed; + +friend class SfxStyleSheetBasePool; +}; + +typedef ::boost::shared_ptr< SfxStyleSheetIterator > SfxStyleSheetIteratorPtr; +//========================================================================= + +class SfxStyleSheetBasePool_Impl; + +class SVL_DLLPUBLIC SfxStyleSheetBasePool: public SfxBroadcaster, public comphelper::OWeakTypeObject +{ +friend class SfxStyleSheetIterator; +friend class SfxStyleSheetBase; + + SfxStyleSheetBasePool_Impl *pImp; + +private: + SVL_DLLPRIVATE SfxStyleSheetIterator& GetIterator_Impl(); +protected: + String aAppName; + SfxItemPool& rPool; + SfxStyles aStyles; + SfxStyleFamily nSearchFamily; + sal_uInt16 nMask; + + SfxStyleSheetBase& Add( SfxStyleSheetBase& ); + void ChangeParent( const UniString&, const UniString&, bool bVirtual = true ); + virtual SfxStyleSheetBase* Create( const UniString&, SfxStyleFamily, sal_uInt16 ); + virtual SfxStyleSheetBase* Create( const SfxStyleSheetBase& ); + + virtual ~SfxStyleSheetBasePool(); + +public: + SfxStyleSheetBasePool( SfxItemPool& ); + SfxStyleSheetBasePool( const SfxStyleSheetBasePool& ); + + const String& GetAppName() const { return aAppName; } + + SfxItemPool& GetPool(); + const SfxItemPool& GetPool() const; + + virtual SfxStyleSheetIteratorPtr CreateIterator(SfxStyleFamily, sal_uInt16 nMask); + virtual sal_uInt16 Count(); + virtual SfxStyleSheetBase* operator[](sal_uInt16 nIdx); + + virtual SfxStyleSheetBase& Make(const UniString&, + SfxStyleFamily eFam, + sal_uInt16 nMask = SFXSTYLEBIT_ALL , + sal_uInt16 nPos = 0xffff); + + virtual void Replace( + SfxStyleSheetBase& rSource, SfxStyleSheetBase& rTarget ); + + virtual void Remove( SfxStyleSheetBase* ); + virtual void Insert( SfxStyleSheetBase* ); + + virtual void Clear(); + + SfxStyleSheetBasePool& operator=( const SfxStyleSheetBasePool& ); + SfxStyleSheetBasePool& operator+=( const SfxStyleSheetBasePool& ); + + const SfxStyles& GetStyles(); + virtual SfxStyleSheetBase* First(); + virtual SfxStyleSheetBase* Next(); + virtual SfxStyleSheetBase* Find( const UniString&, SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); + + virtual bool SetParent(SfxStyleFamily eFam, + const UniString &rStyle, + const UniString &rParent); + + SfxStyleSheetBase* Find(const UniString& rStr) + { return Find(rStr, nSearchFamily, nMask); } + + void SetSearchMask(SfxStyleFamily eFam, sal_uInt16 n=SFXSTYLEBIT_ALL ); + sal_uInt16 GetSearchMask() const; + SfxStyleFamily GetSearchFamily() const { return nSearchFamily; } +}; + +//========================================================================= + +class SVL_DLLPUBLIC SfxStyleSheet: public SfxStyleSheetBase, + public SfxListener, public SfxBroadcaster, public svl::StyleSheetUser +{ +public: + TYPEINFO(); + + SfxStyleSheet( const UniString&, const SfxStyleSheetBasePool&, SfxStyleFamily, sal_uInt16 ); + SfxStyleSheet( const SfxStyleSheet& ); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + + virtual bool isUsedByModel() const; + + virtual bool SetParent( const UniString& ); + +protected: + SfxStyleSheet() // do not use! needed by MSVC at compile time to satisfy ImplInheritanceHelper2 + : SfxStyleSheetBase(OUString("dummy"), + NULL, SFX_STYLE_FAMILY_ALL, 0) + { + assert(false); + } + virtual ~SfxStyleSheet(); +}; + +//========================================================================= + +class SVL_DLLPUBLIC SfxStyleSheetPool: public SfxStyleSheetBasePool +{ +protected: + using SfxStyleSheetBasePool::Create; + virtual SfxStyleSheetBase* Create(const UniString&, SfxStyleFamily, sal_uInt16 mask); + virtual SfxStyleSheetBase* Create(const SfxStyleSheet &); + +public: + SfxStyleSheetPool( SfxItemPool const& ); + +// virtual sal_Bool CopyTo(SfxStyleSheetPool &rDest, const String &rSourceName); +}; + +//========================================================================= + +#define SFX_STYLESHEET_CREATED 1 // neu +#define SFX_STYLESHEET_MODIFIED 2 // ver"andert +#define SFX_STYLESHEET_CHANGED 3 // gel"oscht und neu (ausgetauscht) +#define SFX_STYLESHEET_ERASED 4 // gel"oscht +#define SFX_STYLESHEET_INDESTRUCTION 5 // wird gerade entfernt + +#define SFX_STYLESHEETPOOL_CHANGES 1 // Aenderungen, die den Zustand + // des Pools anedern, aber nicht + // ueber die STYLESHEET Hints + // verschickt werden sollen. + +//======================================================================== + +class SVL_DLLPUBLIC SfxStyleSheetPoolHint : public SfxHint +{ + sal_uInt16 nHint; + +public: + TYPEINFO(); + + SfxStyleSheetPoolHint(sal_uInt16 nArgHint) : nHint(nArgHint){} + sal_uInt16 GetHint() const + { return nHint; } +}; + +//========================================================================= + +class SVL_DLLPUBLIC SfxStyleSheetHint: public SfxHint +{ + SfxStyleSheetBase* pStyleSh; + sal_uInt16 nHint; + +public: + TYPEINFO(); + + SfxStyleSheetHint( sal_uInt16, SfxStyleSheetBase& ); + SfxStyleSheetBase* GetStyleSheet() const + { return pStyleSh; } + sal_uInt16 GetHint() const + { return nHint; } +}; + +class SVL_DLLPUBLIC SfxStyleSheetHintExtended: public SfxStyleSheetHint +{ + String aName; + +public: + TYPEINFO(); + + SfxStyleSheetHintExtended( + sal_uInt16, const String& rOld, + SfxStyleSheetBase& ); + const String& GetOldName() { return aName; } +}; + +class SVL_DLLPUBLIC SfxUnoStyleSheet : public ::cppu::ImplInheritanceHelper2< SfxStyleSheet, ::com::sun::star::style::XStyle, ::com::sun::star::lang::XUnoTunnel > +{ +public: + SfxUnoStyleSheet( const UniString& _rName, const SfxStyleSheetBasePool& _rPool, SfxStyleFamily _eFamily, sal_uInt16 _nMaske ); + + static SfxUnoStyleSheet* getUnoStyleSheet( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle ); + + // XUnoTunnel + virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException); + +private: + SfxUnoStyleSheet(); // not implemented + + static const ::com::sun::star::uno::Sequence< ::sal_Int8 >& getIdentifier(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stylepool.hxx b/include/svl/stylepool.hxx new file mode 100644 index 000000000000..deaed2591a83 --- /dev/null +++ b/include/svl/stylepool.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 INCLUDED_SVTOOLS_STYLEPOOL_HXX +#define INCLUDED_SVTOOLS_STYLEPOOL_HXX + +#include <boost/shared_ptr.hpp> +#include <rtl/ustring.hxx> +#include <svl/itemset.hxx> + +class StylePoolImpl; +class IStylePoolIteratorAccess; + +class SVL_DLLPUBLIC StylePool +{ +private: + StylePoolImpl *pImpl; +public: + typedef boost::shared_ptr<SfxItemSet> SfxItemSet_Pointer_t; + + explicit StylePool( SfxItemSet* pIgnorableItems = 0 ); + + /** Insert a SfxItemSet into the style pool. + + The pool makes a copy of the provided SfxItemSet. + + @param SfxItemSet + the SfxItemSet to insert + + @return a shared pointer to the SfxItemSet + */ + virtual SfxItemSet_Pointer_t insertItemSet( const SfxItemSet& rSet ); + + /** Create an iterator + + The iterator walks through the StylePool + OD 2008-03-07 #i86923# + introduce optional parameter to control, if unused SfxItemsSet are skipped or not + introduce optional parameter to control, if ignorable items are skipped or not + + @attention every change, e.g. destruction, of the StylePool could cause undefined effects. + + @param bSkipUnusedItemSets + input parameter - boolean, indicating if unused SfxItemSets are skipped or not + + @param bSkipIgnorableItems + input parameter - boolean, indicating if ignorable items are skipped or not + + @postcond the iterator "points before the first" SfxItemSet of the pool. + The first StylePoolIterator::getNext() call will deliver the first SfxItemSet. + */ + virtual IStylePoolIteratorAccess* createIterator( const bool bSkipUnusedItemSets = false, + const bool bSkipIgnorableItems = false ); + + /** Returns the number of styles + */ + virtual sal_Int32 getCount() const; + + virtual ~StylePool(); + + static OUString nameOf( SfxItemSet_Pointer_t pSet ); +}; + +class SVL_DLLPUBLIC IStylePoolIteratorAccess +{ +public: + /** Delivers a shared pointer to the next SfxItemSet of the pool + If there is no more SfxItemSet, the delivered share_pointer is empty. + */ + virtual StylePool::SfxItemSet_Pointer_t getNext() = 0; + virtual OUString getName() = 0; + virtual ~IStylePoolIteratorAccess() {}; +}; +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/stylesheetuser.hxx b/include/svl/stylesheetuser.hxx new file mode 100644 index 000000000000..787263ff4a8e --- /dev/null +++ b/include/svl/stylesheetuser.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef SVL_STYLESHEETUSER_HXX_INCLUDED +#define SVL_STYLESHEETUSER_HXX_INCLUDED + +namespace svl +{ + +/** Test whether object that uses a stylesheet is used itself. + + This interface should be implemented by all classes that use + a SfxStyleSheet (and listen on it). It can be queried by the stylesheet + to determine if it is really used. + */ +class StyleSheetUser +{ +public: + /** Test whether this object is used. + + @return true, if the object is used, false otherwise + */ + virtual bool isUsedByModel() const = 0; +protected: + ~StyleSheetUser() {} +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svdde.hxx b/include/svl/svdde.hxx new file mode 100644 index 000000000000..c8a08beffbb9 --- /dev/null +++ b/include/svl/svdde.hxx @@ -0,0 +1,416 @@ +/* -*- 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 _SVDDE_HXX +#define _SVDDE_HXX + +#include "svl/svldllapi.h" +#include <sot/exchange.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <vector> + +class DdeString; +class DdeData; +class DdeConnection; +class DdeTransaction; +class DdeLink; +class DdeRequest; +class DdeWarmLink; +class DdeHotLink; +class DdePoke; +class DdeExecute; +class DdeItem; +class DdeTopic; +class DdeService; +struct DdeDataImp; +struct DdeImp; +class DdeItemImp; +struct Conversation; + +typedef ::std::vector< DdeService* > DdeServices; +typedef ::std::vector< long > DdeFormats; +typedef ::std::vector< Conversation* > ConvList; + +// ----------- +// - DdeData - +// ----------- + +class SVL_DLLPUBLIC DdeData +{ + friend class DdeInternal; + friend class DdeService; + friend class DdeConnection; + friend class DdeTransaction; + DdeDataImp* pImp; + + SVL_DLLPRIVATE void Lock(); + + void SetFormat( sal_uLong nFmt ); + +public: + DdeData(); + DdeData( SAL_UNUSED_PARAMETER const void*, SAL_UNUSED_PARAMETER long, SAL_UNUSED_PARAMETER sal_uLong = FORMAT_STRING ); + DdeData( SAL_UNUSED_PARAMETER const String& ); + DdeData( const DdeData& ); + ~DdeData(); + + operator const void*() const; + operator long() const; + + sal_uLong GetFormat() const; + + DdeData& operator = ( const DdeData& ); + + static sal_uLong GetExternalFormat( sal_uLong nFmt ); + static sal_uLong GetInternalFormat( sal_uLong nFmt ); +}; + +// ------------------ +// - DdeTransaction - +// ------------------ + +class SVL_DLLPUBLIC DdeTransaction +{ +public: + virtual void Data( const DdeData* ); + virtual void Done( sal_Bool bDataValid ); +protected: + DdeConnection& rDde; + DdeData aDdeData; + DdeString* pName; + short nType; + long nId; + long nTime; + Link aData; + Link aDone; + bool bBusy; + + DdeTransaction( DdeConnection&, SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER long = 0 ); + +public: + virtual ~DdeTransaction(); + + bool IsBusy() { return bBusy; } + const OUString GetName() const; + + void Execute(); + + void SetDataHdl( const Link& rLink ) { aData = rLink; } + const Link& GetDataHdl() const { return aData; } + + void SetDoneHdl( const Link& rLink ) { aDone = rLink; } + const Link& GetDoneHdl() const { return aDone; } + + void SetFormat( sal_uLong nFmt ) { aDdeData.SetFormat( nFmt ); } + sal_uLong GetFormat() const { return aDdeData.GetFormat(); } + + long GetError(); + +private: + friend class DdeInternal; + friend class DdeConnection; + + DdeTransaction( const DdeTransaction& ); + const DdeTransaction& operator= ( const DdeTransaction& ); + +}; + +// ----------- +// - DdeLink - +// ----------- + +class SVL_DLLPUBLIC DdeLink : public DdeTransaction +{ + Link aNotify; + +public: + DdeLink( DdeConnection&, const String&, long = 0 ); + virtual ~DdeLink(); + + void SetNotifyHdl( const Link& rLink ) { aNotify = rLink; } + const Link& GetNotifyHdl() const { return aNotify; } + virtual void Notify(); +}; + +// --------------- +// - DdeWarmLink - +// --------------- + +class SVL_DLLPUBLIC DdeWarmLink : public DdeLink +{ +public: + DdeWarmLink( DdeConnection&, const String&, long = 0 ); +}; + +// -------------- +// - DdeHotLink - +// -------------- + +class SVL_DLLPUBLIC DdeHotLink : public DdeLink +{ +public: + DdeHotLink( DdeConnection&, const String&, long = 0 ); +}; + +// -------------- +// - DdeRequest - +// -------------- + +class SVL_DLLPUBLIC DdeRequest : public DdeTransaction +{ +public: + DdeRequest( DdeConnection&, const String&, long = 0 ); +}; + +// ----------- +// - DdePoke - +// ----------- + +class SVL_DLLPUBLIC DdePoke : public DdeTransaction +{ +public: + DdePoke( DdeConnection&, const String&, const char*, long, + sal_uLong = FORMAT_STRING, long = 0 ); + DdePoke( DdeConnection&, const String&, SAL_UNUSED_PARAMETER const DdeData&, long = 0 ); + DdePoke( DdeConnection&, const String&, const String&, long = 0 ); +}; + +// -------------- +// - DdeExecute - +// -------------- + +class SVL_DLLPUBLIC DdeExecute : public DdeTransaction +{ +public: + DdeExecute( DdeConnection&, const String&, long = 0 ); +}; + +// ----------------- +// - DdeConnection - +// ----------------- + +class SVL_DLLPUBLIC DdeConnection +{ + friend class DdeInternal; + friend class DdeTransaction; + std::vector<DdeTransaction*> aTransactions; + DdeString* pService; + DdeString* pTopic; + DdeImp* pImp; + +public: + DdeConnection( SAL_UNUSED_PARAMETER const String&, SAL_UNUSED_PARAMETER const String& ); + ~DdeConnection(); + + long GetError(); + long GetConvId(); + + static const std::vector<DdeConnection*>& GetConnections(); + + sal_Bool IsConnected(); + + const String& GetServiceName(); + const String& GetTopicName(); + +private: + DdeConnection( const DdeConnection& ); + const DdeConnection& operator= ( const DdeConnection& ); +}; + +// ----------- +// - DdeItem - +// ----------- + +class SVL_DLLPUBLIC DdeItem +{ + friend class DdeInternal; + friend class DdeTopic; + DdeString* pName; + DdeTopic* pMyTopic; + DdeItemImp* pImpData; + + void IncMonitor( sal_uLong ); + void DecMonitor( sal_uLong ); + +protected: + sal_uInt8 nType; + +public: + DdeItem( const sal_Unicode* ); + DdeItem( SAL_UNUSED_PARAMETER const String& ); + DdeItem( const DdeItem& ); + virtual ~DdeItem(); + + const OUString GetName() const; + short GetLinks(); + void NotifyClient(); +}; + +// ----------- +// - DdeItem - +// ----------- + +class SVL_DLLPUBLIC DdeGetPutItem : public DdeItem +{ +public: + DdeGetPutItem( const sal_Unicode* p ); + DdeGetPutItem( const String& rStr ); + DdeGetPutItem( const DdeItem& rItem ); + + virtual DdeData* Get( sal_uLong ); + virtual sal_Bool Put( const DdeData* ); + virtual void AdviseLoop( sal_Bool ); // AdviseLoop starten/stoppen +}; + +// ------------ +// - DdeTopic - +// ------------ + +class SVL_DLLPUBLIC DdeTopic +{ + SVL_DLLPRIVATE void _Disconnect( long ); + +public: + virtual void Connect( long ); + virtual void Disconnect( long ); + virtual DdeData* Get( sal_uLong ); + virtual sal_Bool Put( const DdeData* ); + virtual sal_Bool Execute( const String* ); + // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden + virtual sal_Bool MakeItem( const OUString& rItem ); + + // es wird ein Warm-/Hot-Link eingerichtet. Return-Wert + // besagt ob es geklappt hat + virtual sal_Bool StartAdviseLoop(); + virtual sal_Bool StopAdviseLoop(); + +private: + friend class DdeInternal; + friend class DdeService; + friend class DdeItem; + +private: + DdeString* pName; + OUString aItem; + std::vector<DdeItem*> aItems; + Link aConnectLink; + Link aDisconnectLink; + Link aGetLink; + Link aPutLink; + Link aExecLink; + +public: + DdeTopic( SAL_UNUSED_PARAMETER const OUString& ); + virtual ~DdeTopic(); + + const OUString GetName() const; + long GetConvId(); + + void SetConnectHdl( const Link& rLink ) { aConnectLink = rLink; } + const Link& GetConnectHdl() const { return aConnectLink; } + void SetDisconnectHdl( const Link& rLink ) { aDisconnectLink = rLink; } + const Link& GetDisconnectHdl() const { return aDisconnectLink; } + void SetGetHdl( const Link& rLink ) { aGetLink = rLink; } + const Link& GetGetHdl() const { return aGetLink; } + void SetPutHdl( const Link& rLink ) { aPutLink = rLink; } + const Link& GetPutHdl() const { return aPutLink; } + void SetExecuteHdl( const Link& rLink ) { aExecLink = rLink; } + const Link& GetExecuteHdl() const { return aExecLink; } + + void NotifyClient( const String& ); + sal_Bool IsSystemTopic(); + + void InsertItem( DdeItem* ); // fuer eigene Ableitungen! + DdeItem* AddItem( const DdeItem& ); // werden kopiert ! + void RemoveItem( const DdeItem& ); + const OUString& GetCurItem() { return aItem; } + const std::vector<DdeItem*>& GetItems() const { return aItems; } + +private: + DdeTopic( const DdeTopic& ); + const DdeTopic& operator= ( const DdeTopic& ); +}; + +// -------------- +// - DdeService - +// -------------- + +class SVL_DLLPUBLIC DdeService +{ + friend class DdeInternal; + +public: + virtual sal_Bool IsBusy(); + virtual String GetHelp(); + // evt. ein neues anlegen; return 0 -> es konnte nicht angelegt werden + virtual sal_Bool MakeTopic( const OUString& rItem ); + +protected: + virtual String Topics(); + virtual String Formats(); + virtual String SysItems(); + virtual String Status(); + virtual String SysTopicGet( const String& ); + virtual sal_Bool SysTopicExecute( const String* ); + + const DdeTopic* GetSysTopic() const { return pSysTopic; } +private: + std::vector<DdeTopic*> aTopics; + DdeFormats aFormats; + DdeTopic* pSysTopic; + DdeString* pName; + ConvList* pConv; + short nStatus; + + SVL_DLLPRIVATE sal_Bool HasCbFormat( sal_uInt16 ); + +public: + DdeService( SAL_UNUSED_PARAMETER const String& ); + virtual ~DdeService(); + + const OUString GetName() const; + short GetError() { return nStatus; } + + static DdeServices& GetServices(); + std::vector<DdeTopic*>& GetTopics() { return aTopics; } + + void AddTopic( const DdeTopic& ); + void RemoveTopic( const DdeTopic& ); + + void AddFormat( sal_uLong ); + void RemoveFormat( sal_uLong ); + sal_Bool HasFormat( sal_uLong ); + +private: + // DdeService( const DdeService& ); + //int operator= ( const DdeService& ); +}; + +// ------------------ +// - DdeTransaction - +// ------------------ + +inline long DdeTransaction::GetError() +{ + return rDde.GetError(); +} +#endif // _SVDDE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc new file mode 100644 index 000000000000..407fd6783c0f --- /dev/null +++ b/include/svl/svl.hrc @@ -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 _SVL_HRC +#define _SVL_HRC + +#include <svl/solar.hrc> + +#define STR_SVT_MIMETYPE_START (RID_SVL_START) +#define STR_SVT_MIMETYPE_APP_OCTSTREAM (STR_SVT_MIMETYPE_START+0) +#define STR_SVT_MIMETYPE_APP_PDF (STR_SVT_MIMETYPE_START+1) +#define STR_SVT_MIMETYPE_APP_RTF (STR_SVT_MIMETYPE_START+2) +#define STR_SVT_MIMETYPE_APP_MSWORD (STR_SVT_MIMETYPE_START+3) +#define STR_SVT_MIMETYPE_APP_STARCALC (STR_SVT_MIMETYPE_START+4) +#define STR_SVT_MIMETYPE_APP_STARCHART (STR_SVT_MIMETYPE_START+5) +#define STR_SVT_MIMETYPE_APP_STARDRAW (STR_SVT_MIMETYPE_START+6) +#define STR_SVT_MIMETYPE_APP_STARIMAGE (STR_SVT_MIMETYPE_START+7) +#define STR_SVT_MIMETYPE_APP_STARMATH (STR_SVT_MIMETYPE_START+8) +#define STR_SVT_MIMETYPE_APP_STARWRITER (STR_SVT_MIMETYPE_START+9) +#define STR_SVT_MIMETYPE_APP_ZIP (STR_SVT_MIMETYPE_START+10) +#define STR_SVT_MIMETYPE_AUDIO_AIFF (STR_SVT_MIMETYPE_START+11) +#define STR_SVT_MIMETYPE_AUDIO_BASIC (STR_SVT_MIMETYPE_START+12) +#define STR_SVT_MIMETYPE_AUDIO_VORBIS (STR_SVT_MIMETYPE_START+13) +#define STR_SVT_MIMETYPE_AUDIO_MIDI (STR_SVT_MIMETYPE_START+14) +#define STR_SVT_MIMETYPE_AUDIO_WAV (STR_SVT_MIMETYPE_START+15) +#define STR_SVT_MIMETYPE_IMAGE_GIF (STR_SVT_MIMETYPE_START+16) +#define STR_SVT_MIMETYPE_IMAGE_JPEG (STR_SVT_MIMETYPE_START+17) +#define STR_SVT_MIMETYPE_IMAGE_PCX (STR_SVT_MIMETYPE_START+18) +#define STR_SVT_MIMETYPE_IMAGE_BMP (STR_SVT_MIMETYPE_START+19) +#define STR_SVT_MIMETYPE_TEXT_HTML (STR_SVT_MIMETYPE_START+20) +#define STR_SVT_MIMETYPE_TEXT_PLAIN (STR_SVT_MIMETYPE_START+21) +#define STR_SVT_MIMETYPE_TEXT_URL (STR_SVT_MIMETYPE_START+22) +#define STR_SVT_MIMETYPE_TEXT_VCARD (STR_SVT_MIMETYPE_START+23) +#define STR_SVT_MIMETYPE_VIDEO_THEORA (STR_SVT_MIMETYPE_START+24) +#define STR_SVT_MIMETYPE_VIDEO_VDO (STR_SVT_MIMETYPE_START+25) +#define STR_SVT_MIMETYPE_VIDEO_MSVIDEO (STR_SVT_MIMETYPE_START+26) +#define STR_SVT_MIMETYPE_X_STARMAIL (STR_SVT_MIMETYPE_START+27) +#define STR_SVT_MIMETYPE_X_VRML (STR_SVT_MIMETYPE_START+28) +#define STR_SVT_MIMETYPE_APP_STARHELP (STR_SVT_MIMETYPE_START+29) +#define STR_SVT_MIMETYPE_APP_STARIMPRESS (STR_SVT_MIMETYPE_START+30) + +#define STR_SVT_MIMETYPE_CNT_FSYSBOX (STR_SVT_MIMETYPE_START+35) +#define STR_SVT_MIMETYPE_CNT_FSYSFLD (STR_SVT_MIMETYPE_START+36) +#define STR_SVT_MIMETYPE_APP_GAL (STR_SVT_MIMETYPE_START+37) +#define STR_SVT_MIMETYPE_APP_GAL_THEME (STR_SVT_MIMETYPE_START+38) +#define STR_SVT_MIMETYPE_APP_STARW_GLOB (STR_SVT_MIMETYPE_START+39) +#define STR_SVT_MIMETYPE_APP_SDM (STR_SVT_MIMETYPE_START+40) +#define STR_SVT_MIMETYPE_APP_SMD (STR_SVT_MIMETYPE_START+41) +#define STR_SVT_MIMETYPE_APP_STARW_WEB (STR_SVT_MIMETYPE_START+42) +#define STR_SVT_MIMETYPE_SCHEDULE (STR_SVT_MIMETYPE_START+43) +#define STR_SVT_MIMETYPE_SCHEDULE_EVT (STR_SVT_MIMETYPE_START+44) +#define STR_SVT_MIMETYPE_SCHEDULE_TASK (STR_SVT_MIMETYPE_START+45) +#define STR_SVT_MIMETYPE_SCHEDULE_FEVT (STR_SVT_MIMETYPE_START+46) +#define STR_SVT_MIMETYPE_SCHEDULE_FTASK (STR_SVT_MIMETYPE_START+47) +#define STR_SVT_MIMETYPE_FRAMESET (STR_SVT_MIMETYPE_START+48) +#define STR_SVT_MIMETYPE_MACRO (STR_SVT_MIMETYPE_START+49) +#define STR_SVT_MIMETYPE_CNT_SFSYSFOLDER (STR_SVT_MIMETYPE_START+50) +#define STR_SVT_MIMETYPE_APP_TEMPLATE (STR_SVT_MIMETYPE_START+51) +#define STR_SVT_MIMETYPE_IMAGE_GENERIC (STR_SVT_MIMETYPE_START+52) +#define STR_SVT_MIMETYPE_APP_MSEXCEL (STR_SVT_MIMETYPE_START+53) +#define STR_SVT_MIMETYPE_APP_MSEXCEL_TEMPL (STR_SVT_MIMETYPE_START+54) +#define STR_SVT_MIMETYPE_APP_MSPPOINT (STR_SVT_MIMETYPE_START+55) +#define STR_SVT_MIMETYPE_TEXT_VCALENDAR (STR_SVT_MIMETYPE_START+56) +#define STR_SVT_MIMETYPE_TEXT_ICALENDAR (STR_SVT_MIMETYPE_START+57) +#define STR_SVT_MIMETYPE_TEXT_XMLICALENDAR (STR_SVT_MIMETYPE_START+58) +#define STR_SVT_MIMETYPE_TEXT_CDE_CALENDAR_APP (STR_SVT_MIMETYPE_START+59) +#define STR_SVT_MIMETYPE_INET_MSG_RFC822 (STR_SVT_MIMETYPE_START+60) +#define STR_SVT_MIMETYPE_INET_MULTI_ALTERNATIVE (STR_SVT_MIMETYPE_START+61) +#define STR_SVT_MIMETYPE_INET_MULTI_DIGEST (STR_SVT_MIMETYPE_START+62) +#define STR_SVT_MIMETYPE_INET_MULTI_PARALLEL (STR_SVT_MIMETYPE_START+63) +#define STR_SVT_MIMETYPE_INET_MULTI_RELATED (STR_SVT_MIMETYPE_START+64) +#define STR_SVT_MIMETYPE_INET_MULTI_MIXED (STR_SVT_MIMETYPE_START+65) +#define STR_SVT_MIMETYPE_APP_IMPRESSPACKED (STR_SVT_MIMETYPE_START+66) +#define STR_SVT_MIMETYPE_APP_JAR (STR_SVT_MIMETYPE_START+67) +#define STR_SVT_MIMETYPE_IMAGE_PNG (STR_SVT_MIMETYPE_START+68) +#define STR_SVT_MIMETYPE_IMAGE_TIFF (STR_SVT_MIMETYPE_START+69) + +#define STR_SVT_MIMETYPE_APP_SXCALC (STR_SVT_MIMETYPE_START+70) +#define STR_SVT_MIMETYPE_APP_SXCHART (STR_SVT_MIMETYPE_START+71) +#define STR_SVT_MIMETYPE_APP_SXDRAW (STR_SVT_MIMETYPE_START+72) +#define STR_SVT_MIMETYPE_APP_SXMATH (STR_SVT_MIMETYPE_START+73) +#define STR_SVT_MIMETYPE_APP_SXWRITER (STR_SVT_MIMETYPE_START+74) +#define STR_SVT_MIMETYPE_APP_SXIMPRESS (STR_SVT_MIMETYPE_START+75) +#define STR_SVT_MIMETYPE_APP_SXGLOBAL (STR_SVT_MIMETYPE_START+76) +#define STR_SVT_MIMETYPE_APP_SXIPACKED (STR_SVT_MIMETYPE_START+77) + + +#define STR_SVT_MIMETYPE_VIDEO_WEBM (STR_SVT_MIMETYPE_START+78) +#define STR_SVT_MIMETYPE_AUDIO_WEBM (STR_SVT_MIMETYPE_START+79) + +#define STR_SVT_MIMETYPE_END (STR_SVT_MIMETYPE_AUDIO_WEBM) + +#define STR_COLUM_DT_AUTO (STR_SVT_MIMETYPE_END+1) + +#endif // #ifndef _SVTOOLS_HRC + +// ******************************************************************* EOF + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/svldllapi.h b/include/svl/svldllapi.h new file mode 100644 index 000000000000..5d0feda87469 --- /dev/null +++ b/include/svl/svldllapi.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_SVLDLLAPI_H +#define INCLUDED_SVLDLLAPI_H + +#include "sal/types.h" + +#if defined(SVL_DLLIMPLEMENTATION) +#define SVL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define SVL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define SVL_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_SVLDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/szitem.hxx b/include/svl/szitem.hxx new file mode 100644 index 000000000000..1a576eced6fd --- /dev/null +++ b/include/svl/szitem.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 _SFXSZITEM_HXX +#define _SFXSZITEM_HXX + +#include <tools/gen.hxx> + +#include <svl/poolitem.hxx> + +class SvStream; + +DBG_NAMEEX(SfxSizeItem) + +// ----------------------------------------------------------------------- + +class SfxSizeItem : public SfxPoolItem +{ +private: + Size aVal; + +public: + TYPEINFO(); + SfxSizeItem(); + SfxSizeItem( sal_uInt16 nWhich, const Size& rVal ); + SfxSizeItem( const SfxSizeItem& ); + ~SfxSizeItem() { DBG_DTOR(SfxSizeItem, 0); } + + virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres, + SfxMapUnit eCoreMetric, + SfxMapUnit ePresMetric, + OUString &rText, + const IntlWrapper * = 0 ) const; + + virtual int operator==( const SfxPoolItem& ) const; + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create(SvStream &, sal_uInt16 nItemVersion) const; + virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion) const; + + const Size& GetValue() const { return aVal; } + void SetValue( const Size& rNewVal ) { + DBG_ASSERT( GetRefCount() == 0, "SetValue() with pooled item" ); + aVal = rNewVal; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx new file mode 100644 index 000000000000..f36cd816b607 --- /dev/null +++ b/include/svl/undo.hxx @@ -0,0 +1,474 @@ +/* -*- 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 _UNDO_HXX +#define _UNDO_HXX + +#include "svl/svldllapi.h" +#include <tools/rtti.hxx> +#include <tools/string.hxx> + +#include <boost/scoped_ptr.hpp> + +#include <vector> +#include <limits> + +//==================================================================== + +class SVL_DLLPUBLIC SfxRepeatTarget +{ +public: + TYPEINFO(); + virtual ~SfxRepeatTarget() = 0; +}; + +//==================================================================== + +class SVL_DLLPUBLIC SfxUndoContext +{ +public: + virtual ~SfxUndoContext() = 0; +}; + +//==================================================================== + +class SVL_DLLPUBLIC SfxUndoAction +{ + sal_Bool bLinked; +public: + TYPEINFO(); + SfxUndoAction(); + virtual ~SfxUndoAction(); + + virtual sal_Bool IsLinked(); + virtual void SetLinked( sal_Bool bIsLinked = sal_True ); + virtual void Undo(); + virtual void UndoWithContext( SfxUndoContext& i_context ); + virtual void Redo(); + virtual void RedoWithContext( SfxUndoContext& i_context ); + virtual void Repeat(SfxRepeatTarget&); + virtual sal_Bool CanRepeat(SfxRepeatTarget&) const; + + virtual sal_Bool Merge( SfxUndoAction *pNextAction ); + + virtual OUString GetComment() const; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const; + virtual sal_uInt16 GetId() const; + +private: + SfxUndoAction& operator=( const SfxUndoAction& ); // n.i.!! +}; + +//======================================================================== + +/// is a mark on the Undo stack +typedef sal_Int32 UndoStackMark; +#define MARK_INVALID ::std::numeric_limits< UndoStackMark >::max() + +//======================================================================== + +struct MarkedUndoAction +{ + SfxUndoAction* pAction; + ::std::vector< UndoStackMark > aMarks; + + MarkedUndoAction( SfxUndoAction* i_action ) + :pAction( i_action ) + ,aMarks() + { + } +}; + +class SfxUndoActions +{ +private: + ::std::vector< MarkedUndoAction > m_aActions; + +public: + SfxUndoActions() + { + } + + bool empty() const { return m_aActions.empty(); } + size_t size() const { return m_aActions.size(); } + + const MarkedUndoAction& operator[]( size_t i ) const { return m_aActions[i]; } + MarkedUndoAction& operator[]( size_t i ) { return m_aActions[i]; } + + void Remove( size_t i_pos ) + { + m_aActions.erase( m_aActions.begin() + i_pos ); + } + + void Remove( size_t i_pos, size_t i_count ) + { + m_aActions.erase( m_aActions.begin() + i_pos, m_aActions.begin() + i_pos + i_count ); + } + + void Insert( SfxUndoAction* i_action, size_t i_pos ) + { + m_aActions.insert( m_aActions.begin() + i_pos, MarkedUndoAction( i_action ) ); + } +}; + +//==================================================================== + +/** do not make use of these implementation details, unless you + really really have to! */ +struct SVL_DLLPUBLIC SfxUndoArray +{ + SfxUndoActions aUndoActions; + size_t nMaxUndoActions; + size_t nCurUndoAction; + SfxUndoArray *pFatherUndoArray; + SfxUndoArray(size_t nMax=0): + nMaxUndoActions(nMax), nCurUndoAction(0), + pFatherUndoArray(0) {} + ~SfxUndoArray(); +}; + +//========================================================================= + +/** do not make use of these implementation details, unless you + really really have to! */ +class SVL_DLLPUBLIC SfxListUndoAction : public SfxUndoAction, public SfxUndoArray + +/* [Beschreibung] + + UndoAction zur Klammerung mehrerer Undos in einer UndoAction. + Diese Actions werden vom SfxUndoManager verwendet. Dort + wird mit < SfxUndoManager::EnterListAction > eine Klammerebene + geoeffnet und mit <SfxUndoManager::LeaveListAction > wieder + geschlossen. Redo und Undo auf SfxListUndoActions wirken + Elementweise. + +*/ +{ + public: + TYPEINFO(); + + SfxListUndoAction( const OUString &rComment, + const OUString rRepeatComment, sal_uInt16 Id, SfxUndoArray *pFather); + virtual void Undo(); + virtual void UndoWithContext( SfxUndoContext& i_context ); + virtual void Redo(); + virtual void RedoWithContext( SfxUndoContext& i_context ); + virtual void Repeat(SfxRepeatTarget&); + virtual sal_Bool CanRepeat(SfxRepeatTarget&) const; + + virtual sal_Bool Merge( SfxUndoAction *pNextAction ); + + virtual OUString GetComment() const; + virtual OUString GetRepeatComment(SfxRepeatTarget&) const; + virtual sal_uInt16 GetId() const; + + void SetComment(const OUString& rComment); + + private: + + sal_uInt16 nId; + OUString aComment; + OUString aRepeatComment; + +}; + +//========================================================================= + +/** is a callback interface for notifications about state changes of an SfxUndoManager +*/ +class SAL_NO_VTABLE SfxUndoListener +{ +public: + virtual void actionUndone( const String& i_actionComment ) = 0; + virtual void actionRedone( const String& i_actionComment ) = 0; + virtual void undoActionAdded( const String& i_actionComment ) = 0; + virtual void cleared() = 0; + virtual void clearedRedo() = 0; + virtual void resetAll() = 0; + virtual void listActionEntered( const String& i_comment ) = 0; + virtual void listActionLeft( const String& i_comment ) = 0; + virtual void listActionLeftAndMerged() = 0; + virtual void listActionCancelled() = 0; + virtual void undoManagerDying() = 0; + +protected: + ~SfxUndoListener() {} +}; + +//========================================================================= + +namespace svl +{ + class SAL_NO_VTABLE IUndoManager + { + public: + enum + { + CurrentLevel = true, + TopLevel = false + }; + + virtual ~IUndoManager() { }; + + virtual void SetMaxUndoActionCount( size_t nMaxUndoActionCount ) = 0; + virtual size_t GetMaxUndoActionCount() const = 0; + + virtual void AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg=sal_False ) = 0; + + virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0; + virtual sal_uInt16 GetUndoActionId() const = 0; + virtual OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0; + virtual SfxUndoAction* GetUndoAction( size_t nNo=0 ) const = 0; + + virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0; + virtual OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0; + + virtual sal_Bool Undo() = 0; + virtual sal_Bool Redo() = 0; + + /** clears both the Redo and the Undo stack. + + Will assert and bail out when called while within a list action (<member>IsInListAction</member>). + */ + virtual void Clear() = 0; + + /** clears the Redo stack. + + Will assert and bail out when called while within a list action (<member>IsInListAction</member>). + */ + virtual void ClearRedo() = 0; + + /** leaves any possible open list action (<member>IsInListAction</member>), and clears both the Undo and the + Redo stack. + + Effectively, calling this method is equivalent to <code>while ( IsInListAction() ) LeaveListAction();</code>, + followed by <code>Clear()</code>. The only difference to this calling sequence is that Reset is an + atomic operation, also resulting in only one notification. + */ + virtual void Reset() = 0; + + /** determines whether an Undo or Redo is currently running + */ + virtual bool IsDoing() const = 0; + + virtual size_t GetRepeatActionCount() const = 0; + virtual OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const = 0; + virtual sal_Bool Repeat( SfxRepeatTarget &rTarget ) = 0; + virtual sal_Bool CanRepeat( SfxRepeatTarget &rTarget ) const = 0; + + virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId=0) = 0; + + /** leaves the list action entered with EnterListAction + @return the number of the sub actions in the list which has just been left. Note that in case no such + actions exist, the list action does not contribute to the Undo stack, but is silently removed. + */ + virtual size_t LeaveListAction() = 0; + + /** leaves the list action entered with EnterListAction, and forcefully merges the previous + action on the stack into the newly created list action. + + Say you have an Undo action A on the stack, then call EnterListAction, followed by one or more calls to + AddUndoAction, followed by a call to LeaveAndMergeListAction. In opposite to LeaveListAction, your Undo + stack will now still contain one undo action: the newly created list action, whose first child is the + original A, whose other children are those you added via AddUndoAction, and whose comment is the same as + the comment of A. + + Effectively, this means that all actions added between EnterListAction and LeaveAndMergeListAction are + hidden from the user. + + @return the number of the sub actions in the list which has just been left. Note that in case no such + actions exist, the list action does not contribute to the Undo stack, but is silently removed. + */ + virtual size_t LeaveAndMergeListAction() = 0; + + /// determines whether we're within a ListAction context, i.e. a LeaveListAction/LeaveAndMergeListAction call is pending + virtual bool IsInListAction() const = 0; + + /// determines how many nested list actions are currently open + virtual size_t GetListActionDepth() const = 0; + + /** clears the redo stack and removes the top undo action */ + virtual void RemoveLastUndoAction() = 0; + + /** enables (true) or disables (false) recording of undo actions + + If undo actions are added while undo is disabled, they are deleted. + Disabling undo does not clear the current undo buffer! + + Multiple calls to <code>EnableUndo</code> are not cumulative. That is, calling <code>EnableUndo( false )</code> + twice, and then calling <code>EnableUndo( true )</code> means that Undo is enable afterwards. + */ + virtual void EnableUndo( bool bEnable ) = 0; + + // returns true if undo is currently enabled + // This returns false if undo was disabled using EnableUndo( false ) and + // also during the runtime of the Undo() and Redo() methods. + virtual bool IsUndoEnabled() const = 0; + + /// adds a new listener to be notified about changes in the UndoManager's state + virtual void AddUndoListener( SfxUndoListener& i_listener ) = 0; + virtual void RemoveUndoListener( SfxUndoListener& i_listener ) = 0; + }; +} + +//========================================================================= + +namespace svl { namespace undo { namespace impl +{ + class UndoManagerGuard; + class LockGuard; +} } } + +struct SfxUndoManager_Data; +class SVL_DLLPUBLIC SfxUndoManager : public ::svl::IUndoManager +{ + friend class SfxLinkUndoAction; + + ::boost::scoped_ptr< SfxUndoManager_Data > + m_pData; +public: + SfxUndoManager( size_t nMaxUndoActionCount = 20 ); + virtual ~SfxUndoManager(); + + // IUndoManager overridables + virtual void SetMaxUndoActionCount( size_t nMaxUndoActionCount ); + virtual size_t GetMaxUndoActionCount() const; + virtual void AddUndoAction( SfxUndoAction *pAction, sal_Bool bTryMerg=sal_False ); + virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const; + virtual sal_uInt16 GetUndoActionId() const; + virtual OUString GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const; + virtual SfxUndoAction* GetUndoAction( size_t nNo=0 ) const; + virtual size_t GetRedoActionCount( bool const i_currentLevel = CurrentLevel ) const; + virtual OUString GetRedoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const; + virtual sal_Bool Undo(); + virtual sal_Bool Redo(); + virtual void Clear(); + virtual void ClearRedo(); + virtual void Reset(); + virtual bool IsDoing() const; + virtual size_t GetRepeatActionCount() const; + virtual OUString GetRepeatActionComment( SfxRepeatTarget &rTarget) const; + virtual sal_Bool Repeat( SfxRepeatTarget &rTarget ); + virtual sal_Bool CanRepeat( SfxRepeatTarget &rTarget ) const; + virtual void EnterListAction(const OUString &rComment, const OUString& rRepeatComment, sal_uInt16 nId=0); + virtual size_t LeaveListAction(); + virtual size_t LeaveAndMergeListAction(); + virtual bool IsInListAction() const; + virtual size_t GetListActionDepth() const; + virtual void RemoveLastUndoAction(); + virtual void EnableUndo( bool bEnable ); + virtual bool IsUndoEnabled() const; + virtual void AddUndoListener( SfxUndoListener& i_listener ); + virtual void RemoveUndoListener( SfxUndoListener& i_listener ); + + /** marks the current top-level element of the Undo stack, and returns a unique ID for it + */ + UndoStackMark MarkTopUndoAction(); + + /** removes a mark given by its ID. + After the call, the mark ID is invalid. + */ + void RemoveMark( UndoStackMark const i_mark ); + + /** determines whether the top action on the Undo stack has a given mark + */ + bool HasTopUndoActionMark( UndoStackMark const i_mark ); + + /** removes the oldest Undo actions from the stack + */ + void RemoveOldestUndoActions( size_t const i_count ); + +protected: + sal_Bool UndoWithContext( SfxUndoContext& i_context ); + sal_Bool RedoWithContext( SfxUndoContext& i_context ); + + void ImplClearRedo_NoLock( bool const i_currentLevel ); + + /** clears all undo actions on the current level, plus all undo actions on superordinate levels, + as soon as those levels are reached. + + If no list action is active currently, i.e. we're on the top level already, this method is equivalent to + ->Clear. + + Otherwise, the Undo actions on the current level are removed. Upon leaving the current list action, all + undo actions on the then-current level are removed, too. This is continued until the top level is reached. + */ + void ClearAllLevels(); + +private: + size_t ImplLeaveListAction( const bool i_merge, ::svl::undo::impl::UndoManagerGuard& i_guard ); + bool ImplAddUndoAction_NoNotify( SfxUndoAction* pAction, bool bTryMerge, bool bClearRedo, ::svl::undo::impl::UndoManagerGuard& i_guard ); + void ImplClearRedo( ::svl::undo::impl::UndoManagerGuard& i_guard, bool const i_currentLevel ); + void ImplClearUndo( ::svl::undo::impl::UndoManagerGuard& i_guard ); + void ImplClearCurrentLevel_NoNotify( ::svl::undo::impl::UndoManagerGuard& i_guard ); + size_t ImplGetRedoActionCount_Lock( bool const i_currentLevel = CurrentLevel ) const; + bool ImplIsUndoEnabled_Lock() const; + bool ImplIsInListAction_Lock() const; + void ImplEnableUndo_Lock( bool const i_enable ); + + sal_Bool ImplUndo( SfxUndoContext* i_contextOrNull ); + sal_Bool ImplRedo( SfxUndoContext* i_contextOrNull ); + + friend class ::svl::undo::impl::LockGuard; +}; + +//========================================================================= + +class SVL_DLLPUBLIC SfxLinkUndoAction : public SfxUndoAction + +/* [Beschreibung] + + Die SfxLinkUndoAction dient zur Verbindung zweier SfxUndoManager. Die + im ersten SfxUndoManager eingefuegten SfxUndoAction leiten ihr Undo und Redo + an den zweiten weiter, so dass ein Undo und Redo am ersten + SfxUndoManager wie eine am zweiten wirkt. + + Die SfxLinkUndoAction ist nach dem Einfuegen der SfxUndoAction am + zweiten SfxUndoManager einzufuegen. Waehrend der zweite SfxUndoManager + vom ersten ferngesteuert wird, duerfen an ihm weder Actions eingefuegt werden, + noch darf Undo/Redo aufgerufen werden. + +*/ + +{ +public: + TYPEINFO(); + SfxLinkUndoAction(::svl::IUndoManager *pManager); + ~SfxLinkUndoAction(); + + virtual void Undo(); + virtual void Redo(); + virtual sal_Bool CanRepeat(SfxRepeatTarget& r) const; + + virtual void Repeat(SfxRepeatTarget&r); + + virtual OUString GetComment() const; + virtual OUString GetRepeatComment(SfxRepeatTarget&r) const; + virtual sal_uInt16 GetId() const; + + SfxUndoAction* GetAction() const { return pAction; } + +protected: + ::svl::IUndoManager *pUndoManager; + SfxUndoAction *pAction; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/urihelper.hxx b/include/svl/urihelper.hxx new file mode 100644 index 000000000000..321d9cd2ae0b --- /dev/null +++ b/include/svl/urihelper.hxx @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_URIHELPER_HXX +#define SVTOOLS_URIHELPER_HXX + +#include "svl/svldllapi.h" +#include "com/sun/star/uno/Reference.hxx" +#include <com/sun/star/uno/RuntimeException.hpp> +#include <rtl/textenc.h> +#include <tools/link.hxx> +#include <tools/solar.h> +#include <tools/urlobj.hxx> + +namespace com { namespace sun { namespace star { + namespace uno { class XComponentContext; } + namespace uri { class XUriReference; } +} } } + +class CharClass; + +//============================================================================ +namespace URIHelper { + +/** + @ATT + Calling this function with defaulted arguments rMaybeFileHdl = Link() and + bCheckFileExists = true often leads to results that are not intended: + Whenever the given rTheBaseURIRef is a file URL, the given rTheRelURIRef is + relative, and rTheRelURIRef could also be smart-parsed as a non-file URL + (e.g., the relative URL "foo/bar" can be smart-parsed as "http://foo/bar"), + then SmartRel2Abs called with rMaybeFileHdl = Link() and bCheckFileExists = + true returns the non-file URL interpretation. To avoid this, either pass + some non-null rMaybeFileHdl if you want to check generated file URLs for + existence (see URIHelper::GetMaybeFileHdl), or use bCheckFileExists = false + if you want to generate file URLs without checking for their existence. +*/ +SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const & rTheBaseURIRef, + OUString const & rTheRelURIRef, + Link const & rMaybeFileHdl = Link(), + bool bCheckFileExists = true, + bool bIgnoreFragment = false, + INetURLObject::EncodeMechanism eEncodeMechanism = INetURLObject::WAS_ENCODED, + INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + bool bRelativeNonURIs = false, + INetURLObject::FSysStyle eStyle = INetURLObject::FSYS_DETECT); + +//============================================================================ +SVL_DLLPUBLIC void SetMaybeFileHdl(Link const & rTheMaybeFileHdl); + +//============================================================================ +SVL_DLLPUBLIC Link GetMaybeFileHdl(); + +/** + Converts a URI reference to a relative one, ignoring certain differences (for + example, treating file URLs for case-ignoring file systems + case-insensitively). + + @param context a component context; must not be null + + @param baseUriReference a base URI reference + + @param uriReference a URI reference + + @return a URI reference representing the given uriReference relative to the + given baseUriReference; if the given baseUriReference is not an absolute, + hierarchical URI reference, or the given uriReference is not a valid URI + reference, null is returned + + @exception std::bad_alloc if an out-of-memory condition occurs + + @exception com::sun::star::uno::RuntimeException if any error occurs + */ +SVL_DLLPUBLIC com::sun::star::uno::Reference< com::sun::star::uri::XUriReference > +normalizedMakeRelative( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context, + OUString const & baseUriReference, OUString const & uriReference); + +/** + A variant of normalizedMakeRelative with a simplified interface. + + Internally calls normalizedMakeRelative with the default component context. + + @param baseUriReference a base URI reference, passed to + normalizedMakeRelative + + @param uriReference a URI reference, passed to normalizedMakeRelative + + @return if the XUriReference returnd by normalizedMakeRelative is empty, + uriReference is returned unmodified; otherwise, the result of calling + XUriReference::getUriReference on the XUriReference returnd by + normalizedMakeRelative is returned + + @exception std::bad_alloc if an out-of-memory condition occurs + + @exception com::sun::star::uno::RuntimeException if any error occurs + + @deprecated + No code should rely on the default component context. +*/ +SVL_DLLPUBLIC OUString simpleNormalizedMakeRelative( OUString const & baseUriReference, + OUString const & uriReference); + +//============================================================================ +SVL_DLLPUBLIC OUString FindFirstURLInText(OUString const & rText, + sal_Int32 & rBegin, + sal_Int32 & rEnd, + CharClass const & rCharClass, + INetURLObject::EncodeMechanism eMechanism = INetURLObject::WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + INetURLObject::FSysStyle eStyle = INetURLObject::FSYS_DETECT); + +//============================================================================ +/** Remove any password component from both absolute and relative URLs. + + @ATT The current implementation will not remove a password from a + relative URL that has an authority component (e.g., the password is not + removed from the relative ftp URL <//user:password@domain/path>). But + since our functions to translate between absolute and relative URLs never + produce relative URLs with authority components, this is no real problem. + + @ATT For relative URLs (or anything not recognized as an absolute URI), + the current implementation will return the input unmodified, not applying + any translations implied by the encode/decode parameters. + + @param rURI An absolute or relative URI reference. + + @param eEncodeMechanism See the general discussion for INetURLObject set- + methods. + + @param eDecodeMechanism See the general discussion for INetURLObject get- + methods. + + @param eCharset See the general discussion for INetURLObject get- and + set-methods. + + @return The input URI with any password component removed. + */ +SVL_DLLPUBLIC OUString removePassword(OUString const & rURI, + INetURLObject::EncodeMechanism eEncodeMechanism = INetURLObject::WAS_ENCODED, + INetURLObject::DecodeMechanism eDecodeMechanism = INetURLObject::DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); +} + +#endif // SVTOOLS_URIHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/urlbmk.hxx b/include/svl/urlbmk.hxx new file mode 100644 index 000000000000..cc04b226d146 --- /dev/null +++ b/include/svl/urlbmk.hxx @@ -0,0 +1,62 @@ +/* -*- 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 _URLBMK_HXX +#define _URLBMK_HXX + + +#include <tools/string.hxx> + +//========================================================================= + +class INetBookmark + +/* [Beschreibung] + + Diese Klasse stellt ein Bookmark dar, welches aus einer URL und + einem dazuge"horigen Beschreibungstext besteht. + + Es gibt ein eigenes Clipboardformat und Hilfsmethoden zum Kopieren + und Einf"ugen in und aus Clipboard und DragServer. +*/ + +{ + String aUrl; + String aDescr; + +protected: + + void SetURL( const String& rS ) { aUrl = rS; } + void SetDescription( const String& rS ) { aDescr = rS; } + +public: + INetBookmark( const String &rUrl, const String &rDescr ) + : aUrl( rUrl ), aDescr( rDescr ) + {} + INetBookmark() + {} + + const String& GetURL() const { return aUrl; } + const String& GetDescription() const { return aDescr; } +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/urlfilter.hxx b/include/svl/urlfilter.hxx new file mode 100644 index 000000000000..abcf0fd07091 --- /dev/null +++ b/include/svl/urlfilter.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef SVTOOLS_URL_FILTER_HXX +#define SVTOOLS_URL_FILTER_HXX + +#include <tools/wldcrd.hxx> +#include <functional> +#include <vector> +/** filters allowed URLs +*/ +class IUrlFilter +{ +public: + virtual bool isUrlAllowed( const OUString& _rURL ) const = 0; + +protected: + virtual inline ~IUrlFilter() = 0; +}; + +inline IUrlFilter::~IUrlFilter() {} + +struct FilterMatch : public ::std::unary_function< bool, WildCard > +{ +private: + const OUString& m_rCompareString; +public: + FilterMatch( const OUString& _rCompareString ) : m_rCompareString( _rCompareString ) { } + + bool operator()( const WildCard& _rMatcher ) + { + return _rMatcher.Matches( m_rCompareString ) ? true : false; + } + + static void createWildCardFilterList(const OUString& _rFilterList,::std::vector< WildCard >& _rFilters); +}; + +#endif // SVTOOLS_URL_FILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/visitem.hxx b/include/svl/visitem.hxx new file mode 100644 index 000000000000..adb72d0578e7 --- /dev/null +++ b/include/svl/visitem.hxx @@ -0,0 +1,87 @@ +/* -*- 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 _SFXVISIBILITYITEM_HXX +#define _SFXVISIBILITYITEM_HXX + +#include "svl/svldllapi.h" +#include <tools/debug.hxx> +#include <svl/poolitem.hxx> +#include <com/sun/star/frame/status/Visibility.hpp> + +//============================================================================ +DBG_NAMEEX_VISIBILITY(SfxVisibilityItem, SVL_DLLPUBLIC) + +class SVL_DLLPUBLIC SfxVisibilityItem: public SfxPoolItem +{ + ::com::sun::star::frame::status::Visibility m_nValue; + +public: + TYPEINFO(); + + explicit SfxVisibilityItem(sal_uInt16 which = 0, sal_Bool bVisible = sal_True): + SfxPoolItem(which) + { + m_nValue.bVisible = bVisible; + DBG_CTOR(SfxVisibilityItem, 0); + } + + SfxVisibilityItem(sal_uInt16 which, SvStream & rStream); + + SfxVisibilityItem(const SfxVisibilityItem & rItem): + SfxPoolItem(rItem), m_nValue(rItem.m_nValue) + { DBG_CTOR(SfxVisibilityItem, 0); } + + virtual ~SfxVisibilityItem() { DBG_DTOR(SfxVisibilityItem, 0); } + + virtual int operator ==(const SfxPoolItem & rItem) const; + + using SfxPoolItem::Compare; + virtual int Compare(const SfxPoolItem & rWith) const; + + virtual SfxItemPresentation GetPresentation(SfxItemPresentation, + SfxMapUnit, SfxMapUnit, + OUString & rText, + const IntlWrapper * = 0) + const; + + virtual bool QueryValue( com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ) const; + + virtual bool PutValue( const com::sun::star::uno::Any& rVal, + sal_uInt8 nMemberId = 0 ); + + virtual SfxPoolItem * Create(SvStream & rStream, sal_uInt16) const; + + virtual SvStream & Store(SvStream & rStream, sal_uInt16) const; + + virtual SfxPoolItem * Clone(SfxItemPool * = 0) const; + + virtual sal_uInt16 GetValueCount() const; + + virtual OUString GetValueTextByVal(sal_Bool bTheValue) const; + + sal_Bool GetValue() const { return m_nValue.bVisible; } + + void SetValue(sal_Bool bVisible) { m_nValue.bVisible = bVisible; } +}; + +#endif // _SFXVISIBILITYITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/whiter.hxx b/include/svl/whiter.hxx new file mode 100644 index 000000000000..e92383624743 --- /dev/null +++ b/include/svl/whiter.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _SFX_WHITER_HXX +#define _SFX_WHITER_HXX + +#include "svl/svldllapi.h" + +#include <limits.h> +#include <tools/solar.h> + +class SfxItemSet; + + +// INCLUDE --------------------------------------------------------------- + +class SVL_DLLPUBLIC SfxWhichIter +{ + const sal_uInt16 *pRanges, *pStart; + sal_uInt16 nOfst, nFrom, nTo; + +public: + SfxWhichIter( const SfxItemSet& rSet, sal_uInt16 nFrom = 0, sal_uInt16 nTo = USHRT_MAX ); + ~SfxWhichIter(); + + sal_uInt16 GetCurWhich() const { return *pRanges + nOfst; } + sal_uInt16 NextWhich(); + sal_uInt16 FirstWhich(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/xmlement.hxx b/include/svl/xmlement.hxx new file mode 100644 index 000000000000..c6b67d59105b --- /dev/null +++ b/include/svl/xmlement.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: + * + * 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 _SVTOOLS_XMLEMENT_HXX +#define _SVTOOLS_XMLEMENT_HXX + +#include <sal/types.h> + +struct SvXMLEnumMapEntry +{ + const sal_Char *pName; + sal_uInt16 nValue; +}; + + +#endif // _SVTOOLS_XMLEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx new file mode 100644 index 000000000000..d5c84235a4f9 --- /dev/null +++ b/include/svl/zforlist.hxx @@ -0,0 +1,1037 @@ +/* -*- 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 _ZFORLIST_HXX +#define _ZFORLIST_HXX + +#include "svl/svldllapi.h" +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.hxx> +#include <tools/string.hxx> +#include <i18nlangtag/lang.h> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/i18n/NumberFormatCode.hpp> +#include <unotools/localedatawrapper.hxx> +#include <tools/link.hxx> +#include <svl/ondemand.hxx> +#include <svl/nfkeytab.hxx> + +#include <map> +#include <set> +#include <boost/ptr_container/ptr_vector.hpp> + +class Date; +class SvStream; +class Color; +class CharClass; +class CalendarWrapper; + +class ImpSvNumberformatScan; +class ImpSvNumberInputScan; +class SvNumberformat; + +namespace com { namespace sun { namespace star { + namespace uno { + class XComponentContext; + } +}}} + +#define SV_COUNTRY_LANGUAGE_OFFSET 10000 // Max count of formats per country/language +#define SV_MAX_ANZ_STANDARD_FORMATE 100 // Max count of builtin default formats per CL + +// Format types +#ifndef NUMBERFORMAT_ALL +// also defined in com/sun/star/util/NumberFormat.hpp +//! => put in single .idl file and include here +#define NUMBERFORMAT_ALL 0x000 /// Just for Output of total list, not a real format type +#define NUMBERFORMAT_DEFINED 0x001 /// Format defined by user +#define NUMBERFORMAT_DATE 0x002 /// Number as date +#define NUMBERFORMAT_TIME 0x004 /// Number as time +#define NUMBERFORMAT_CURRENCY 0x008 /// Number as currency +#define NUMBERFORMAT_NUMBER 0x010 /// Any "normal" number format +#define NUMBERFORMAT_SCIENTIFIC 0x020 /// Number as scientific +#define NUMBERFORMAT_FRACTION 0x040 /// Number as fraction +#define NUMBERFORMAT_PERCENT 0x080 /// Number as percent +#define NUMBERFORMAT_TEXT 0x100 /// Text format +#define NUMBERFORMAT_DATETIME 0x006 /// Number as date and time +#define NUMBERFORMAT_LOGICAL 0x400 /// Number as boolean value +#define NUMBERFORMAT_UNDEFINED 0x800 /// Format undefined yet in analyzing +#endif +#define NUMBERFORMAT_ENTRY_NOT_FOUND (sal_uInt32)(0xffffffff) /// MAX_ULONG + + +/** enum values for <method>SvNumberFormatter::GetFormatIndex</method> + + <p> + Builtin standard formats, order should be also the arrangement in the + dialog list box representation.</p> + + <p> + Date specials:<ul> + <li>SYSTEM: As set in System Regional Settings. + <li>SYS: short/long defined, order and separators from System Regional Settings. + <li>DEF: short/long and order defined, separators from System Regional Settings. + <li>DIN: all settings hard coded as DIN (Deutsche Industrie Norm) and EN (European Norm) require. + <li>all other: hard coded + </ul> + + Do NOT insert any new values! + The values here correspond with those in offapi/com/sun/star/i18n/NumberFormatIndex.idl + */ +enum NfIndexTableOffset +{ + NF_NUMERIC_START = 0, + + NF_NUMBER_START = NF_NUMERIC_START, + NF_NUMBER_STANDARD = NF_NUMBER_START, // Standard/General + NF_NUMBER_INT, // 0 + NF_NUMBER_DEC2, // 0.00 + NF_NUMBER_1000INT, // #,##0 + NF_NUMBER_1000DEC2, // #,##0.00 + NF_NUMBER_SYSTEM, // #,##0.00 or whatever is set in System Regional Settings + NF_NUMBER_END = NF_NUMBER_SYSTEM, + + NF_SCIENTIFIC_START, + NF_SCIENTIFIC_000E000 = NF_SCIENTIFIC_START, // 0.00E+000 + NF_SCIENTIFIC_000E00, // 0.00E+00 + NF_SCIENTIFIC_END = NF_SCIENTIFIC_000E00, + + NF_PERCENT_START, + NF_PERCENT_INT = NF_PERCENT_START, // 0% + NF_PERCENT_DEC2, // 0.00% + NF_PERCENT_END = NF_PERCENT_DEC2, + + NF_FRACTION_START, + NF_FRACTION_1 = NF_FRACTION_START, // # ?/? + NF_FRACTION_2, // # ??/?? + NF_FRACTION_END = NF_FRACTION_2, + + NF_NUMERIC_END = NF_FRACTION_END, + + NF_CURRENCY_START, + NF_CURRENCY_1000INT = NF_CURRENCY_START,// #,##0 DM + NF_CURRENCY_1000DEC2, // #,##0.00 DM + NF_CURRENCY_1000INT_RED, // #,##0 DM negative in red + NF_CURRENCY_1000DEC2_RED, // #,##0.00 DM negative in red + NF_CURRENCY_1000DEC2_CCC, // #,##0.00 DEM currency abbreviation + NF_CURRENCY_1000DEC2_DASHED, // #,##0.-- DM + NF_CURRENCY_END = NF_CURRENCY_1000DEC2_DASHED, + + NF_DATE_START, + NF_DATE_SYSTEM_SHORT = NF_DATE_START, // 08.10.97 + NF_DATE_SYSTEM_LONG, // Wednesday, 8. October 1997 + NF_DATE_SYS_DDMMYY, // 08.10.97 + NF_DATE_SYS_DDMMYYYY, // 08.10.1997 + NF_DATE_SYS_DMMMYY, // 8. Oct 97 + NF_DATE_SYS_DMMMYYYY, // 8. Oct 1997 + NF_DATE_DIN_DMMMYYYY, // 8. Oct. 1997 DIN + NF_DATE_SYS_DMMMMYYYY, // 8. October 1997 + NF_DATE_DIN_DMMMMYYYY, // 8. October 1997 DIN + NF_DATE_SYS_NNDMMMYY, // Wed, 8. Okt 97 + NF_DATE_DEF_NNDDMMMYY, // Wed 08.Okt 97 + NF_DATE_SYS_NNDMMMMYYYY, // Wed, 8. Oktober 1997 + NF_DATE_SYS_NNNNDMMMMYYYY, // Wednesday, 8. Oktober 1997 + NF_DATE_DIN_MMDD, // 10-08 DIN + NF_DATE_DIN_YYMMDD, // 97-10-08 DIN + NF_DATE_DIN_YYYYMMDD, // 1997-10-08 DIN + NF_DATE_SYS_MMYY, // 10.97 + NF_DATE_SYS_DDMMM, // 08.Oct + NF_DATE_MMMM, // October + NF_DATE_QQJJ, // 4. Quarter 97 + NF_DATE_WW, // week of year + NF_DATE_END = NF_DATE_WW, + + NF_TIME_START, + NF_TIME_HHMM = NF_TIME_START, // HH:MM + NF_TIME_HHMMSS, // HH:MM:SS + NF_TIME_HHMMAMPM, // HH:MM AM/PM + NF_TIME_HHMMSSAMPM, // HH:MM:SS AM/PM + NF_TIME_HH_MMSS, // [HH]:MM:SS + NF_TIME_MMSS00, // MM:SS,00 + NF_TIME_HH_MMSS00, // [HH]:MM:SS,00 + NF_TIME_END = NF_TIME_HH_MMSS00, + + NF_DATETIME_START, + NF_DATETIME_SYSTEM_SHORT_HHMM = NF_DATETIME_START, // 08.10.97 01:23 + NF_DATETIME_SYS_DDMMYYYY_HHMMSS, // 08.10.1997 01:23:45 + NF_DATETIME_END = NF_DATETIME_SYS_DDMMYYYY_HHMMSS, + + NF_BOOLEAN, // BOOLEAN + NF_TEXT, // @ + + // From here on are values of new built-in formats that are not in the + // original NumberFormatIndex.idl + + NF_FRACTION_3, // # ?/4 + NF_FRACTION_4, // # ?/100 + + NF_INDEX_TABLE_ENTRIES +}; + + +// #45717# IsNumberFormat( "98-10-24", 30, x ), YMD Format set with DMY +// International settings doesn't recognize the string as a date. +/** enum values for <method>SvNumberFormatter::SetEvalDateFormat</method> + + <p>How <method>ImpSvNumberInputScan::GetDateRef</method> shall take the + DateFormat order (YMD,DMY,MDY) into account, if called from IsNumberFormat + with a date format to match against. + */ +enum NfEvalDateFormat +{ + /** DateFormat only from International, default. */ + NF_EVALDATEFORMAT_INTL, + + /** DateFormat only from date format passed to function (if any). + If no date format is passed then the DateFormat is taken from International. */ + NF_EVALDATEFORMAT_FORMAT, + + /** First try the DateFormat from International. If it doesn't match a + valid date try the DateFormat from the date format passed. */ + NF_EVALDATEFORMAT_INTL_FORMAT, + + /** First try the DateFormat from the date format passed. If it doesn't + match a valid date try the DateFormat from International. */ + NF_EVALDATEFORMAT_FORMAT_INTL +}; + + +typedef std::map<sal_uInt32, SvNumberformat*> SvNumberFormatTable; +typedef std::map<sal_uInt16, sal_uInt32> SvNumberFormatterIndexTable; + +typedef ::std::map< sal_uInt32, sal_uInt32> SvNumberFormatterMergeMap; + +typedef ::std::set< LanguageType > NfInstalledLocales; + + +/** Language/country dependent currency entries + */ +class SVL_DLLPUBLIC NfCurrencyEntry +{ + OUString aSymbol; /// currency symbol + OUString aBankSymbol; /// currency abbreviation + LanguageType eLanguage; /// language/country value + sal_uInt16 nPositiveFormat; /// position of symbol + sal_uInt16 nNegativeFormat; /// position of symbol and type and position of negative sign + sal_uInt16 nDigits; /// count of decimal digits + sal_Unicode cZeroChar; /// which character is used for zeros as last decimal digits + + /// not implemented, prevent usage + NfCurrencyEntry( const NfCurrencyEntry& ); + /// not implemented, prevent usage + NfCurrencyEntry& operator=( const NfCurrencyEntry& ); + +private: + + // nDecimalFormat := 0, 1, 2 + // #,##0 or #,##0.00 or #,##0.-- is returned + SVL_DLLPRIVATE OUString Impl_BuildFormatStringNumChars( const LocaleDataWrapper&, sal_uInt16 nDecimalFormat) const; + +public: + + NfCurrencyEntry( const LocaleDataWrapper& rLocaleData, + LanguageType eLang ); + NfCurrencyEntry( const ::com::sun::star::i18n::Currency & rCurr, + const LocaleDataWrapper& rLocaleData, + LanguageType eLang ); + ~NfCurrencyEntry() {} + + /// Symbols and language identical + bool operator==( const NfCurrencyEntry& r ) const; + + const OUString& GetSymbol() const { return aSymbol; } + const OUString& GetBankSymbol() const { return aBankSymbol; } + LanguageType GetLanguage() const { return eLanguage; } + sal_uInt16 GetPositiveFormat() const { return nPositiveFormat; } + sal_uInt16 GetNegativeFormat() const { return nNegativeFormat; } + sal_uInt16 GetDigits() const { return nDigits; } + sal_Unicode GetZeroChar() const { return cZeroChar; } + + /** [$DM-407] (bBank==false) or [$DEM] (bBank==true) + is returned. If bBank==false and + bWithoutExtension==true only [$DM] */ + OUString BuildSymbolString(bool bBank, bool bWithoutExtension = false) const; + + /** #,##0.00 [$DM-407] is returned, separators + from rLoc, incl. minus sign but without [RED] */ + OUString BuildPositiveFormatString(bool bBank, const LocaleDataWrapper&, + sal_uInt16 nDecimalFormat = 1) const; + OUString BuildNegativeFormatString(bool bBank, const LocaleDataWrapper&, + sal_uInt16 nDecimalFormat = 1) const; + + /** [$DM-407] (or [$DEM] if bBank==true) + is appended/prepended to rStr, incl. minus sign */ + void CompletePositiveFormatString(OUStringBuffer& rStr, bool bBank, + sal_uInt16 nPosiFormat) const; + void CompleteNegativeFormatString(OUStringBuffer& rStr, bool bBank, + sal_uInt16 nNegaFormat) const; + + /// rSymStr is appended/prepended to rStr, incl. minus sign + static void CompletePositiveFormatString(OUStringBuffer& rStr, + const OUString& rSymStr, sal_uInt16 nPosiFormat); + static void CompleteNegativeFormatString(OUStringBuffer& rStr, + const OUString& rSymStr, sal_uInt16 nNegaFormat); + + /** Representation of a currency (symbol position and + negative sign) in other language settings */ + static sal_uInt16 GetEffectivePositiveFormat( sal_uInt16 nIntlFormat, + sal_uInt16 nCurrFormat, bool bBank ); + static sal_uInt16 GetEffectiveNegativeFormat( sal_uInt16 nIntlFormat, + sal_uInt16 nCurrFormat, bool bBank ); + + /// General Unicode Euro symbol + static inline sal_Unicode GetEuroSymbol() { return sal_Unicode(0x20AC); } + /** Platform and CharSet dependent Euro symbol, + needed for import/export */ + static sal_Char GetEuroSymbol( rtl_TextEncoding eTextEncoding ); +}; + +typedef boost::ptr_vector<NfCurrencyEntry> NfCurrencyTable; + +typedef std::vector< OUString > NfWSStringsDtor; + +class SvNumberFormatterRegistry_Impl; + +class SVL_DLLPUBLIC SvNumberFormatter +{ +public: + /** + * We can't technically have an "infinite" value, so we use an arbitrary + * upper precision threshold to represent the "unlimited" precision. + */ + static const sal_uInt16 UNLIMITED_PRECISION; + + /** + * Precision suitable for numbers displayed in input bar, for instance + * Calc's formula input bar. + */ + static const sal_uInt16 INPUTSTRING_PRECISION; + + /// Preferred ctor with service manager and language/country enum + SvNumberFormatter( + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, + LanguageType eLang + ); + + ~SvNumberFormatter(); + + /// Set CallBack to ColorTable + void SetColorLink( const Link& rColorTableCallBack ) { aColorLink = rColorTableCallBack; } + /// Do the CallBack to ColorTable + Color* GetUserDefColor(sal_uInt16 nIndex); + + /// Change language/country, also input and format scanner + void ChangeIntl( LanguageType eLnge ); + /// Change the reference null date + void ChangeNullDate(sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear); + /// Change standard precision + void ChangeStandardPrec(short nPrec); + /// Set zero value suppression + void SetNoZero(bool bNZ) { bNoZero = bNZ; } + + /** The language with which the formatter was initialized (system setting), + NOT the current language after a ChangeIntl() */ + LanguageType GetLanguage() const { return IniLnge; } + + // Determine whether two format types are input compatible or not + bool IsCompatible(short eOldType, short eNewType); + + /** Get table of formats of a specific type of a locale. A format FIndex is + tested whether it has the type and locale requested, if it doesn't + match FIndex returns the default format for the type/locale. If no + specific format is to be selected FIndex may be initialized to 0. */ + SvNumberFormatTable& GetEntryTable(short eType, + sal_uInt32& FIndex, + LanguageType eLnge); + + /** Get table of formats of a specific type of a language/country. + FIndex returns the default format of that type. + If the language/country was never touched before new entries are generated */ + SvNumberFormatTable& ChangeCL(short eType, + sal_uInt32& FIndex, + LanguageType eLnge); + + /** Get table of formats of the same type as FIndex; eType and rLnge are + set accordingly. An unknown format is set to Standard/General */ + SvNumberFormatTable& GetFirstEntryTable(short& eType, + sal_uInt32& FIndex, + LanguageType& rLnge); + + /// Delete an entry including the format it is refering to + void DeleteEntry(sal_uInt32 nKey); + + /** Create new entry of a format code string for language/country. + @return + <TRUE/> if string new and ok and inserted. + <FALSE/> if string already exists or an unresolvable parse error + occurred, in which case nCheckPos is the error position within rString. + If the error occurs at position 0 or rString is empty nCheckPos + will be 1, so an error in the string is always indicated by + nCheckPos not being zero. + The content of the rString variable can be changed and corrected + by the method. + nType contains the type of the format. + nKey contains the index key of the format. + */ + bool PutEntry( OUString& rString, sal_Int32& nCheckPos, short& nType, sal_uInt32& nKey, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Same as <method>PutEntry</method> but the format code string is + considered to be of language/country eLnge and is converted to + language/country eNewLnge */ + bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos, + short& nType, sal_uInt32& nKey, + LanguageType eLnge, LanguageType eNewLnge ); + + /** Same as <method>PutandConvertEntry</method> but the format code string + is considered to be of the System language/country eLnge and is + converted to another System language/country eNewLnge. In this case + the automatic currency is converted too. */ + bool PutandConvertEntrySystem( OUString& rString, sal_Int32& nCheckPos, + short& nType, sal_uInt32& nKey, + LanguageType eLnge, LanguageType eNewLnge ); + + /** Similar to <method>PutEntry</method> and + <method>PutandConvertEntry</method> or + <method>PutandConvertEntrySystem</method>, the format code string + passed is considered to be of language/country eLnge. If + eLnge==LANGUAGE_SYSTEM the format code has to match eSysLnge, and if + eSysLnge is not the current application locale the format code is + converted to the current locale. Additionally, if the format code + represents an old "automatic" currency format, it is converted to the + new default currency format of the eLnge locale. The rString format + code passed as an argument may get adapted in case eLnge was used (or + is LANGUAGE_SYSTEM and eSysLnge is identical); in case it wasn't the + method works on a copy instead, otherwise the resulting string would + not match eSysLnge anymore. + + <p> This method was introduced to handle the legacy currency formats of + the "autotbl.fmt" file used by Calc and Writer and convert them to + fixed currency codes of the actual currency. Note that in the case of + legacy currency formats no special attribution is converted, only the + default currency format of the locale is chosen, and that new fixed + currency codes are of course not converted to other currencies. The + method may also be used as a general method taking, converting and + inserting almost arbitrary format codes. To insert or use, for example, + the default currency format code matching the current locale, the + method could be called with<br/> + + <code> + GetIndexPuttingAndConverting( "0 $", LANGUAGE_SYSTEM, LANGUAGE_ENGLISH_US, ...); + </code> + + @return + The index key of the resulting number format. If the format code + was empty, could not be converted or has errors, the eLnge locale's + standard number format is chosen instead. The index key is + guaranteed to represent some valid number format. If + rNewInserted==false and rCheckPos>0 the format code has errors + and/or could not be converted. + */ + sal_uInt32 GetIndexPuttingAndConverting( String & rString, LanguageType eLnge, + LanguageType eSysLnge, short & rType, + bool & rNewInserted, + xub_StrLen & rCheckPos ); + + sal_uInt32 GetIndexPuttingAndConverting( OUString & rString, LanguageType eLnge, + LanguageType eSysLnge, short & rType, + bool & rNewInserted, sal_Int32 & rCheckPos ); + + /** Create a format code string using format nIndex as a template and + applying other settings (passed from the dialog) */ + OUString GenerateFormat(sal_uInt32 nIndex, + LanguageType eLnge = LANGUAGE_DONTKNOW, + bool bThousand = false, bool IsRed = false, + sal_uInt16 nPrecision = 0, sal_uInt16 nAnzLeading = 1); + + /** Analyze an input string + @return + <TRUE/> if input is a number or is matching a format F_Index + F_Index is set to a matching format if number, the value is + returned in fOutNumber + <FALSE/> if input is not a number + */ + bool IsNumberFormat( const OUString& sString, sal_uInt32& F_Index, double& fOutNumber ); + + /// Format a number according to a format index, return string and color + void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, + String& sOutString, Color** ppColor, bool bUseStarFormat = false ); + + /// Format a number according to a format index, return string and color + void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, + OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); + + /** Format a string according to a format index, return string and color. + Formats only if the format code is of type text or the 4th subcode + of a format code is specified, otherwise sOutString will be == "" */ + void GetOutputString( const OUString& sString, sal_uInt32 nFIndex, + OUString& sOutString, Color** ppColor, bool bUseStarFormat = false ); + + /** Format a number according to the standard default format matching + the given format index */ + void GetInputLineString( const double& fOutNumber, + sal_uInt32 nFIndex, String& sOutString ); + + void GetInputLineString( const double& fOutNumber, + sal_uInt32 nFIndex, OUString& rOutString ); + + /** Format a number according to a format code string to be scanned. + @return + <FALSE/> if format code contains an error + <TRUE/> else, in which case the string and color are returned. + */ + bool GetPreviewString(const OUString& sFormatString, + double fPreviewNumber, + OUString& sOutString, + Color** ppColor, + LanguageType eLnge, + bool bUseStarFormat = false ); + + /** Same as <method>GetPreviewString</method> but the format code string + may be either language/country eLnge or en_US english US */ + bool GetPreviewStringGuess( const OUString& sFormatString, double fPreviewNumber, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Format a string according to a format code string to be scanned. + @return + <FALSE/> if format code contains an error + <TRUE/> else, in which case the string and color are returned. + */ + bool GetPreviewString( const OUString& sFormatString, const OUString& sPreviewString, + OUString& sOutString, Color** ppColor, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Test whether the format code string is already present in container + @return + NUMBERFORMAT_ENTRY_NOT_FOUND if not found, else the format index. + */ + sal_uInt32 TestNewString( const OUString& sFormatString, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Whether format index nFIndex is of type text or not + bool IsTextFormat(sal_uInt32 nFIndex) const; + + /// Load all formats from a stream + bool Load( SvStream& rStream ); + /// Save all formats to a stream + bool Save( SvStream& rStream ) const; + + /// Get additional info of a format index, e.g. for dialog box + void GetFormatSpecialInfo(sal_uInt32 nFormat, bool& bThousand, bool& IsRed, + sal_uInt16& nPrecision, sal_uInt16& nAnzLeading); + + /// Count of decimals + sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat ) const; + + /** Get additional info of a format code string, e.g. for dialog box. + Uses a temporary parse, if possible use only if format code is not + present in container yet, otherwise ineffective. + @return + 0 if format code string parsed without errors, otherwise error + position (like nCheckPos on <method>PutEntry</method>) + */ + sal_uInt32 GetFormatSpecialInfo( const OUString&, bool& bThousand, bool& IsRed, + sal_uInt16& nPrecision, sal_uInt16& nAnzLeading, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Check if format code string may be deleted by user + bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return the format index of the format code string for language/country, + or NUMBERFORMAT_ENTRY_NOT_FOUND */ + sal_uInt32 GetEntryKey( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /// Return the format for a format index + const SvNumberformat* GetEntry( sal_uInt32 nKey ) const; + + /// Return the format index of the standard default number format for language/country + sal_uInt32 GetStandardIndex(LanguageType eLnge = LANGUAGE_DONTKNOW); + + /// Return the format index of the default format of a type for language/country + sal_uInt32 GetStandardFormat(short eType, LanguageType eLnge = LANGUAGE_DONTKNOW); + + /** Return the format index of the default format of a type for language/country. + Maybe not the default format but a special builtin format, e.g. for + NF_TIME_HH_MMSS00, if that format is passed in nFIndex. */ + sal_uInt32 GetStandardFormat( sal_uInt32 nFIndex, short eType, LanguageType eLnge ); + + /** Return the format index of the default format of a type for language/country. + Maybe not the default format but a special builtin format, e.g. for + NF_TIME_HH_MMSS00, or NF_TIME_HH_MMSS if fNumber >= 1.0 */ + sal_uInt32 GetStandardFormat( double fNumber, sal_uInt32 nFIndex, short eType, + LanguageType eLnge ); + + /// Whether nFIndex is a special builtin format + bool IsSpecialStandardFormat( sal_uInt32 nFIndex, LanguageType eLnge ); + + /** Return the corresponding edit format of a format. */ + sal_uInt32 GetEditFormat( double fNumber, sal_uInt32 nFIndex, short eType, + LanguageType eLnge, SvNumberformat* pFormat ); + + /// Return the reference date + Date* GetNullDate(); + /// Return the standard decimal precision + sal_uInt16 GetStandardPrec(); + /// Return whether zero suppression is switched on + bool GetNoZero() { return bNoZero; } + /** Get the type of a format (or NUMBERFORMAT_UNDEFINED if no entry), + but with NUMBERFORMAT_DEFINED masked out */ + short GetType(sal_uInt32 nFIndex); + + /// As the name says + void ClearMergeTable(); + /// Merge in all new entries from rNewTable and return a table of resulting new format indices + SvNumberFormatterIndexTable* MergeFormatter(SvNumberFormatter& rNewTable); + + /// Whether a merge table is present or not + inline bool HasMergeFmtTbl() const; + /// Return the new format index for an old format index, if a merge table exists + inline sal_uInt32 GetMergeFmtIndex( sal_uInt32 nOldFmt ) const; + + /** Convert the ugly old tools' Table type bloated with new'ed sal_uInt32 + entries merge table to ::std::map with old index key and new index key. + @ATTENTION! Also clears the old table using ClearMergeTable() */ + SvNumberFormatterMergeMap ConvertMergeTableToMap(); + + /// Return the last used position ever of a language/country combination + sal_uInt16 GetLastInsertKey(sal_uInt32 CLOffset); + + /** Return the format index of a builtin format for a specific language/country. + If nFormat is not a builtin format nFormat is returned. */ + sal_uInt32 GetFormatForLanguageIfBuiltIn( sal_uInt32 nFormat, + LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return the format index for a builtin format of a specific language + @see NfIndexTableOffset + */ + sal_uInt32 GetFormatIndex( NfIndexTableOffset, LanguageType eLnge = LANGUAGE_DONTKNOW ); + + /** Return enum index of a format index of a builtin format, + NF_INDEX_TABLE_ENTRIES if it's not a builtin format. + @see NfIndexTableOffset + */ + NfIndexTableOffset GetIndexTableOffset( sal_uInt32 nFormat ) const; + + /** Set evaluation type and order of input date strings + @see NfEvalDateFormat + */ + void SetEvalDateFormat( NfEvalDateFormat eEDF ) { eEvalDateFormat = eEDF; } + NfEvalDateFormat GetEvalDateFormat() const { return eEvalDateFormat; } + + /** Set TwoDigitYearStart, how the input string scanner handles a two digit year. + Default from VCL: 1930, 30-99 19xx, 00-29 20xx + + <p> Historically (prior to src513e) it was a two digit number determing + until which number the string scanner recognizes a year to be 20xx, + default <= 29 is used by SFX/OfaMiscCfg. + The name Year2000 is kept although the actual functionality is now a + TwoDigitYearStart which might be in any century. + */ + void SetYear2000( sal_uInt16 nVal ); + sal_uInt16 GetYear2000() const; + static sal_uInt16 GetYear2000Default(); + + sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear ) const; + inline static sal_uInt16 ExpandTwoDigitYear( sal_uInt16 nYear, sal_uInt16 nTwoDigitYearStart ); + + /// DEPRICATED: Return first character of the decimal separator of the current language/country + sal_Unicode GetDecSep() const { return GetNumDecimalSep()[0]; } + /// Return the decimal separator of the current language/country + OUString GetDecimalSep() const { return GetNumDecimalSep(); } + + /// Return the decimal separator matching the locale of the given format + OUString GetFormatDecimalSep( sal_uInt32 nFormat ) const; + + /// Return a <type>NfCurrencyTable</type> with pointers to <type>NfCurrencyEntry</type> entries + static const NfCurrencyTable& GetTheCurrencyTable(); + + /** Searches, according to the default locale currency, an entry of the + CurrencyTable which is <bold>not</bold> the first (LANGUAGE_SYSTEM) entry. + @return + <NULL/> if not found + else pointer to <type>NfCurrencyEntry</type> + */ + static const NfCurrencyEntry* MatchSystemCurrency(); + + /** Return a <type>NfCurrencyEntry</type> matching a language/country. + If language/country is LANGUAGE_SYSTEM a <method>MatchSystemCurrency</method> + call is tried to get an entry. If that fails or the corresponding + language/country is not present the entry for LANGUAGE_SYSTEM is returned. + */ + static const NfCurrencyEntry& GetCurrencyEntry( LanguageType ); + + /** Return a <type>NfCurrencyEntry</type> pointer matching a language/country + and currency abbreviation (AKA banking symbol). + This method is meant for the configuration of the default currency. + @return + <NULL/> if not found + else pointer to <type>NfCurrencyEntry</type> + */ + static const NfCurrencyEntry* GetCurrencyEntry( const OUString& rAbbrev, + LanguageType eLang ); + + /** Return a <type>NfCurrencyEntry</type> pointer matching the symbol + combination of a LegacyOnly currency. Note that this means only that + the currency matching both symbols was once used in the Office, but is + not offered in dialogs anymore. It doesn't even mean that the currency + symbol combination is valid, since the reason for removing it may have + been just that. #i61657# + @return + A matching entry, or else <NULL/>. + */ + static const NfCurrencyEntry* GetLegacyOnlyCurrencyEntry( const OUString& rSymbol, const OUString& rAbbrev ); + + /** Set the default system currency. The combination of abbreviation and + language must match an existent element of theCurrencyTable. If not, + the SYSTEM (current locale) entry becomes the default. + This method is meant for the configuration of the default currency. + */ + static void SetDefaultSystemCurrency( const OUString& rAbbrev, LanguageType eLang ); + + /** Get all standard formats for a specific currency, formats are + appended to the <type>NfWSStringsDtor</type> list. + @param bBank + <TRUE/>: generate only format strings with currency abbreviation + <FALSE/>: mixed format strings + @return + position of default format + */ + sal_uInt16 GetCurrencyFormatStrings( NfWSStringsDtor&, const NfCurrencyEntry&, + bool bBank ) const; + + /** Whether nFormat is of type NUMBERFORMAT_CURRENCY and the format code + contains a new SYMBOLTYPE_CURRENCY and if so which one [$xxx-nnn]. + If ppEntry is not NULL and exactly one entry is found, a [$xxx-nnn] is + returned, even if the format code only contains [$xxx] ! + */ + bool GetNewCurrencySymbolString( sal_uInt32 nFormat, String& rSymbol, + const NfCurrencyEntry** ppEntry = NULL, + bool* pBank = NULL ) const; + + /** Look up the corresponding <type>NfCurrencyEntry</type> matching + rSymbol (may be CurrencySymbol or CurrencyAbbreviation) and possibly + a rExtension (being yyy of [$xxx-yyy]) or a given language/country + value. Tries to match a rSymbol with rExtension first, then with + eFormatLanguage, then rSymbol only. This is because a currency entry + might have been constructed using I18N locale data where a used locale + of a currrency format code must not necessarily match the locale of + the locale data itself, e.g. [$HK$-40C] (being "zh_HK" locale) in + zh_CN locale data. Here the rExtension would have the value 0x40c but + eFormatLanguage of the number format would have the value of zh_CN + locale, the value with which the corresponding CurrencyEntry is + constructed. + + @param bFoundBank + Only used for output. + If the return value is not <NULL/> this value is set to <TRUE/> if + the matching entry was found by comparing rSymbol against the + CurrencyAbbreviation (AKA BankSymbol). + If the return value is <NULL/> the value of bFoundBank is undefined. + @param rSymbol + Currency symbol, preferably obtained of a format by a call to + <method>SvNumberformat::GetNewCurrencySymbol()</method> + @param rExtension + Currency extension, preferably obtained of a format by a call to + <method>SvNumberformat::GetNewCurrencySymbol()</method> + @param eFormatLanguage + The language/country value of the format of which rSymbol and + rExtension are obtained (<method>SvNumberformat::GetLanguage()</method>). + @param bOnlyStringLanguage + If <TRUE/> only entries with language/country of rExtension are + checked, no match on eFormatLanguage. If rExtension is empty all + entries are checked. + @return + The matching entry if unique (in which case bFoundBank is set), + else <NULL/>. + */ + static const NfCurrencyEntry* GetCurrencyEntry( bool & bFoundBank, + const OUString& rSymbol, + const OUString& rExtension, + LanguageType eFormatLanguage, + bool bOnlyStringLanguage = false ); + + /// Get compatibility ("automatic" old style) currency from I18N locale data + void GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const; + + /// Fill rList with the language/country codes that have been allocated + void GetUsedLanguages( std::vector<sal_uInt16>& rList ); + + /// Fill a <type>NfKeywordIndex</type> table with keywords of a language/country + void FillKeywordTable( NfKeywordTable& rKeywords, LanguageType eLang ); + + /** Return a keyword for a language/country and <type>NfKeywordIndex</type> + for XML import, to generate number format strings. */ + OUString GetKeyword( LanguageType eLnge, sal_uInt16 nIndex ); + + /** Return the GENERAL keyword in proper case ("General") for a + language/country, used in XML import */ + OUString GetStandardName( LanguageType eLnge ); + + /** Check if a specific locale has supported locale data. */ + static bool IsLocaleInstalled( LanguageType eLang ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + LanguageTag maLanguageTag; + SvNumberFormatTable aFTable; // Table of format keys to format entries + typedef std::map<sal_uInt32, sal_uInt32> DefaultFormatKeysMap; + DefaultFormatKeysMap aDefaultFormatKeys; // Table of default standard to format keys + SvNumberFormatTable* pFormatTable; // For the UI dialog + SvNumberFormatterIndexTable* pMergeTable; // List of indices for merging two formatters + CharClass* pCharClass; // CharacterClassification + OnDemandLocaleDataWrapper xLocaleData; // LocaleData switched between SYSTEM, ENGLISH and other + OnDemandTransliterationWrapper xTransliteration; // Transliteration loaded on demand + OnDemandCalendarWrapper xCalendar; // Calendar loaded on demand + OnDemandNativeNumberWrapper xNatNum; // Native number service loaded on demand + ImpSvNumberInputScan* pStringScanner; // Input string scanner + ImpSvNumberformatScan* pFormatScanner; // Format code string scanner + Link aColorLink; // User defined color table CallBack + sal_uInt32 MaxCLOffset; // Max language/country offset used + sal_uInt32 nDefaultSystemCurrencyFormat; // NewCurrency matching SYSTEM locale + LanguageType IniLnge; // Initialized setting language/country + LanguageType ActLnge; // Current setting language/country + NfEvalDateFormat eEvalDateFormat; // DateFormat evaluation + bool bNoZero; // Zero value suppression + + // cached locale data items needed almost any time + OUString aDecimalSep; + OUString aThousandSep; + OUString aDateSep; + +#ifdef _ZFORLIST_CXX // ----- private Methoden ----- + + SVL_DLLPRIVATE static bool bCurrencyTableInitialized; + SVL_DLLPRIVATE static sal_uInt16 nSystemCurrencyPosition; + SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl* pFormatterRegistry; + + // get the registry, create one if none exists + SVL_DLLPRIVATE static SvNumberFormatterRegistry_Impl& GetFormatterRegistry(); + + // called by ctors + SVL_DLLPRIVATE void ImpConstruct( LanguageType eLang ); + + // Changes initialized language/country, clears the entries and generates + // new ones, may ONLY be called by the binary file format load + SVL_DLLPRIVATE void ImpChangeSysCL( LanguageType eLnge, bool bNoAdditionalFormats ); + + // Generate builtin formats provided by i18n behind CLOffset, + // if bNoAdditionalFormats==false also generate additional i18n formats. + SVL_DLLPRIVATE void ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditionalFormats ); + + // Generate additional formats provided by i18n + SVL_DLLPRIVATE void ImpGenerateAdditionalFormats( sal_uInt32 CLOffset, + NumberFormatCodeWrapper& rNumberFormatCode, + bool bAfterChangingSystemCL ); + + SVL_DLLPRIVATE SvNumberformat* ImpInsertFormat( const ::com::sun::star::i18n::NumberFormatCode& rCode, + sal_uInt32 nPos, + bool bAfterChangingSystemCL = false, + sal_Int16 nOrgIndex = 0 ); + // ImpInsertNewStandardFormat for new (since version ...) builtin formats + SVL_DLLPRIVATE SvNumberformat* ImpInsertNewStandardFormat( const ::com::sun::star::i18n::NumberFormatCode& rCode, + sal_uInt32 nPos, + sal_uInt16 nVersion, + bool bAfterChangingSystemCL = false, + sal_Int16 nOrgIndex = 0 ); + + // Return CLOffset or (MaxCLOffset + SV_COUNTRY_LANGUAGE_OFFSET) if new language/country + SVL_DLLPRIVATE sal_uInt32 ImpGetCLOffset(LanguageType eLnge) const; + + // Test whether format code already exists, then return index key, + // otherwise NUMBERFORMAT_ENTRY_NOT_FOUND + SVL_DLLPRIVATE sal_uInt32 ImpIsEntry( const OUString& rString, + sal_uInt32 CLOffset, + LanguageType eLnge ); + + // Create builtin formats for language/country if necessary, return CLOffset + SVL_DLLPRIVATE sal_uInt32 ImpGenerateCL( LanguageType eLnge, bool bNoAdditionalFormats = false ); + + // Build negative currency format, old compatibility style + SVL_DLLPRIVATE void ImpGetNegCurrFormat(OUStringBuffer& sNegStr, const OUString& rCurrSymbol); + // Build positive currency format, old compatibility style + SVL_DLLPRIVATE void ImpGetPosCurrFormat(OUStringBuffer& sPosStr, const OUString& rCurrSymbol); + + // Create <type>theCurrencyTable</type> with all <type>NfCurrencyEntry</type> + SVL_DLLPRIVATE static void ImpInitCurrencyTable(); + + // Return the format index of the currency format of the system locale. + // Format is created if not already present. + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultSystemCurrencyFormat(); + + // Return the format index of the currency format of the current locale. + // Format is created if not already present. + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultCurrencyFormat(); + + // Return the default format for a given type and current locale. + // May ONLY be called from within GetStandardFormat(). + SVL_DLLPRIVATE sal_uInt32 ImpGetDefaultFormat( short nType ); + + // Return the index in a sequence of format codes matching an enum of + // NfIndexTableOffset. If not found 0 is returned. If the sequence doesn't + // contain any format code elements a default element is created and inserted. + SVL_DLLPRIVATE sal_Int32 ImpGetFormatCodeIndex( ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::NumberFormatCode >& rSeq, + const NfIndexTableOffset nTabOff ); + + // Adjust a sequence of format codes to contain only one (THE) default + // instead of multiple defaults for short/medium/long types. + // If there is no medium but a short and a long default the long is taken. + // Return the default index in the sequence. + // Non-PRODUCT version may check locale data for matching defaults in one + // FormatElement group. + SVL_DLLPRIVATE sal_Int32 ImpAdjustFormatCodeDefault( ::com::sun::star::i18n::NumberFormatCode * pFormatArr, + sal_Int32 nCount, bool bCheckCorrectness = true ); + + // Obtain the format entry for a given key index. + SVL_DLLPRIVATE SvNumberformat* GetFormatEntry( sal_uInt32 nKey ); + SVL_DLLPRIVATE const SvNumberformat* GetFormatEntry( sal_uInt32 nKey ) const + { + return GetEntry( nKey); + } + + // used as a loop body inside of GetNewCurrencySymbolString() and GetCurrencyEntry() +#ifndef DBG_UTIL + inline +#endif + static bool ImpLookupCurrencyEntryLoopBody( const NfCurrencyEntry*& pFoundEntry, + bool& bFoundBank, const NfCurrencyEntry* pData, + sal_uInt16 nPos, const OUString& rSymbol ); + + // link to be set at <method>SvtSysLocaleOptions::SetCurrencyChangeLink()</method> + DECL_DLLPRIVATE_STATIC_LINK( SvNumberFormatter, CurrencyChangeLink, void* ); + +#endif // _ZFORLIST_CXX + +public: + + // own static mutex, may also be used by internal class SvNumberFormatterRegistry_Impl + static ::osl::Mutex& GetMutex(); + + // called by SvNumberFormatterRegistry_Impl::Notify if the default system currency changes + void ResetDefaultSystemCurrency(); + + // Called by SvNumberFormatterRegistry_Impl::Notify if the system locale's + // date acceptence patterns change. + void InvalidateDateAcceptancePatterns(); + + // Replace the SYSTEM language/country format codes. Called upon change of + // the user configurable locale. + // Old compatibility codes are replaced, user defined are converted, and + // new format codes are appended. + void ReplaceSystemCL( LanguageType eOldLanguage ); + + inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > GetComponentContext() const + { + return m_xContext; + } + + + + //! The following method is not to be used from outside but must be + //! public for the InputScanner. + // return the current FormatScanner + inline const ImpSvNumberformatScan* GetFormatScanner() const { return pFormatScanner; } + + + //! The following methods are not to be used from outside but must be + //! public for the InputScanner and FormatScanner. + + // return current (!) Locale + inline const LanguageTag& GetLanguageTag() const { return maLanguageTag; } + + // return corresponding Transliteration wrapper + inline const ::utl::TransliterationWrapper* GetTransliteration() const + { + return xTransliteration.get(); + } + + // return corresponding Transliteration wrapper with loadModuleByImplName() + inline const ::utl::TransliterationWrapper* GetTransliterationForModule( const OUString& rModule, + LanguageType eLang ) const + { + return xTransliteration.getForModule( rModule, eLang ); + } + + // return the corresponding CharacterClassification wrapper + inline const CharClass* GetCharClass() const { return pCharClass; } + + // return the corresponding LocaleData wrapper + inline const LocaleDataWrapper* GetLocaleData() const { return xLocaleData.get(); } + + // return the corresponding Calendar wrapper + inline CalendarWrapper* GetCalendar() const { return xCalendar.get(); } + + // return the corresponding NativeNumberSupplier wrapper + inline const NativeNumberWrapper* GetNatNum() const { return xNatNum.get(); } + + // cached locale data items + + // return the corresponding decimal separator + inline const OUString& GetNumDecimalSep() const { return aDecimalSep; } + + // return the corresponding group (AKA thousand) separator + inline const OUString& GetNumThousandSep() const { return aThousandSep; } + + // return the corresponding date separator + inline const OUString& GetDateSep() const { return aDateSep; } + +}; + + +// --------------------------- inline -------------------------------------- + +inline sal_uInt32 SvNumberFormatter::GetMergeFmtIndex( sal_uInt32 nOldFmt ) const +{ + if (pMergeTable) + { + SvNumberFormatterIndexTable::iterator it = pMergeTable->find(nOldFmt); + if (it != pMergeTable->end()) + { + return it->second; + } + } + return nOldFmt; +} + +inline bool SvNumberFormatter::HasMergeFmtTbl() const +{ + return pMergeTable && !pMergeTable->empty(); +} + + +// static +inline sal_uInt16 SvNumberFormatter::ExpandTwoDigitYear( sal_uInt16 nYear, sal_uInt16 nTwoDigitYearStart ) +{ + if ( nYear < 100 ) + { + if ( nYear < (nTwoDigitYearStart % 100) ) + { + return nYear + (((nTwoDigitYearStart / 100) + 1) * 100); + } + else + { + return nYear + ((nTwoDigitYearStart / 100) * 100); + } + } + return nYear; +} + +#endif // _ZFORLIST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx new file mode 100644 index 000000000000..20cc4d110c24 --- /dev/null +++ b/include/svl/zformat.hxx @@ -0,0 +1,712 @@ +/* -*- 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 _ZFORMAT_HXX +#define _ZFORMAT_HXX + +#include "svl/svldllapi.h" +#include <i18nlangtag/mslangid.hxx> +#include <svl/zforlist.hxx> +#include <svl/nfversi.hxx> +#include <svl/nfkeytab.hxx> + +// We need ImpSvNumberformatScan for the private SvNumberformat definitions. +#ifdef _ZFORMAT_CXX +#include "zforscan.hxx" +#endif + +namespace utl { + class DigitGroupingIterator; +} + +class SvStream; +class Color; + +class ImpSvNumberformatScan; // format code string scanner +class ImpSvNumberInputScan; // input string scanner +class ImpSvNumMultipleWriteHeader; // compatible file format +class ImpSvNumMultipleReadHeader; // compatible file format +class SvNumberFormatter; + +enum SvNumberformatLimitOps +{ + NUMBERFORMAT_OP_NO = 0, // Undefined, no OP + NUMBERFORMAT_OP_EQ = 1, // Operator = + NUMBERFORMAT_OP_NE = 2, // Operator <> + NUMBERFORMAT_OP_LT = 3, // Operator < + NUMBERFORMAT_OP_LE = 4, // Operator <= + NUMBERFORMAT_OP_GT = 5, // Operator > + NUMBERFORMAT_OP_GE = 6 // Operator >= +}; + +// SYSTEM-german to SYSTEM-xxx and vice versa conversion hack onLoad +enum NfHackConversion +{ + NF_CONVERT_NONE, + NF_CONVERT_GERMAN_ENGLISH, + NF_CONVERT_ENGLISH_GERMAN +}; + +struct ImpSvNumberformatInfo // Struct for FormatInfo +{ + OUString* sStrArray; // Array of symbols + short* nTypeArray; // Array of infos + sal_uInt16 nThousand; // Count of group separator sequences + sal_uInt16 nCntPre; // Count of digits before decimal point + sal_uInt16 nCntPost; // Count of digits after decimal point + sal_uInt16 nCntExp; // Count of exponent digits, or AM/PM + short eScannedType; // Type determined by scan + bool bThousand; // Has group (AKA thousand) separator + + void Copy( const ImpSvNumberformatInfo& rNumFor, sal_uInt16 nAnz ); + void Load(SvStream& rStream, sal_uInt16 nAnz); + void Save(SvStream& rStream, sal_uInt16 nAnz) const; +}; + +// NativeNumber, represent numbers using CJK or other digits if nNum>0, +// eLang specifies the Locale to use. +class SvNumberNatNum +{ + LanguageType eLang; + sal_uInt8 nNum; + bool bDBNum :1; // DBNum, to be converted to NatNum + bool bDate :1; // Used in date? (needed for DBNum/NatNum mapping) + bool bSet :1; // If set, since NatNum0 is possible + +public: + + static sal_uInt8 MapDBNumToNatNum( sal_uInt8 nDBNum, LanguageType eLang, bool bDate ); +#ifdef THE_FUTURE + static sal_uInt8 MapNatNumToDBNum( sal_uInt8 nNatNum, LanguageType eLang, bool bDate ); +#endif + + SvNumberNatNum() : eLang( LANGUAGE_DONTKNOW ), nNum(0), + bDBNum(0), bDate(0), bSet(0) {} + bool IsComplete() const { return bSet && eLang != LANGUAGE_DONTKNOW; } + sal_uInt8 GetRawNum() const { return nNum; } + sal_uInt8 GetNatNum() const { return bDBNum ? MapDBNumToNatNum( nNum, eLang, bDate ) : nNum; } +#ifdef THE_FUTURE + sal_uInt8 GetDBNum() const { return bDBNum ? nNum : MapNatNumToDBNum( nNum, eLang, bDate ); } +#endif + LanguageType GetLang() const { return eLang; } + void SetLang( LanguageType e ) { eLang = e; } + void SetNum( sal_uInt8 nNumber, bool bDBNumber ) + { + nNum = nNumber; + bDBNum = bDBNumber; + bSet = true; + } + bool IsSet() const { return bSet; } + void SetDate( bool bDateP ) { bDate = (bDateP != 0); } +}; + +class CharClass; + +class ImpSvNumFor // One of four subformats of the format code string +{ +public: + ImpSvNumFor(); // Ctor without filling the Info + ~ImpSvNumFor(); + + void Enlarge(sal_uInt16 nAnz); // Init of arrays to the right size + void Load( SvStream& rStream, ImpSvNumberformatScan& rSc, + OUString& rLoadedColorName); + void Save( SvStream& rStream ) const; + + // if pSc is set, it is used to get the Color pointer + void Copy( const ImpSvNumFor& rNumFor, ImpSvNumberformatScan* pSc ); + + // Access to Info; call Enlarge before! + ImpSvNumberformatInfo& Info() { return aI;} + const ImpSvNumberformatInfo& Info() const { return aI; } + + // Get count of substrings (symbols) + sal_uInt16 GetCount() const { return nAnzStrings;} + + Color* GetColor() const { return pColor; } + void SetColor( Color* pCol, OUString& rName ) + { pColor = pCol; sColorName = rName; } + const OUString& GetColorName() const { return sColorName; } + + // new SYMBOLTYPE_CURRENCY in subformat? + bool HasNewCurrency() const; + bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const; + void SaveNewCurrencyMap( SvStream& rStream ) const; + void LoadNewCurrencyMap( SvStream& rStream ); + + // [NatNum1], [NatNum2], ... + void SetNatNumNum( sal_uInt8 nNum, bool bDBNum ) { aNatNum.SetNum( nNum, bDBNum ); } + void SetNatNumLang( LanguageType eLang ) { aNatNum.SetLang( eLang ); } + void SetNatNumDate( bool bDate ) { aNatNum.SetDate( bDate ); } + const SvNumberNatNum& GetNatNum() const { return aNatNum; } + +private: + ImpSvNumberformatInfo aI; // Hilfsstruct fuer die restlichen Infos + OUString sColorName; // color name + Color* pColor; // pointer to color of subformat + sal_uInt16 nAnzStrings; // count of symbols + SvNumberNatNum aNatNum; // DoubleByteNumber + +}; + +class SVL_DLLPUBLIC SvNumberformat +{ + struct LocaleType + { + sal_uInt8 mnNumeralShape; + sal_uInt8 mnCalendarType; + LanguageType meLanguage; + + OUString generateCode() const; + + LocaleType(); + LocaleType(sal_uInt32 nRawCode); + }; + +public: + // Ctor for Load + SvNumberformat( ImpSvNumberformatScan& rSc, LanguageType eLge ); + + // Normal ctor + SvNumberformat( OUString& rString, + ImpSvNumberformatScan* pSc, + ImpSvNumberInputScan* pISc, + sal_Int32& nCheckPos, + LanguageType& eLan, + bool bStand = false ); + + // Copy ctor + SvNumberformat( SvNumberformat& rFormat ); + + // Copy ctor with exchange of format code string scanner (used in merge) + SvNumberformat( SvNumberformat& rFormat, ImpSvNumberformatScan& rSc ); + + ~SvNumberformat(); + + /// Get type of format, may include NUMBERFORMAT_DEFINED bit + short GetType() const + { return (nNewStandardDefined && + (nNewStandardDefined <= SV_NUMBERFORMATTER_VERSION)) ? + (eType & ~NUMBERFORMAT_DEFINED) : eType; } + + void SetType(const short eSetType) { eType = eSetType; } + // Standard means the I18N defined standard format of this type + void SetStandard() { bStandard = true; } + bool IsStandard() const { return bStandard; } + + // For versions before version nVer it is UserDefined, for newer versions + // it is builtin. nVer of SV_NUMBERFORMATTER_VERSION_... + void SetNewStandardDefined( sal_uInt16 nVer ) + { nNewStandardDefined = nVer; eType |= NUMBERFORMAT_DEFINED; } + + sal_uInt16 GetNewStandardDefined() const { return nNewStandardDefined; } + bool IsAdditionalStandardDefined() const + { return nNewStandardDefined == SV_NUMBERFORMATTER_VERSION_ADDITIONAL_I18N_FORMATS; } + + LanguageType GetLanguage() const { return maLocale.meLanguage;} + + const OUString& GetFormatstring() const { return sFormatstring; } + + // Build a format string of application defined keywords + OUString GetMappedFormatstring( const NfKeywordTable& rKeywords, + const LocaleDataWrapper& rLoc, + bool bDontQuote = false ) const; + + void SetUsed(const bool b) { bIsUsed = b; } + bool GetUsed() const { return bIsUsed; } + bool IsStarFormatSupported() const { return bStarFlag; } + void SetStarFormatSupport( bool b ) { bStarFlag = b; } + + NfHackConversion Load( SvStream& rStream, ImpSvNumMultipleReadHeader& rHdr, + SvNumberFormatter* pConverter, ImpSvNumberInputScan& rISc ); + void Save( SvStream& rStream, ImpSvNumMultipleWriteHeader& rHdr ) const; + + // Load a string which might contain an Euro symbol, + // in fact that could be any string used in number formats. + static OUString LoadString( SvStream& rStream ); + + /** + * Get output string from a numeric value that fits the number of + * characters specified. + */ + bool GetOutputString( double fNumber, sal_uInt16 nCharCount, OUString& rOutString ) const; + + bool GetOutputString( double fNumber, OUString& OutString, Color** ppColor ); + bool GetOutputString( const OUString& sString, OUString& OutString, Color** ppColor ); + + // True if type text + bool IsTextFormat() const { return (eType & NUMBERFORMAT_TEXT) != 0; } + // True if 4th subformat present + bool HasTextFormat() const + { + return (NumFor[3].GetCount() > 0) || + (NumFor[3].Info().eScannedType == NUMBERFORMAT_TEXT); + } + + void GetFormatSpecialInfo(bool& bThousand, + bool& IsRed, + sal_uInt16& nPrecision, + sal_uInt16& nAnzLeading) const; + + /// Count of decimal precision + sal_uInt16 GetFormatPrecision() const { return NumFor[0].Info().nCntPost; } + + //! Read/write access on a special sal_uInt16 component, may only be used on the + //! standard format 0, 5000, ... and only by the number formatter! + sal_uInt16 GetLastInsertKey() const + { return NumFor[0].Info().nThousand; } + void SetLastInsertKey(sal_uInt16 nKey) + { NumFor[0].Info().nThousand = nKey; } + + //! Only onLoad: convert from stored to current system language/country + void ConvertLanguage( SvNumberFormatter& rConverter, + LanguageType eConvertFrom, LanguageType eConvertTo, bool bSystem = false ); + + // Substring of a subformat code nNumFor (0..3) + // nPos == 0xFFFF => last substring + // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY + const OUString* GetNumForString( sal_uInt16 nNumFor, sal_uInt16 nPos, + bool bString = false ) const; + + // Subtype of a subformat code nNumFor (0..3) + // nPos == 0xFFFF => last substring + // bString==true: first/last SYMBOLTYPE_STRING or SYMBOLTYPE_CURRENCY + short GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos, bool bString = false ) const; + + sal_Int32 GetForcedDenominatorForType( sal_uInt16 nNumFor ) const; + /** If the count of string elements (substrings, ignoring [modifiers] and + so on) in a subformat code nNumFor (0..3) is equal to the given number. + Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched + format. */ + bool IsNumForStringElementCountEqual( sal_uInt16 nNumFor, sal_uInt16 nAllCount, + sal_uInt16 nNumCount ) const + { + if ( nNumFor < 4 ) + { + // First try a simple approach. Note that this is called only + // if all MidStrings did match so far, to verify that all + // strings of the format were matched and not just the starting + // sequence, so we don't have to check if GetnAnz() includes + // [modifiers] or anything else if both counts are equal. + sal_uInt16 nCnt = NumFor[nNumFor].GetCount(); + if ( nAllCount == nCnt ) + return true; + if ( nAllCount < nCnt ) // check ignoring [modifiers] and so on + return ImpGetNumForStringElementCount( nNumFor ) == + (nAllCount - nNumCount); + } + return false; + } + + // Whether the second subformat code is really for negative numbers + // or another limit set. + bool IsSecondSubformatRealNegative() const + { + return fLimit1 == 0.0 && fLimit2 == 0.0 && + ( (eOp1 == NUMBERFORMAT_OP_GE && eOp2 == NUMBERFORMAT_OP_NO) || + (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) || + (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) ); + } + + // Whether the first subformat code is really for negative numbers + // or another limit set. + bool IsFirstSubformatRealNegative() const + { + return fLimit1 == 0.0 && fLimit2 == 0.0 && + ((eOp1 == NUMBERFORMAT_OP_LT && + (eOp2 == NUMBERFORMAT_OP_GT || eOp2 == NUMBERFORMAT_OP_EQ || + eOp2 == NUMBERFORMAT_OP_GE || eOp2 == NUMBERFORMAT_OP_NO)) || + (eOp1 == NUMBERFORMAT_OP_LE && + (eOp2 == NUMBERFORMAT_OP_NO || eOp2 == NUMBERFORMAT_OP_GT))); + } + + // Whether the negative format is without a sign or not + bool IsNegativeWithoutSign() const; + + bool IsNegativeInBracket() const; + + bool HasPositiveBracketPlaceholder() const; + + // Whether a new SYMBOLTYPE_CURRENCY is contained in the format + bool HasNewCurrency() const; + + // Build string from NewCurrency for saving it SO50 compatible + void Build50Formatstring( OUString& rStr ) const; + + // strip [$-yyy] from all [$xxx-yyy] leaving only xxx's, + // if bQuoteSymbol==true the xxx will become "xxx" + static OUString StripNewCurrencyDelimiters( const OUString& rStr, + bool bQuoteSymbol ); + + // If a new SYMBOLTYPE_CURRENCY is contained if the format is of type + // NUMBERFORMAT_CURRENCY, and if so the symbol xxx and the extension nnn + // of [$xxx-nnn] are returned + bool GetNewCurrencySymbol( OUString& rSymbol, OUString& rExtension ) const; + + static bool HasStringNegativeSign( const OUString& rStr ); + + /** + Whether a character at position nPos is somewhere between two matching + cQuote or not. + If nPos points to a cQuote, a true is returned on an opening cQuote, + a false is returned on a closing cQuote. + A cQuote between quotes may be escaped by a cEscIn, a cQuote outside of + quotes may be escaped by a cEscOut. + The default '\0' results in no escapement possible. + Defaults are set right according to the "unlogic" of the Numberformatter + */ + static bool IsInQuote( const OUString& rString, sal_Int32 nPos, + sal_Unicode cQuote = '"', + sal_Unicode cEscIn = '\0', sal_Unicode cEscOut = '\\' ); + + /** + Return the position of a matching closing cQuote if the character at + position nPos is between two matching cQuote, otherwise return + STRING_NOTFOUND. + If nPos points to an opening cQuote the position of the matching + closing cQuote is returned. + If nPos points to a closing cQuote nPos is returned. + If nPos points into a part which starts with an opening cQuote but has + no closing cQuote, rString.Len() is returned. + Uses <method>IsInQuote</method> internally, so you don't have to call + that prior to a call of this method. + */ + static sal_Int32 GetQuoteEnd( const OUString& rString, sal_Int32 nPos, + sal_Unicode cQuote = '"', + sal_Unicode cEscIn = '\0', + sal_Unicode cEscOut = '\\' ); + + void SetComment( const OUString& rStr ) + { sComment = rStr; } + const OUString& GetComment() const { return sComment; } + + /** Insert the number of blanks into the string that is needed to simulate + the width of character c for underscore formats */ + static sal_Int32 InsertBlanks( OUString& r, sal_Int32 nPos, sal_Unicode c ) + { + sal_Int32 result; + OUStringBuffer sBuff(r); + + result = InsertBlanks(sBuff, nPos, c); + r = sBuff.makeStringAndClear(); + + return result; + } + + /** Insert the number of blanks into the string that is needed to simulate + the width of character c for underscore formats */ + static sal_Int32 InsertBlanks( OUStringBuffer& r, sal_Int32 nPos, sal_Unicode c ); + + /// One of YMD,DMY,MDY if date format + DateFormat GetDateOrder() const; + + /** A coded value of the exact YMD combination used, if date format. + For example: YYYY-MM-DD => ('Y' << 16) | ('M' << 8) | 'D' + or: MM/YY => ('M' << 8) | 'Y' */ + sal_uInt32 GetExactDateOrder() const; + + ImpSvNumberformatScan& ImpGetScan() const { return rScan; } + + // used in XML export + void GetConditions( SvNumberformatLimitOps& rOper1, double& rVal1, + SvNumberformatLimitOps& rOper2, double& rVal2 ) const; + Color* GetColor( sal_uInt16 nNumFor ) const; + void GetNumForInfo( sal_uInt16 nNumFor, short& rScannedType, + bool& bThousand, sal_uInt16& nPrecision, sal_uInt16& nAnzLeading ) const; + + // rAttr.Number not empty if NatNum attributes are to be stored + void GetNatNumXml( + ::com::sun::star::i18n::NativeNumberXmlAttributes& rAttr, + sal_uInt16 nNumFor ) const; + + /** @returns <TRUE/> if E,EE,R,RR,AAA,AAAA in format code of subformat + nNumFor (0..3) and <b>no</b> preceding calendar was specified and the + currently loaded calendar is "gregorian". */ + bool IsOtherCalendar( sal_uInt16 nNumFor ) const + { + if ( nNumFor < 4 ) + return ImpIsOtherCalendar( NumFor[nNumFor] ); + return false; + } + + /** Switches to the first non-"gregorian" calendar, but only if the current + calendar is "gregorian"; original calendar name and date/time returned, + but only if calendar switched and rOrgCalendar was empty. */ + void SwitchToOtherCalendar( OUString& rOrgCalendar, double& fOrgDateTime ) const; + + /** Switches to the "gregorian" calendar, but only if the current calendar + is non-"gregorian" and rOrgCalendar is not empty. Thus a preceding + ImpSwitchToOtherCalendar() call should have been placed prior to + calling this method. */ + void SwitchToGregorianCalendar( const OUString& rOrgCalendar, double fOrgDateTime ) const; + +#ifdef THE_FUTURE + /** Switches to the first specified calendar, if any, in subformat nNumFor + (0..3). Original calendar name and date/time returned, but only if + calendar switched and rOrgCalendar was empty. + + @return + <TRUE/> if a calendar was specified and switched to, + <FALSE/> else. + */ + bool SwitchToSpecifiedCalendar( OUString& rOrgCalendar, double& fOrgDateTime, + sal_uInt16 nNumFor ) const + { + if ( nNumFor < 4 ) + return ImpSwitchToSpecifiedCalendar( rOrgCalendar, + fOrgDateTime, NumFor[nNumFor] ); + return false; + } +#endif + + /// Whether it's a (YY)YY-M(M)-D(D) format. + bool IsIso8601( sal_uInt16 nNumFor ) + { + if ( nNumFor < 4 ) + return ImpIsIso8601( NumFor[nNumFor]); + return false; + } + +private: + ImpSvNumFor NumFor[4]; // Array for the 4 subformats + OUString sFormatstring; // The format code string + OUString sComment; // Comment, since number formatter version 6 + double fLimit1; // Value for first condition + double fLimit2; // Value for second condition + ImpSvNumberformatScan& rScan; // Format code scanner + LocaleType maLocale; // Language/country of the format, numeral shape and calendar type from Excel. + SvNumberformatLimitOps eOp1; // Operator for first condition + SvNumberformatLimitOps eOp2; // Operator for second condition + sal_uInt16 nNewStandardDefined; // new builtin formats as of version 6 + short eType; // Type of format + bool bStarFlag; // Take *n format as ESC n + bool bStandard; // If this is a default standard format + bool bIsUsed; // Flag as used for storing + + SVL_DLLPRIVATE sal_uInt16 ImpGetNumForStringElementCount( sal_uInt16 nNumFor ) const; + + SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const; + +#ifdef THE_FUTURE + SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( OUString& rOrgCalendar, + double& fOrgDateTime, + const ImpSvNumFor& rNumFor ) const; +#endif + + /** Whether to use possessive genitive case month name, or partitive case + month name, instead of nominative name (noun). + + @param io_nState + 0: execute check <br> + set to 1 if nominative case is returned, <br> + set to 2 if genitive case is returned, <br> + set to 3 if partitive case is returned <br> + 1: don't execute check, return nominative case <br> + 2: don't execute check, return genitive case <br> + 3: don't execute check, return partitive case <br> + + @param eCodeType + a NfKeywordIndex, must designate a month type code + + @returns one of com::sun::star::i18n::CalendarDisplayCode values + according to eCodeType and the check executed (or passed). + */ + SVL_DLLPRIVATE sal_Int32 ImpUseMonthCase( int & io_nState, const ImpSvNumFor& rNumFor, NfKeywordIndex eCodeType ) const; + + /// Whether it's a (YY)YY-M(M)-D(D) format. + SVL_DLLPRIVATE bool ImpIsIso8601( const ImpSvNumFor& rNumFor ); + +#ifdef _ZFORMAT_CXX // ----- private implementation methods ----- + + const CharClass& rChrCls() const { return rScan.GetChrCls(); } + const LocaleDataWrapper& rLoc() const { return rScan.GetLoc(); } + CalendarWrapper& GetCal() const { return rScan.GetCal(); } + const SvNumberFormatter& GetFormatter() const { return *rScan.GetNumberformatter(); } + + // divide in substrings and color conditions + SVL_DLLPRIVATE short ImpNextSymbol( OUStringBuffer& rString, + sal_Int32& nPos, + OUString& sSymbol ); + + // read string until ']' and strip blanks (after condition) + SVL_DLLPRIVATE static sal_Int32 ImpGetNumber( OUStringBuffer& rString, + sal_Int32& nPos, + OUString& sSymbol ); + + /** + * Parse the content of '[$-xxx] or '[$-xxxxxxxx]' and extract the locale + * type from it. Given the string, start parsing at position specified by + * nPos, and store the end position with nPos when the parsing is + * complete. The nPos should point to the '$' before the parsing, and to + * the closing bracket after the parsing. When the content is [$-xxx], + * the xxx part represents the language type (aka LCID) in hex numerals. + * When the content is [$-xxxxxxxx] the last 4 digits represent the LCID + * (again in hex), the next 2 digits represent the calendar type, and the + * 2 highest digits (if exists) is the numeral shape. + * + * @reference + * http://office.microsoft.com/en-us/excel-help/creating-international-number-formats-HA001034635.aspx + * + * @param rString input string + * @param nPos position (see above). + * + * @return struct containing numeral shape, calendar type, and LCID that + * specifies language type. See i18nlangtag/lang.h for a complete + * list of language types. These numbers also correspond with the + * numbers used by Microsoft Office. + */ + SVL_DLLPRIVATE static LocaleType ImpGetLocaleType( const OUString& rString, sal_Int32& nPos ); + + /** Obtain calendar and numerals from a LocaleType that was parsed from a + LCID with ImpGetLocaleType(). + + Inserts a NatNum modifier to rString at nPos if needed as determined + from the numeral code. + + @ATTENTION: may modify <member>maLocale</member> to make it follow + aTmpLocale, in which case also nLang is adapted. + + @returns a string with the calendar if one was determined from the + calendar code, else an empty string. The calendar string needs to be + inserted at a proper positon to rString after all bracketed prefixes. + */ + SVL_DLLPRIVATE OUString ImpObtainCalendarAndNumerals( OUStringBuffer & rString, + sal_Int32 & nPos, + LanguageType & nLang, + const LocaleType & aTmpLocale ); + + // standard number output + SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUString& OutString ); + SVL_DLLPRIVATE void ImpGetOutputStandard( double& fNumber, OUStringBuffer& OutString ); + SVL_DLLPRIVATE void ImpGetOutputStdToPrecision( double& rNumber, OUString& rOutString, sal_uInt16 nPrecision ) const; + // numbers in input line + SVL_DLLPRIVATE void ImpGetOutputInputLine( double fNumber, OUString& OutString ); + + // check subcondition + // OP undefined => -1 + // else 0 or 1 + SVL_DLLPRIVATE short ImpCheckCondition(double& fNumber, + double& fLimit, + SvNumberformatLimitOps eOp); + + SVL_DLLPRIVATE sal_uLong ImpGGT(sal_uLong x, sal_uLong y); + SVL_DLLPRIVATE sal_uLong ImpGGTRound(sal_uLong x, sal_uLong y); + + // Helper function for number strings + // append string symbols, insert leading 0 or ' ', or ... + SVL_DLLPRIVATE bool ImpNumberFill( OUStringBuffer& sStr, + double& rNumber, + sal_Int32& k, + sal_uInt16& j, + sal_uInt16 nIx, + short eSymbolType ); + + // Helper function to fill in the integer part and the group (AKA thousand) separators + SVL_DLLPRIVATE bool ImpNumberFillWithThousands( OUStringBuffer& sStr, + double& rNumber, + sal_Int32 k, + sal_uInt16 j, + sal_uInt16 nIx, + sal_Int32 nDigCnt ); + // Hilfsfunktion zum Auffuellen der Vor- + // kommazahl auch mit Tausenderpunkt + + // Helper function to fill in the group (AKA thousand) separators + // or to skip additional digits + SVL_DLLPRIVATE void ImpDigitFill( OUStringBuffer& sStr, + sal_Int32 nStart, + sal_Int32& k, + sal_uInt16 nIx, + sal_Int32 & nDigitCount, + utl::DigitGroupingIterator & ); + + SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString); + SVL_DLLPRIVATE bool ImpGetScientificOutput(double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString); + + SVL_DLLPRIVATE bool ImpGetDateOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + SVL_DLLPRIVATE bool ImpGetTimeOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + SVL_DLLPRIVATE bool ImpGetDateTimeOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + + // Switches to the "gregorian" calendar if the current calendar is + // non-"gregorian" and the era is a "Dummy" era of a calendar which doesn't + // know a "before" era (like zh_TW ROC or ja_JP Gengou). If switched and + // rOrgCalendar was "gregorian" the string is emptied. If rOrgCalendar was + // empty the previous calendar name and date/time are returned. + SVL_DLLPRIVATE bool ImpFallBackToGregorianCalendar( OUString& rOrgCalendar, double& fOrgDateTime ); + + // Append a "G" short era string of the given calendar. In the case of a + // Gengou calendar this is a one character abbreviation, for other + // calendars the XExtendedCalendar::getDisplayString() method is called. + SVL_DLLPRIVATE static void ImpAppendEraG( OUStringBuffer& OutStringBuffer, const CalendarWrapper& rCal, + sal_Int16 nNatNum ); + + SVL_DLLPRIVATE bool ImpGetNumberOutput( double fNumber, + sal_uInt16 nIx, + OUStringBuffer& OutString ); + + SVL_DLLPRIVATE void ImpCopyNumberformat( const SvNumberformat& rFormat ); + + // normal digits or other digits, depending on ImpSvNumFor.aNatNum, + // [NatNum1], [NatNum2], ... + SVL_DLLPRIVATE OUString ImpGetNatNumString( const SvNumberNatNum& rNum, sal_Int32 nVal, + sal_uInt16 nMinDigits = 0 ) const; + + OUString ImpIntToString( sal_uInt16 nIx, sal_Int32 nVal, sal_uInt16 nMinDigits = 0 ) const + { + const SvNumberNatNum& rNum = NumFor[nIx].GetNatNum(); + if ( nMinDigits || rNum.IsComplete() ) + { + return ImpGetNatNumString( rNum, nVal, nMinDigits ); + } + return OUString::valueOf(nVal); + } + + // transliterate according to NativeNumber + SVL_DLLPRIVATE OUString impTransliterateImpl(const OUString& rStr, const SvNumberNatNum& rNum) const; + SVL_DLLPRIVATE void impTransliterateImpl(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const; + + OUString impTransliterate(const OUString& rStr, const SvNumberNatNum& rNum) const + { + return rNum.IsComplete() ? impTransliterateImpl(rStr, rNum) : rStr; + } + + SVL_DLLPRIVATE void impTransliterate(OUStringBuffer& rStr, const SvNumberNatNum& rNum) const + { + if(rNum.IsComplete()) + { + impTransliterateImpl(rStr, rNum); + } + } + +#endif // _ZFORMAT_CXX + +}; + +#endif // _ZFORMAT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |