2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2013-11-05 02:17:53 +01:00
|
|
|
#ifndef INCLUDED_SW_INC_DOCARY_HXX
|
|
|
|
#define INCLUDED_SW_INC_DOCARY_HXX
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-01-23 09:42:57 +00:00
|
|
|
#include <com/sun/star/i18n/ForbiddenCharacters.hpp>
|
2012-05-16 11:48:48 +02:00
|
|
|
#include <vector>
|
2012-07-13 15:35:23 +02:00
|
|
|
#include <set>
|
2012-05-16 15:23:09 +02:00
|
|
|
#include <algorithm>
|
2012-07-20 17:16:03 +02:00
|
|
|
#include <o3tl/sorted_vector.hxx>
|
2001-01-23 09:42:57 +00:00
|
|
|
|
2014-01-13 17:58:25 +02:00
|
|
|
class SwRangeRedline;
|
2014-01-16 16:51:09 +02:00
|
|
|
class SwExtraRedline;
|
2000-09-18 16:15:01 +00:00
|
|
|
class SwUnoCrsr;
|
|
|
|
class SwOLENode;
|
2014-03-23 13:19:15 +02:00
|
|
|
class SwTable;
|
|
|
|
class SwTableLine;
|
|
|
|
class SwTableBox;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-01-19 15:45:37 +00:00
|
|
|
namespace com { namespace sun { namespace star { namespace i18n {
|
2012-09-02 09:05:03 +03:00
|
|
|
struct ForbiddenCharacters; ///< comes from the I18N UNO interface
|
2007-09-27 06:59:22 +00:00
|
|
|
}}}}
|
2001-01-19 15:45:37 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <swtypes.hxx>
|
2013-02-16 12:20:08 +01:00
|
|
|
#include <ndarr.hxx>
|
2014-11-08 18:19:04 +01:00
|
|
|
#include <charfmt.hxx>
|
|
|
|
#include <fmtcol.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <section.hxx>
|
2014-11-11 16:52:48 +01:00
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <tox.hxx>
|
|
|
|
#include <numrule.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-02 09:05:03 +03:00
|
|
|
/** provides some methods for generic operations on lists that contain
|
|
|
|
SwFmt* subclasses. */
|
2012-06-20 16:36:51 +02:00
|
|
|
class SwFmtsBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual size_t GetFmtCount() const = 0;
|
2014-11-11 16:52:48 +01:00
|
|
|
virtual SwFmt* GetFmt(size_t idx) const = 0;
|
|
|
|
virtual ~SwFmtsBase() {};
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
template<typename Value>
|
|
|
|
class SwVectorModifyBase : public std::vector<Value>
|
2012-06-20 16:36:51 +02:00
|
|
|
{
|
2014-11-11 16:52:48 +01:00
|
|
|
public:
|
|
|
|
typedef typename std::vector<Value>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
enum class DestructorPolicy {
|
|
|
|
KeepElements,
|
|
|
|
FreeElements,
|
|
|
|
};
|
|
|
|
|
2014-10-01 14:54:59 +09:00
|
|
|
private:
|
2014-11-11 16:52:48 +01:00
|
|
|
const DestructorPolicy mPolicy;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// default destructor deletes all contained elements
|
|
|
|
SwVectorModifyBase(DestructorPolicy policy = DestructorPolicy::FreeElements)
|
|
|
|
: mPolicy(policy) {}
|
2014-10-01 14:54:59 +09:00
|
|
|
|
2012-06-20 16:36:51 +02:00
|
|
|
public:
|
2014-11-11 16:52:48 +01:00
|
|
|
using std::vector<Value>::begin;
|
|
|
|
using std::vector<Value>::end;
|
|
|
|
|
|
|
|
// free any remaining child objects based on mPolicy
|
|
|
|
virtual ~SwVectorModifyBase()
|
|
|
|
{
|
|
|
|
if (mPolicy == DestructorPolicy::FreeElements)
|
|
|
|
for(const_iterator it = begin(); it != end(); ++it)
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeleteAndDestroy(int aStartIdx, int aEndIdx)
|
|
|
|
{
|
|
|
|
if (aEndIdx < aStartIdx)
|
|
|
|
return;
|
|
|
|
for (const_iterator it = begin() + aStartIdx;
|
|
|
|
it != begin() + aEndIdx; ++it)
|
|
|
|
delete *it;
|
|
|
|
this->erase( begin() + aStartIdx, begin() + aEndIdx);
|
|
|
|
}
|
|
|
|
|
2015-04-06 12:23:09 +03:00
|
|
|
size_t GetPos(Value const& p) const
|
2014-11-11 16:52:48 +01:00
|
|
|
{
|
|
|
|
const_iterator const it = std::find(begin(), end(), p);
|
2015-05-04 13:25:38 +03:00
|
|
|
return it == end() ? SIZE_MAX : it - begin();
|
2014-11-11 16:52:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Contains(Value const& p) const
|
|
|
|
{ return std::find(begin(), end(), p) != end(); }
|
|
|
|
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* /*pWriter*/) const {};
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
template<typename Value>
|
|
|
|
class SwFmtsModifyBase : public SwVectorModifyBase<Value>, public SwFmtsBase
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
SwFmtsModifyBase(typename SwVectorModifyBase<Value>::DestructorPolicy
|
|
|
|
policy = SwVectorModifyBase<Value>::DestructorPolicy::FreeElements)
|
|
|
|
: SwVectorModifyBase<Value>(policy) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual size_t GetFmtCount() const SAL_OVERRIDE
|
|
|
|
{ return std::vector<Value>::size(); }
|
|
|
|
|
|
|
|
virtual Value GetFmt(size_t idx) const SAL_OVERRIDE
|
|
|
|
{ return std::vector<Value>::operator[](idx); }
|
|
|
|
|
2015-04-06 12:23:09 +03:00
|
|
|
inline size_t GetPos(const SwFmt *p) const
|
2014-11-11 16:52:48 +01:00
|
|
|
{ return SwVectorModifyBase<Value>::GetPos( static_cast<Value>( const_cast<SwFmt*>( p ) ) ); }
|
Avoid bad downcast of SwFrmFmt to SwSectionFmt
as observed by -fsanitize=vptr e.g. during CppunitTest_writerperfect_writer:
SwFmtsModifyBase<SwSectionFmt*>::Contains(SwFmt const*) const
SwUndoFmtAttr::Init()
SwUndoFmtAttr::SwUndoFmtAttr(SfxItemSet const&, SwFmt&, bool)
SwDoc::ChgFmt(SwFmt&, SfxItemSet const&)
SwDocStyleSheet::SetItemSet(SfxItemSet const&, bool)
SwXStyle::SetPropertyValues_Impl(com::sun::star::uno::Sequence<rtl::OUString> const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)
SwXStyle::setPropertyValues(com::sun::star::uno::Sequence<rtl::OUString> const&, com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&)
SvXMLImportPropertyMapper::_FillMultiPropertySet(std::__debug::vector<XMLPropertyState, std::allocator<XMLPropertyState> > const&, com::sun::star::uno::Reference<com::sun::star::beans::XMultiPropertySet> const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> const&, rtl::Reference<XMLPropertySetMapper> const&, _ContextID_Index_Pair*)
SvXMLImportPropertyMapper::FillPropertySet(std::__debug::vector<XMLPropertyState, std::allocator<XMLPropertyState> > const&, com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>, _ContextID_Index_Pair*) const
XMLShapeStyleContext::FillPropertySet(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> const&)
XMLPropStyleContext::CreateAndInsert(bool)
XMLTextShapeStyleContext::CreateAndInsert(bool)
SvXMLStylesContext::CopyStylesToDoc(bool, bool)
SwXMLImport::InsertStyles(bool)
SwXMLStylesContext_Impl::EndElement()
SvXMLImport::endElement(rtl::OUString const&)
...
Change-Id: Ibbf6d4def751c5a8ad1416e22b8b5255eda3dd44
2015-03-04 13:52:03 +01:00
|
|
|
inline bool Contains(const SwFmt *p) const {
|
|
|
|
Value p2 = dynamic_cast<Value>(const_cast<SwFmt*>(p));
|
|
|
|
return p2 != nullptr && SwVectorModifyBase<Value>::Contains(p2);
|
|
|
|
}
|
2014-11-11 16:52:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class SwGrfFmtColls : public SwFmtsModifyBase<SwGrfFmtColl*>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SwGrfFmtColls() : SwFmtsModifyBase( DestructorPolicy::KeepElements ) {}
|
|
|
|
};
|
2013-03-14 19:36:04 +01:00
|
|
|
|
2012-09-02 09:05:03 +03:00
|
|
|
/// Specific frame formats (frames, DrawObjects).
|
2014-11-11 16:52:48 +01:00
|
|
|
class SW_DLLPUBLIC SwFrmFmts : public SwFmtsModifyBase<SwFrmFmt*>
|
2012-06-20 16:36:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter, const char* pName) const;
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
class SwCharFmts : public SwFmtsModifyBase<SwCharFmt*>
|
2012-06-20 16:36:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
class SwTxtFmtColls : public SwFmtsModifyBase<SwTxtFmtColl*>
|
2012-06-20 16:36:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-11-11 16:52:48 +01:00
|
|
|
SwTxtFmtColls() : SwFmtsModifyBase( DestructorPolicy::KeepElements ) {}
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
|
|
|
|
2012-09-02 09:05:03 +03:00
|
|
|
/// Array of Undo-history.
|
2014-11-11 16:52:48 +01:00
|
|
|
class SW_DLLPUBLIC SwSectionFmts : public SwFmtsModifyBase<SwSectionFmt*>
|
2012-06-20 16:36:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2012-06-20 16:36:51 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
class SwFldTypes : public SwVectorModifyBase<SwFieldType*> {
|
2012-05-21 17:01:56 +02:00
|
|
|
public:
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2012-05-21 17:01:56 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
class SwTOXTypes : public SwVectorModifyBase<SwTOXType*> {};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-11-11 16:52:48 +01:00
|
|
|
class SW_DLLPUBLIC SwNumRuleTbl : public SwVectorModifyBase<SwNumRule*> {
|
2012-05-16 15:23:09 +02:00
|
|
|
public:
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2012-05-16 15:23:09 +02:00
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-07-20 17:16:03 +02:00
|
|
|
struct CompareSwRedlineTbl
|
|
|
|
{
|
2014-01-13 17:58:25 +02:00
|
|
|
bool operator()(SwRangeRedline* const &lhs, SwRangeRedline* const &rhs) const;
|
2012-07-20 17:16:03 +02:00
|
|
|
};
|
2012-07-31 18:53:04 +02:00
|
|
|
class _SwRedlineTbl
|
2014-01-13 17:58:25 +02:00
|
|
|
: public o3tl::sorted_vector<SwRangeRedline*, CompareSwRedlineTbl,
|
2012-08-02 21:30:45 +02:00
|
|
|
o3tl::find_partialorder_ptrequals>
|
2012-07-31 18:53:04 +02:00
|
|
|
{
|
2012-07-20 17:16:03 +02:00
|
|
|
public:
|
|
|
|
~_SwRedlineTbl();
|
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
class SwRedlineTbl : private _SwRedlineTbl
|
|
|
|
{
|
|
|
|
public:
|
2014-01-13 17:58:25 +02:00
|
|
|
bool Contains(const SwRangeRedline* p) const { return find(const_cast<SwRangeRedline* const>(p)) != end(); }
|
|
|
|
sal_uInt16 GetPos(const SwRangeRedline* p) const;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-01-13 17:58:25 +02:00
|
|
|
bool Insert( SwRangeRedline* p, bool bIns = true );
|
|
|
|
bool Insert( SwRangeRedline* p, sal_uInt16& rInsPos, bool bIns = true );
|
|
|
|
bool InsertWithValidRanges( SwRangeRedline* p, sal_uInt16* pInsPos = 0 );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-07-20 17:16:03 +02:00
|
|
|
void Remove( sal_uInt16 nPos );
|
2014-01-13 17:58:25 +02:00
|
|
|
bool Remove( const SwRangeRedline* p );
|
2012-07-20 17:16:03 +02:00
|
|
|
void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
|
|
|
|
void DeleteAndDestroyAll();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2015-02-27 09:01:06 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2013-11-26 14:10:36 +02:00
|
|
|
|
2015-03-01 08:37:07 +01:00
|
|
|
sal_uInt16 FindNextOfSeqNo( sal_uInt16 nSttPos ) const;
|
|
|
|
sal_uInt16 FindPrevOfSeqNo( sal_uInt16 nSttPos ) const;
|
2012-09-02 09:05:03 +03:00
|
|
|
/** Search next or previous Redline with the same Seq. No.
|
2015-03-02 22:13:35 +01:00
|
|
|
Search can be restricted via Lookahead.
|
2015-03-01 08:47:53 +01:00
|
|
|
Using 0 makes search the whole array. */
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 FindNextSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
|
|
|
|
sal_uInt16 nLookahead = 20 ) const;
|
|
|
|
sal_uInt16 FindPrevSeqNo( sal_uInt16 nSeqNo, sal_uInt16 nSttPos,
|
|
|
|
sal_uInt16 nLookahead = 20 ) const;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-04-28 18:03:49 +02:00
|
|
|
/**
|
|
|
|
Find the redline at the given position.
|
|
|
|
|
|
|
|
@param tableIndex position in SwRedlineTbl to start searching at, will be updated with the index of the returned
|
|
|
|
redline (or the next redline after the given position if not found)
|
|
|
|
@param next true: redline starts at position and ends after, false: redline starts before position and ends at or after
|
|
|
|
*/
|
|
|
|
const SwRangeRedline* FindAtPosition( const SwPosition& startPosition, sal_uInt16& tableIndex, bool next = true ) const;
|
|
|
|
|
2014-07-25 10:21:09 +02:00
|
|
|
using _SwRedlineTbl::const_iterator;
|
|
|
|
using _SwRedlineTbl::begin;
|
|
|
|
using _SwRedlineTbl::end;
|
2012-07-20 17:16:03 +02:00
|
|
|
using _SwRedlineTbl::size;
|
2015-01-25 00:56:38 +01:00
|
|
|
using _SwRedlineTbl::size_type;
|
2007-09-27 06:59:22 +00:00
|
|
|
using _SwRedlineTbl::operator[];
|
2012-07-20 17:16:03 +02:00
|
|
|
using _SwRedlineTbl::empty;
|
2015-01-30 15:34:30 +00:00
|
|
|
using _SwRedlineTbl::Resort;
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2014-01-16 16:51:09 +02:00
|
|
|
/// Table that holds 'extra' redlines, such as 'table row insert\delete', 'paragraph moves' etc...
|
|
|
|
class SwExtraRedlineTbl
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::vector<SwExtraRedline*> m_aExtraRedlines;
|
|
|
|
|
|
|
|
public:
|
2014-03-22 14:03:23 +01:00
|
|
|
~SwExtraRedlineTbl();
|
2014-01-16 16:51:09 +02:00
|
|
|
|
|
|
|
bool Insert( SwExtraRedline* p );
|
|
|
|
|
|
|
|
void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
|
|
|
|
void DeleteAndDestroyAll();
|
|
|
|
|
2015-03-02 07:51:53 +01:00
|
|
|
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
|
2014-01-16 16:51:09 +02:00
|
|
|
|
|
|
|
sal_uInt16 GetSize() const { return m_aExtraRedlines.size(); }
|
|
|
|
SwExtraRedline* GetRedline( sal_uInt16 uIndex ) const { return m_aExtraRedlines.operator[]( uIndex ); }
|
2014-02-11 14:26:30 +01:00
|
|
|
bool IsEmpty() const { return m_aExtraRedlines.empty(); }
|
2014-03-23 13:19:15 +02:00
|
|
|
|
|
|
|
bool DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTable, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
|
|
|
|
bool DeleteTableRowRedline ( SwDoc* pDoc, const SwTableLine& rTableLine, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
|
|
|
|
bool DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox& rTableBox, bool bSaveInUndo, sal_uInt16 nRedlineTypeToDelete );
|
2014-01-16 16:51:09 +02:00
|
|
|
};
|
|
|
|
|
2012-07-13 15:35:23 +02:00
|
|
|
class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> {
|
|
|
|
public:
|
2012-09-02 09:05:03 +03:00
|
|
|
/// the destructor will free all objects still in the set
|
2012-07-13 15:35:23 +02:00
|
|
|
~SwUnoCrsrTbl();
|
|
|
|
};
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2014-10-18 19:26:00 +09:00
|
|
|
typedef std::vector<SwOLENode*> SwOLENodes;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2013-11-05 02:17:53 +01:00
|
|
|
#endif // INCLUDED_SW_INC_DOCARY_HXX
|
2001-01-23 09:42:57 +00:00
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|