LCOV - code coverage report
Current view: top level - sw/inc - ndarr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 16 16 100.0 %
Date: 2015-06-13 12:38:46 Functions: 14 14 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SW_INC_NDARR_HXX
      21             : #define INCLUDED_SW_INC_NDARR_HXX
      22             : 
      23             : #include <vector>
      24             : #include <memory>
      25             : 
      26             : #include <boost/utility.hpp>
      27             : 
      28             : #include <com/sun/star/embed/XEmbeddedObject.hpp>
      29             : 
      30             : #include <svtools/embedhlp.hxx>
      31             : 
      32             : #include <bparr.hxx>
      33             : #include <ndtyp.hxx>
      34             : #include <o3tl/sorted_vector.hxx>
      35             : #include <ring.hxx>
      36             : 
      37             : class Graphic;
      38             : class GraphicObject;
      39             : class SwAttrSet;
      40             : class SfxItemSet;
      41             : class SwContentNode;
      42             : class SwDoc;
      43             : class SwGrfFormatColl;
      44             : class SwGrfNode;
      45             : class SwHistory;
      46             : class SwNode;
      47             : class SwNodeIndex;
      48             : class SwNodeRange;
      49             : class SwOLENode;
      50             : class SwOutlineNodes;
      51             : class SwPaM;
      52             : class SwSectionData;
      53             : class SwSectionFormat;
      54             : class SwTOXBase;
      55             : class SwSectionNode;
      56             : class SwStartNode;
      57             : class SwTableBoxFormat;
      58             : class SwTableFormat;
      59             : class SwTableLine;
      60             : class SwTableLineFormat;
      61             : class SwTableNode;
      62             : class SwTableToTextSaves;
      63             : class SwTextFormatColl;
      64             : class SwTextNode;
      65             : class SwUndoTableToText;
      66             : class SwUndoTextToTable;
      67             : struct SwPosition;
      68             : 
      69             : namespace sw { class DocumentContentOperationsManager; }
      70             : 
      71             : // class SwNodes
      72             : 
      73             : typedef SwNode * SwNodePtr;
      74             : typedef bool (*FnForEach_SwNodes)( const SwNodePtr&, void* pArgs );
      75             : typedef struct _xmlTextWriter *xmlTextWriterPtr;
      76             : 
      77             : struct CompareSwOutlineNodes
      78             : {
      79             :     bool operator()( SwNode* const& lhs, SwNode* const& rhs) const;
      80             : };
      81             : 
      82       11814 : class SwOutlineNodes : public o3tl::sorted_vector<SwNode*, CompareSwOutlineNodes>
      83             : {
      84             : public:
      85             :     bool Seek_Entry(SwNode* rP, sal_uInt16* pnPos) const;
      86             : };
      87             : 
      88             : class SW_DLLPUBLIC SwNodes
      89             :     : private BigPtrArray
      90             :     , private ::boost::noncopyable
      91             : {
      92             :     friend class SwDoc;
      93             :     friend class SwNode;
      94             :     friend class SwNodeIndex;
      95             :     friend class SwStartNode;
      96             :     friend class ::sw::DocumentContentOperationsManager;
      97             : 
      98             :     SwNodeIndex* vIndices; ///< ring of all indices on nodes.
      99             :     void RemoveNode( sal_uLong nDelPos, sal_uLong nLen, bool bDel );
     100             : 
     101             :     void InsertNode( const SwNodePtr pNode,
     102             :                      const SwNodeIndex& rPos );
     103             :     void InsertNode( const SwNodePtr pNode,
     104             :                      sal_uLong nPos );
     105             : 
     106             :     SwDoc* pMyDoc;                      ///< This Doc contains the nodes-array.
     107             : 
     108             :     SwNode *pEndOfPostIts, *pEndOfInserts,  ///< These are the fixed ranges.
     109             :            *pEndOfAutotext, *pEndOfRedlines,
     110             :            *pEndOfContent;
     111             : 
     112             :     mutable SwOutlineNodes* pOutlineNds;        ///< Array of all outline nodes.
     113             : 
     114             :     bool bInNodesDel : 1;           /**< In Case of recursive calling.
     115             :                                            Do not update Num/Outline. */
     116             :     bool bInDelUpdOutl : 1;         ///< Flag for updating of Outline.
     117             :     bool bInDelUpdNum : 1;          ///< Flag for updating of Outline.
     118             : 
     119             :     // Actions on the nodes.
     120             :     static void SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEnd );
     121             :     void DelNodes( const SwNodeIndex& rStart, sal_uLong nCnt = 1 );
     122             : 
     123             :     void ChgNode( SwNodeIndex& rDelPos, sal_uLong nSize,
     124             :                   SwNodeIndex& rInsPos, bool bNewFrms );
     125             : 
     126             :     void UpdateOutlineIdx( const SwNode& );   ///< Update all OutlineNodes starting from Node.
     127             : 
     128             :     void _CopyNodes( const SwNodeRange&, const SwNodeIndex&,
     129             :                     bool bNewFrms = true, bool bTableInsDummyNode = false ) const;
     130             :     void _DelDummyNodes( const SwNodeRange& rRg );
     131             : 
     132             : protected:
     133             :     SwNodes( SwDoc* pDoc );
     134             : 
     135             : public:
     136             :     ~SwNodes();
     137             : 
     138             :     typedef ::std::vector<SwNodeRange> NodeRanges_t;
     139             :     typedef ::std::vector<NodeRanges_t> TableRanges_t;
     140             : 
     141             :     SwNodePtr operator[]( sal_uLong n ) const; // defined in node.hxx
     142             : 
     143     1163747 :     sal_uLong Count() const { return BigPtrArray::Count(); }
     144           9 :     void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = 0 )
     145             :     {
     146           9 :         ForEach( 0, BigPtrArray::Count(), fnForEach, pArgs );
     147           9 :     }
     148             :     void ForEach( sal_uLong nStt, sal_uLong nEnd, FnForEach_SwNodes fnForEach, void* pArgs = 0 );
     149             :     void ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
     150             :                     FnForEach_SwNodes fnForEach, void* pArgs = 0 );
     151             : 
     152             :     /// A still empty section.
     153         133 :     SwNode& GetEndOfPostIts() const     { return *pEndOfPostIts; }
     154             :     /// Section fpr all footnotes.
     155        3970 :     SwNode& GetEndOfInserts() const     { return *pEndOfInserts; }
     156             :     /// Section for all Flys/Header/Footers.
     157       35498 :     SwNode& GetEndOfAutotext() const    { return *pEndOfAutotext; }
     158             :     /// Section for all Redlines.
     159    11479120 :     SwNode& GetEndOfRedlines() const    { return *pEndOfRedlines; }
     160             :     /** This is the last EndNode of a special section. After it
     161             :        there is only the regular ContentSection (i.e. the BodyText). */
     162       86164 :     SwNode& GetEndOfExtras() const      { return *pEndOfRedlines; }
     163             :     /// Regular ContentSection (i.e. the BodyText).
     164      811492 :     SwNode& GetEndOfContent() const     { return *pEndOfContent; }
     165             : 
     166             :     /** Is the NodesArray the regular one of Doc? (and not the UndoNds, ...)
     167             :        Implementation in doc.hxx (because one needs to know Doc for it) ! */
     168             :     bool IsDocNodes() const;
     169             : 
     170             :     static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex);
     171             :     void Delete(const SwNodeIndex &rPos, sal_uLong nNodes = 1);
     172             : 
     173             :     bool _MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&,
     174             :                 bool bNewFrms = true );
     175             :     void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes );
     176             : 
     177        4728 :     void _Copy( const SwNodeRange& rRg, const SwNodeIndex& rInsPos,
     178             :                 bool bNewFrms = true ) const
     179        4728 :         {   _CopyNodes( rRg, rInsPos, bNewFrms ); }
     180             : 
     181             :     void SectionUp( SwNodeRange *);
     182             :     void SectionDown( SwNodeRange *pRange, SwStartNodeType = SwNormalStartNode );
     183             : 
     184             :     bool CheckNodesRange( const SwNodeIndex& rStt, const SwNodeIndex& rEnd ) const;
     185             : 
     186             :     static void GoStartOfSection(SwNodeIndex *);
     187             :     static void GoEndOfSection(SwNodeIndex *);
     188             : 
     189             :     SwContentNode* GoNext(SwNodeIndex *) const;
     190             :     static SwContentNode* GoPrevious(SwNodeIndex *);
     191             : 
     192             :     /** Go to next/previous Content/Table-node for which LayoutFrames exist.
     193             :      While doing this do not leave Header/Footer/Frame etc. */
     194             :     SwNode* GoNextWithFrm(SwNodeIndex *) const;
     195             :     SwNode* GoPreviousWithFrm(SwNodeIndex *) const;
     196             : 
     197             :     /** Go to next content-node that is not protected or hidden
     198             :        (Both set FALSE ==> GoNext/GoPrevious!!!). */
     199             :     SwContentNode* GoNextSection( SwNodeIndex *, bool bSkipHidden  = true,
     200             :                                            bool bSkipProtect = true ) const;
     201             :     static SwContentNode* GoPrevSection( SwNodeIndex *, bool bSkipHidden  = true,
     202             :                                            bool bSkipProtect = true );
     203             : 
     204             :     /** Create an empty section of Start- and EndNote. It may be called
     205             :        only if a new section with content is to be created,
     206             :        e.g. at filters/Undo/... */
     207             :     static SwStartNode* MakeEmptySection( const SwNodeIndex& rIdx,
     208             :                                     SwStartNodeType = SwNormalStartNode );
     209             : 
     210             :     /// Implementations of "Make...Node" are in the given .cxx-files.
     211             :     SwTextNode *MakeTextNode( const SwNodeIndex & rWhere,
     212             :                             SwTextFormatColl *pColl,
     213             :                             SwAttrSet* pAutoAttr = 0 ); ///< in ndtxt.cxx
     214             :     SwStartNode* MakeTextSection( const SwNodeIndex & rWhere,
     215             :                             SwStartNodeType eSttNdTyp,
     216             :                             SwTextFormatColl *pColl,
     217             :                             SwAttrSet* pAutoAttr = 0 );
     218             : 
     219             :     static SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
     220             :                             const OUString& rGrfName,
     221             :                             const OUString& rFltName,
     222             :                             const Graphic* pGraphic,
     223             :                             SwGrfFormatColl *pColl,
     224             :                             SwAttrSet* pAutoAttr = 0,
     225             :                             bool bDelayed = false );    ///< in ndgrf.cxx
     226             : 
     227             :     static SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
     228             :                             const GraphicObject& rGrfObj,
     229             :                             SwGrfFormatColl *pColl,
     230             :                             SwAttrSet* pAutoAttr = 0 ); ///< in ndgrf.cxx
     231             : 
     232             :     SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
     233             :                             const svt::EmbeddedObjectRef&,
     234             :                             SwGrfFormatColl *pColl,
     235             :                             SwAttrSet* pAutoAttr = 0 ); ///< in ndole.cxx
     236             :     SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
     237             :                             const OUString &rName,
     238             :                             sal_Int64 nAspect,
     239             :                             SwGrfFormatColl *pColl,
     240             :                             SwAttrSet* pAutoAttr ); ///< in ndole.cxx
     241             : 
     242             :     /// Array of all OutlineNodes.
     243         568 :     const SwOutlineNodes& GetOutLineNds() const { return *pOutlineNds;}
     244             : 
     245             :     /// Update all Nodes - Rule/Format-Change.
     246             :     void UpdateOutlineNode(SwNode & rNd);
     247             : 
     248             :     /** Insert nodes for tables. If Lines is given, create the matrix
     249             :        from lines and boxes, else only the count of boxes.
     250             : 
     251             :        New parameter pAttrSet: If pAttrSet is non-null and contains an
     252             :        adjust item it is propagated to the table cells. If there is an
     253             :        adjust in pContentTextColl or pHeadlineTextColl this adjust item
     254             :        overrides the item in pAttrSet. */
     255             : 
     256             :     static SwTableNode* InsertTable( const SwNodeIndex& rNdIdx,
     257             :                         sal_uInt16 nBoxes, SwTextFormatColl* pContentTextColl,
     258             :                         sal_uInt16 nLines = 0, sal_uInt16 nRepeat = 0,
     259             :                         SwTextFormatColl* pHeadlineTextColl = 0,
     260             :                         const SwAttrSet * pAttrSet = 0);
     261             : 
     262             :     /// Create balanced table from selected range.
     263             :     SwTableNode* TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
     264             :                                 SwTableFormat* pTableFormat,
     265             :                                 SwTableLineFormat* pLineFormat,
     266             :                                 SwTableBoxFormat* pBoxFormat,
     267             :                                 SwTextFormatColl* pTextColl,
     268             :                                 SwUndoTextToTable* pUndo = 0 );
     269             : 
     270             :     static SwNodeRange * ExpandRangeForTableBox(const SwNodeRange & rRange);
     271             : 
     272             :     /// create a table from a vector of NodeRanges - API support
     273             :     SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
     274             :                                 SwTableFormat* pTableFormat,
     275             :                                 SwTableLineFormat* pLineFormat,
     276             :                                 SwTableBoxFormat* pBoxFormat,
     277             :                                 SwTextFormatColl* pTextColl
     278             :                                 /*, SwUndo... pUndo*/ );
     279             : 
     280             :     /// Create regular text from what was table.
     281             :     bool TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
     282             :                         SwUndoTableToText* = 0 );
     283             :     /// Is in untbl.cxx and may called only by Undo-object.
     284             :     SwTableNode* UndoTableToText( sal_uLong nStt, sal_uLong nEnd,
     285             :                         const SwTableToTextSaves& rSavedData );
     286             : 
     287             :     /** Insert a new box in the line before InsPos. Its format
     288             :        is taken from the following one (or from the previous one if we are
     289             :        at the end). In the line there must be a box already. */
     290             :     bool InsBoxen( SwTableNode*, SwTableLine*, SwTableBoxFormat*,
     291             :                         /// Formats for TextNode of box.
     292             :                         SwTextFormatColl*, const SfxItemSet* pAutoAttr,
     293             :                         sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
     294             :     /** Splits a table at the base-line which contains the index.
     295             :        All base lines behind it are moved to a new table/ -node.
     296             :        Is the flag bCalcNewSize set to TRUE, the new SSize for both
     297             :        tables is calculated from the Maximum of the boxes, provided
     298             :        SSize is set "absolute" (LONG_MAX).
     299             :        (Momentarily this is needed only for the RTF-parser.) */
     300             :     SwTableNode* SplitTable( const SwNodeIndex& rPos, bool bAfter = true,
     301             :                                 bool bCalcNewSize = false );
     302             :     /// Two Tables that are following one another are merged.
     303             :     bool MergeTable( const SwNodeIndex& rPos, bool bWithPrev = true,
     304             :                     sal_uInt16 nMode = 0, SwHistory* pHistory = 0 );
     305             : 
     306             :     /// Insert a new SwSection.
     307             :     SwSectionNode* InsertTextSection(SwNodeIndex const& rNdIdx,
     308             :                                 SwSectionFormat& rSectionFormat,
     309             :                                 SwSectionData const&,
     310             :                                 SwTOXBase const*const pTOXBase,
     311             :                                 SwNodeIndex const*const pEnde,
     312             :                                 bool const bInsAtStart = true,
     313             :                                 bool const bCreateFrms = true);
     314             : 
     315             :     /// Which Doc contains the nodes-array?
     316    52062478 :             SwDoc* GetDoc()         { return pMyDoc; }
     317   123902549 :     const   SwDoc* GetDoc() const   { return pMyDoc; }
     318             : 
     319             :     /** Search previous / next content node or table node with frames.
     320             :      If no end is given begin with the FrameIndex, else start search
     321             :      with that before rFrmIdx and pEnd at the back.
     322             :      If no valid node is found, return 0. rFrmIdx points to the node with frames. **/
     323             :     SwNode* FindPrvNxtFrmNode( SwNodeIndex& rFrmIdx,
     324             :                                 const SwNode* pEnd = 0 ) const;
     325             : 
     326             :     SwNode * DocumentSectionStartNode(SwNode * pNode) const;
     327             :     SwNode * DocumentSectionEndNode(SwNode * pNode) const;
     328             : 
     329             :     /**
     330             :      * Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by default)
     331             :      * @since 3.5
     332             :      */
     333             :     void dumpAsXml( xmlTextWriterPtr pWriter ) const;
     334             : };
     335             : 
     336             : 
     337             : #endif
     338             : 
     339             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11