diff options
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/doc.hxx | 5 | ||||
-rw-r--r-- | sw/inc/frmfmt.hxx | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c7d7af8de5ef..fc258ef8ac21 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -128,6 +128,7 @@ class SwFmt; class SwFmtINetFmt; class SwFmtRefMark; class SwFrmFmt; +class SwFrmFmtAnchorMap; class SwFrmFmts; class SwFtnIdxs; class SwFtnInfo; @@ -297,6 +298,7 @@ class SW_DLLPUBLIC SwDoc : SwGrfFmtColl *mpDfltGrfFmtColl; SwFrmFmts *mpFrmFmtTbl; ///< Format table + SwFrmFmtAnchorMap *mpFrmFmtAnchorMap; SwCharFmts *mpCharFmtTbl; SwFrmFmts *mpSpzFrmFmtTbl; SwSectionFmts *mpSectionFmtTbl; @@ -1214,6 +1216,9 @@ public: const SwCharFmt *GetDfltCharFmt() const { return mpDfltCharFmt;} SwCharFmt *GetDfltCharFmt() { return mpDfltCharFmt;} + const SwFrmFmtAnchorMap* GetFrmFmtAnchorMap() const { return mpFrmFmtAnchorMap; } + SwFrmFmtAnchorMap* GetFrmFmtAnchorMap() { return mpFrmFmtAnchorMap; } + /// @return the interface of the management of (auto)styles IStyleAccess& GetIStyleAccess() { return *mpStyleAccess; } diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 742abca3397f..0c22837bb5b3 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -23,6 +23,8 @@ #include <cppuhelper/weakref.hxx> #include <tools/gen.hxx> #include <format.hxx> +#include <map> +#include <ndindex.hxx> #include "swdllapi.h" class SwFlyFrm; @@ -67,6 +69,7 @@ protected: public: TYPEINFO(); ///< Already in base class Client. + virtual ~SwFrmFmt(); /// Destroys all Frms in aDepend (Frms are identified via PTR_CAST). virtual void DelFrms(); @@ -298,6 +301,30 @@ public: }; +/** + Fast mapping from node positions to SwFrmFmt objects anchored at them. + + SwFrmFmt::GetAnchor().GetCntntAnchor() provides the position where the object is anchored. + This class provides the reverse mapping. It intentionally uses SwNodeIndex instead of SwPosition + to allow simpler implementation, do SwIndex checking explicitly if needed. +*/ +class SwFrmFmtAnchorMap +{ +public: + SwFrmFmtAnchorMap( const SwDoc* doc ); + void Add( SwFrmFmt* fmt, const SwNodeIndex& index ); + void Remove( SwFrmFmt* fmt, const SwNodeIndex& index ); + typedef std::multimap< SwNodeIndex, SwFrmFmt* >::const_iterator const_iterator; + typedef std::pair< const_iterator, const_iterator > const_iterator_pair; + const_iterator_pair equal_range( const SwNodeIndex& pos ) const; + const_iterator lower_bound( const SwNodeIndex& pos ) const; + const_iterator upper_bound( const SwNodeIndex& pos ) const; + const_iterator end() const; +private: + std::multimap< SwNodeIndex, SwFrmFmt* > items; + const SwDoc* doc; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |