LCOV - code coverage report
Current view: top level - sw/source/filter/ww1 - fltshell.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 241 1019 23.7 %
Date: 2014-04-11 Functions: 32 146 21.9 %
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             : #include <ctype.h>
      21             : #include <hintids.hxx>
      22             : #include <hints.hxx>
      23             : #include <vcl/graphicfilter.hxx>
      24             : 
      25             : #include <vcl/graph.hxx>
      26             : #include <svl/urihelper.hxx>
      27             : #include <editeng/boxitem.hxx>
      28             : #include <editeng/wghtitem.hxx>
      29             : #include <editeng/cmapitem.hxx>
      30             : #include <editeng/contouritem.hxx>
      31             : #include <editeng/postitem.hxx>
      32             : #include <editeng/crossedoutitem.hxx>
      33             : #include <svl/stritem.hxx>
      34             : #include <unotools/charclass.hxx>
      35             : #include <txtftn.hxx>
      36             : #include <fmtpdsc.hxx>
      37             : #include <fmtftn.hxx>
      38             : #include <fmtanchr.hxx>
      39             : #include <fmtrfmrk.hxx>
      40             : #include <fmtclds.hxx>
      41             : #include <fmtfld.hxx>
      42             : #include <fmtfsize.hxx>
      43             : #include <fmthdft.hxx>
      44             : #include <fmtcntnt.hxx>
      45             : #include <redline.hxx>
      46             : #include <pam.hxx>
      47             : #include <doc.hxx>
      48             : #include <ndtxt.hxx>
      49             : #include <frmatr.hxx>
      50             : #include <fldbas.hxx>
      51             : #include <charatr.hxx>
      52             : #include <swtable.hxx>
      53             : #include <tox.hxx>
      54             : #include <expfld.hxx>
      55             : #include <section.hxx>
      56             : #include <tblsel.hxx>
      57             : #include <pagedesc.hxx>
      58             : #include <docsh.hxx>
      59             : #include <fltshell.hxx>
      60             : #include <viewsh.hxx>
      61             : #include <shellres.hxx>
      62             : 
      63             : using namespace com::sun::star;
      64             : 
      65       21043 : static SwCntntNode* GetCntntNode(SwDoc* pDoc, SwNodeIndex& rIdx, bool bNext)
      66             : {
      67       21043 :     SwCntntNode * pCNd = rIdx.GetNode().GetCntntNode();
      68       21059 :     if(!pCNd && 0 == (pCNd = bNext ? pDoc->GetNodes().GoNext(&rIdx)
      69          16 :                                      : pDoc->GetNodes().GoPrevious(&rIdx)))
      70             :     {
      71           0 :         pCNd = bNext ? pDoc->GetNodes().GoPrevious(&rIdx)
      72           0 :                      : pDoc->GetNodes().GoNext(&rIdx);
      73             :         OSL_ENSURE(pCNd, "no ContentNode found");
      74             :     }
      75       21043 :     return pCNd;
      76             : }
      77             : 
      78             : // Stack entry for all text attributes
      79       23893 : SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
      80             :     : m_aMkPos(rStartPos)
      81             :     , m_aPtPos(rStartPos)
      82             :     , mnStartCP(-1)
      83             :     , mnEndCP(-1)
      84       23893 :     , bIsParaEnd(false)
      85             : {
      86       23893 :     pAttr = pHt;            // store a copy of the attribute
      87       23893 :     bOld    = sal_False;    // used for marking Attributes *before* skipping field results
      88       23893 :     bOpen = sal_True;       // lock the attribute --> may first
      89       23893 :     bConsumedByField = sal_False;
      90       23893 : }
      91             : 
      92       47786 : SwFltStackEntry::~SwFltStackEntry()
      93             : {
      94             :     // Although attribute got passed as pointer, it gets deleted here
      95       23893 :     delete pAttr;
      96       23893 : }
      97             : 
      98       23958 : void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
      99             : {
     100             :     // Release attribute and keep track of end
     101             :     // Everything with sal_uInt16s, lest the inserting of new text at
     102             :     // the cursor position moves the attribute's range
     103             :     // That's not the desired behavior!
     104       23958 :     bOpen = sal_False;                  // release and remember END
     105       23958 :     m_aPtPos.SetPos(rEndPos);
     106       23958 : }
     107             : 
     108       22750 : bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck,
     109             :     const SwFltPosition &rMkPos, const SwFltPosition &rPtPos, bool bIsParaEnd,
     110             :     sal_uInt16 nWhich)
     111             : {
     112             :     // does this range actually contain something?
     113             :     // empty range is allowed if at start of empty paragraph
     114             :     // fields are special: never have range, so leave them
     115             : 
     116             :     // The only position of 0x0D will not be able to make region in the old logic
     117             :     // because it is beyond the length of para...need special consideration here.
     118             :     SwCntntNode *const pCntntNode(
     119       22750 :         SwNodeIndex(rMkPos.m_nNode, +1).GetNode().GetCntntNode());
     120       53457 :     if (rMkPos == rPtPos &&
     121       14027 :         ((0 != rPtPos.m_nCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
     122        4279 :         && ( RES_TXTATR_FIELD != nWhich
     123        4279 :              && RES_TXTATR_ANNOTATION != nWhich
     124        4279 :              && RES_TXTATR_INPUTFIELD != nWhich )
     125       27029 :         && !(bIsParaEnd && pCntntNode && pCntntNode->IsTxtNode() && 0 != pCntntNode->Len() ))
     126             :     {
     127        3992 :         return false;
     128             :     }
     129             :     // The content indices always apply to the node!
     130       18758 :     rRegion.GetPoint()->nNode = rMkPos.m_nNode.GetIndex() + 1;
     131       18758 :     SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, true);
     132       18758 :     rRegion.GetPoint()->nContent.Assign(pCNd, rMkPos.m_nCntnt);
     133       18758 :     rRegion.SetMark();
     134       18758 :     if (rMkPos.m_nNode != rPtPos.m_nNode)
     135             :     {
     136        2191 :         rRegion.GetPoint()->nNode = rPtPos.m_nNode.GetIndex() + 1;
     137        2191 :         pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, false);
     138             :     }
     139       18758 :     rRegion.GetPoint()->nContent.Assign(pCNd, rPtPos.m_nCntnt);
     140             :     OSL_ENSURE( CheckNodesRange( rRegion.Start()->nNode,
     141             :                              rRegion.End()->nNode, true ),
     142             :              "atttribute or similar crosses section-boundaries" );
     143       18758 :     if( bCheck )
     144          10 :         return CheckNodesRange( rRegion.Start()->nNode,
     145          20 :                                 rRegion.End()->nNode, true );
     146             :     else
     147       18748 :         return true;
     148             : }
     149             : 
     150       22742 : bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
     151             : {
     152             :     return MakeRegion(pDoc, rRegion, bCheck, m_aMkPos, m_aPtPos, bIsParaEnd,
     153       22742 :         pAttr->Which());
     154             : }
     155             : 
     156         734 : SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
     157         734 :     : nFieldFlags(nFieldFl),bHasSdOD(true), bSdODChecked(false), pDoc(pDo), bIsEndStack(false)
     158             : {
     159         734 : }
     160             : 
     161         734 : SwFltControlStack::~SwFltControlStack()
     162             : {
     163             :     OSL_ENSURE(maEntries.empty(), "There are still Attributes on the stack");
     164         734 : }
     165             : 
     166             : // MoveAttrs() is meant to address the following problem:
     167             : // When a field like "set variable" is set through the stack, the text
     168             : // is shifted by one \xff character, which makes all subsequent
     169             : // attribute positions invalid.
     170             : // After setting the attribute in the doc, MoveAttrs() needs to be
     171             : // called in order to push all attribute positions to the right in the
     172             : // same paragraph further out by one character.
     173           0 : void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
     174             : {
     175           0 :     size_t nCnt = maEntries.size();
     176           0 :     sal_uLong nPosNd = rPos.nNode.GetIndex();
     177           0 :     sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
     178             : 
     179           0 :     for (size_t i=0; i < nCnt; ++i)
     180             :     {
     181           0 :         SwFltStackEntry& rEntry = maEntries[i];
     182           0 :         if (
     183           0 :             (rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
     184           0 :             (rEntry.m_aMkPos.m_nCntnt >= nPosCt)
     185             :            )
     186             :         {
     187           0 :             rEntry.m_aMkPos.m_nCntnt++;
     188             :             OSL_ENSURE( rEntry.m_aMkPos.m_nCntnt
     189             :                 <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
     190             :                     "Attribute ends after end of line" );
     191             :         }
     192           0 :         if (
     193           0 :             (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
     194           0 :             (rEntry.m_aPtPos.m_nCntnt >= nPosCt)
     195             :            )
     196             :         {
     197           0 :             rEntry.m_aPtPos.m_nCntnt++;
     198             :             OSL_ENSURE( rEntry.m_aPtPos.m_nCntnt
     199             :                 <= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
     200             :                     "Attribute ends after end of line" );
     201             :         }
     202             :     }
     203           0 : }
     204             : 
     205          22 : void SwFltControlStack::MarkAllAttrsOld()
     206             : {
     207          22 :     size_t nCnt = maEntries.size();
     208         152 :     for (sal_uInt16 i=0; i < nCnt; ++i)
     209         130 :         maEntries[i].bOld = sal_True;
     210          22 : }
     211             : 
     212             : namespace
     213             : {
     214       24415 :     bool couldExtendEntry(const SwFltStackEntry *pExtendCandidate,
     215             :         const SfxPoolItem& rAttr)
     216             :     {
     217        2598 :         return (pExtendCandidate &&
     218        5196 :                 !pExtendCandidate->bConsumedByField &&
     219             :                 //potentially more, but lets keep it simple
     220       30914 :                 (isPARATR_LIST(rAttr.Which()) || (isCHRATR(rAttr.Which()) && rAttr.Which() != RES_CHRATR_FONT && rAttr.Which() != RES_CHRATR_FONTSIZE)) &&
     221       25718 :                 *(pExtendCandidate->pAttr) == rAttr);
     222             :     }
     223             : }
     224             : 
     225       24415 : void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr)
     226             : {
     227       24415 :     sal_uInt16 nWhich = rAttr.Which();
     228             :     // Set end position of potentially equal attributes on stack, so
     229             :     // as to avoid having them accumulate
     230       24415 :     SwFltStackEntry *pExtendCandidate = SetAttr(rPos, nWhich);
     231       24415 :     if (couldExtendEntry(pExtendCandidate, rAttr))
     232             :     {
     233             :         //Here we optimize by seeing if there is an attribute uncommited
     234             :         //to the document which
     235             : 
     236             :         //a) has the same value as this attribute
     237             :         //b) is already open, or ends at the same place as where we're starting
     238             :         //from. If so we merge it with this one and elide adding another
     239             :         //to the stack
     240         522 :         pExtendCandidate->SetEndPos(rPos);
     241         522 :         pExtendCandidate->bOpen=true;
     242             :     }
     243             :     else
     244             :     {
     245       23893 :         SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
     246       23893 :         pTmp->SetStartCP(GetCurrAttrCP());
     247       23893 :         maEntries.push_back(pTmp);
     248             :     }
     249       24415 : }
     250             : 
     251        1151 : void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
     252             : {
     253             :     OSL_ENSURE(nCnt < maEntries.size(), "Out of range!");
     254        1151 :     if (nCnt < maEntries.size())
     255             :     {
     256        1151 :         myEIter aElement = maEntries.begin() + nCnt;
     257        1151 :         maEntries.erase(aElement);
     258             :     }
     259             :     //Clear the para end position recorded in reader intermittently for the least impact on loading performance
     260             :     //Because the attributes handled based on the unit of para
     261        1151 :     if ( empty() )
     262             :     {
     263         195 :         ClearParaEndPosition();
     264         195 :         bHasSdOD = true;
     265         195 :         bSdODChecked = false;
     266             :     }
     267        1151 : }
     268             : 
     269             : // SwFltControlStack::StealAttr() removes attributes of the given type
     270             : // from the stack. Allowed as nAttrId: 0 meaning any, or a specific
     271             : // type.  This makes them disappear from the doc structure. Only
     272             : // attributes from the same paragraph as rPos are removed. Used for
     273             : // graphic apos -> images.
     274           0 : void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId)
     275             : {
     276           0 :     size_t nCnt = maEntries.size();
     277             : 
     278           0 :     while (nCnt)
     279             :     {
     280           0 :         nCnt --;
     281           0 :         SwFltStackEntry& rEntry = maEntries[nCnt];
     282           0 :         if (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
     283           0 :             (!nAttrId || nAttrId == rEntry.pAttr->Which()))
     284             :         {
     285           0 :             DeleteAndDestroy(nCnt);     // loesche aus dem Stack
     286             :         }
     287             :     }
     288           0 : }
     289             : 
     290             : // SwFltControlStack::KillUnlockedAttr() removes all attributes from
     291             : // the stack, which are assigned to an rPos. This makes them disappear
     292             : // from the doc structure. Used in WW import for ignoring attributes
     293             : // assigned to the 0x0c section break symbol.
     294          80 : void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
     295             : {
     296          80 :     SwFltPosition aFltPos(rPos);
     297             : 
     298          80 :     size_t nCnt = maEntries.size();
     299         570 :     while( nCnt )
     300             :     {
     301         410 :         nCnt --;
     302         410 :         SwFltStackEntry& rEntry = maEntries[nCnt];
     303         820 :         if(    !rEntry.bOld
     304         280 :             && !rEntry.bOpen
     305         158 :             && (rEntry.m_aMkPos == aFltPos)
     306         552 :             && (rEntry.m_aPtPos == aFltPos))
     307             :         {
     308         142 :             DeleteAndDestroy( nCnt ); // remove from stack
     309             :         }
     310          80 :     }
     311          80 : }
     312             : 
     313             : // Unlock all locked attributes and move to the end, all others will
     314             : // be applied to the document and removed from the stack.
     315             : // Returns if there were any selected attributes on the stack
     316       47956 : SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
     317             :     sal_uInt16 nAttrId, sal_Bool bTstEnde, long nHand,
     318             :     sal_Bool consumedByField)
     319             : {
     320       47956 :     SwFltStackEntry *pRet = NULL;
     321             : 
     322       47956 :     SwFltPosition aFltPos(rPos);
     323             : 
     324             :     OSL_ENSURE(!nAttrId ||
     325             :         (POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId) ||
     326             :         (RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
     327             :         "Wrong id for attribute");
     328             : 
     329       47956 :     myEIter aI = maEntries.begin();
     330     1190145 :     while (aI != maEntries.end())
     331             :     {
     332     1094233 :         bool bLastEntry = aI == maEntries.end() - 1;
     333             : 
     334     1094233 :         SwFltStackEntry& rEntry = *aI;
     335     1094233 :         if (rEntry.bOpen)
     336             :         {
     337             :             // set end of attribute
     338      199900 :             bool bF = false;
     339      199900 :             if (!nAttrId )
     340             :             {
     341           7 :                 bF = true;
     342             :             }
     343      199893 :             else if (nAttrId == rEntry.pAttr->Which())
     344             :             {
     345       23431 :                 if( nAttrId != RES_FLTR_BOOKMARK )
     346             :                 {
     347             :                     // query handle
     348       23412 :                     bF = true;
     349             :                 }
     350          19 :                 else if (nHand == ((SwFltBookmark*)(rEntry.pAttr))->GetHandle())
     351             :                 {
     352          17 :                     bF = true;
     353             :                 }
     354             :             }
     355      199900 :             if (bF)
     356             :             {
     357       23436 :                 rEntry.bConsumedByField = consumedByField;
     358       23436 :                 rEntry.SetEndPos(rPos);
     359       23436 :                 rEntry.SetEndCP(GetCurrAttrCP());
     360       23436 :                 if (bLastEntry && nAttrId == rEntry.pAttr->Which())
     361             :                 {
     362             :                     //potential candidate for merging with an identical
     363             :                     //property beginning at rPos
     364        6868 :                     pRet = &rEntry;
     365             :                 }
     366             :             }
     367      199900 :             ++aI;
     368      199900 :             continue;
     369             :         }
     370             : 
     371             :         // if the end position is equal to the cursor position, then
     372             :         // refrain from applying it; there needs to be following text,
     373             :         // except at the very end. (attribute expansion !!)
     374             :         // Never apply end stack except at document ending
     375      894333 :         if (bTstEnde)
     376             :         {
     377      893114 :             if (bIsEndStack)
     378             :             {
     379          53 :                 ++aI;
     380          53 :                 continue;
     381             :             }
     382             : 
     383             :             //defer inserting this attribute into the document until
     384             :             //we advance to the next node, or finish processing the document
     385      893061 :             if (rEntry.m_aPtPos.m_nNode.GetIndex() == aFltPos.m_nNode.GetIndex())
     386             :             {
     387      874151 :                 if (bLastEntry && nAttrId == rEntry.pAttr->Which() &&
     388        2613 :                     rEntry.m_aPtPos.m_nCntnt == aFltPos.m_nCntnt)
     389             :                 {
     390             :                     //potential candidate for merging with an identical
     391             :                     //property beginning at rPos
     392        2588 :                     pRet = &rEntry;
     393             :                 }
     394             : 
     395      871538 :                 ++aI;
     396      871538 :                 continue;
     397             :             }
     398             :         }
     399       22742 :         SetAttrInDoc(rPos, rEntry);
     400       22742 :         aI = maEntries.erase(aI);
     401             :     }
     402             : 
     403       47956 :     return pRet;
     404             : }
     405             : 
     406          94 : static void MakePoint(const SwFltStackEntry& rEntry, SwDoc* pDoc,
     407             :     SwPaM& rRegion)
     408             : {
     409             :     // the anchor is the Pam's Point. It's modified when inserting
     410             :     // text, etc.; therefore it is kept on the stack. Only the
     411             :     // attribute's format needs to be set.
     412          94 :     rRegion.DeleteMark();
     413          94 :     rRegion.GetPoint()->nNode = rEntry.m_aMkPos.m_nNode.GetIndex() + 1;
     414          94 :     SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, true);
     415          94 :     rRegion.GetPoint()->nContent.Assign(pCNd, rEntry.m_aMkPos.m_nCntnt);
     416          94 : }
     417             : 
     418             : // MakeBookRegionOrPoint() behaves like MakeRegionOrPoint, except that
     419             : // it adheres to certain restrictions on bookmarks in tables (cannot
     420             : // span more than one cell)
     421          17 : static void MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc* pDoc,
     422             :                     SwPaM& rRegion, sal_Bool bCheck )
     423             : {
     424          17 :     if (rEntry.MakeRegion(pDoc, rRegion, bCheck )){
     425             :         // sal_Bool b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0;
     426          20 :         if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode()
     427          10 :               != rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode())
     428             :         {
     429           0 :             rRegion.Exchange();         // invalid range
     430           0 :             rRegion.DeleteMark();       // -> both to mark
     431             :         }
     432             :     }else{
     433           7 :         MakePoint(rEntry, pDoc, rRegion);
     434             :     }
     435          17 : }
     436             : 
     437             : // IterateNumrulePiece() looks for the first range valid for Numrules
     438             : // between rTmpStart and rEnd.
     439             : 
     440             : // rNds denotes the doc nodes
     441             : // rEnd denotes the range end,
     442             : // rTmpStart is an in/out parameter: in: start of range to be searched,
     443             : //                                   out: start of valid range
     444             : // rTmpEnd is an out parameter
     445             : // Returns true for valid range
     446           0 : static bool IterateNumrulePiece( const SwNodeIndex& rEnd,
     447             :                                 SwNodeIndex& rTmpStart, SwNodeIndex& rTmpEnd )
     448             : {
     449           0 :     while( ( rTmpStart <= rEnd )
     450           0 :            && !( rTmpStart.GetNode().IsTxtNode() ) )    // look for valid start
     451           0 :         ++rTmpStart;
     452             : 
     453           0 :     rTmpEnd = rTmpStart;
     454           0 :     while( ( rTmpEnd <= rEnd )
     455           0 :            && ( rTmpEnd.GetNode().IsTxtNode() ) )       // look for valid end + 1
     456           0 :         ++rTmpEnd;
     457             : 
     458           0 :     rTmpEnd--;                                      // valid end
     459             : 
     460           0 :     return rTmpStart <= rTmpEnd;                    // valid ?
     461             : }
     462             : 
     463             : //***This function will check whether there is existing individual attribute positon for 0x0D***/
     464             : //The check will happen only once for a paragraph during loading
     465         129 : bool SwFltControlStack::HasSdOD()
     466             : {
     467         129 :     bool bRet = false;
     468             : 
     469         959 :     for (Entries::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
     470             :     {
     471         852 :         SwFltStackEntry& rEntry = *it;
     472         852 :         if ( rEntry.mnStartCP == rEntry.mnEndCP )
     473             :         {
     474         176 :             if ( CheckSdOD(rEntry.mnStartCP,rEntry.mnEndCP) )
     475             :             {
     476          22 :                 bRet = true;
     477          22 :                 break;
     478             :             }
     479             :         }
     480             :     }
     481             : 
     482         129 :     return bRet;
     483             : }
     484             : 
     485       21196 : void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
     486             :     SwFltStackEntry& rEntry)
     487             : {
     488       21196 :     SwPaM aRegion( rTmpPos );
     489             : 
     490       21196 :     switch(rEntry.pAttr->Which())
     491             :     {
     492             :     case RES_FLTR_ANCHOR:
     493             :         {
     494          87 :             SwFrmFmt* pFmt = ((SwFltAnchor*)rEntry.pAttr)->GetFrmFmt();
     495          87 :             if (pFmt != NULL)
     496             :             {
     497          87 :                 MakePoint(rEntry, pDoc, aRegion);
     498          87 :                 SwFmtAnchor aAnchor(pFmt->GetAnchor());
     499          87 :                 aAnchor.SetAnchor(aRegion.GetPoint());
     500          87 :                 pFmt->SetFmtAttr(aAnchor);
     501             :                 // So the frames will be created when inserting into
     502             :                 // existing doc (after setting the anchor!):
     503         174 :                 if(pDoc->GetCurrentViewShell()
     504          87 :                    && (FLY_AT_PARA == pFmt->GetAnchor().GetAnchorId()))
     505             :                 {
     506           0 :                     pFmt->MakeFrms();
     507          87 :                 }
     508             :             }
     509             :         }
     510          87 :         break;
     511             :     case RES_FLTR_STYLESHEET:
     512           0 :         break;
     513             : 
     514             :     case RES_TXTATR_FIELD:
     515             :     case RES_TXTATR_ANNOTATION:
     516             :     case RES_TXTATR_INPUTFIELD:
     517           0 :         break;
     518             : 
     519             :     case RES_TXTATR_TOXMARK:
     520           0 :         break;
     521             : 
     522             :     case RES_FLTR_NUMRULE:          // insert Numrule
     523             :         {
     524           0 :             const OUString& rNumNm = ((SfxStringItem*)rEntry.pAttr)->GetValue();
     525           0 :             SwNumRule* pNumRule = pDoc->FindNumRulePtr( rNumNm );
     526           0 :             if( pNumRule )
     527             :             {
     528           0 :                 if( rEntry.MakeRegion(pDoc, aRegion, true))
     529             :                 {
     530           0 :                     SwNodeIndex aTmpStart( aRegion.Start()->nNode );
     531           0 :                     SwNodeIndex aTmpEnd( aTmpStart );
     532           0 :                     SwNodeIndex& rRegEndNd = aRegion.End()->nNode;
     533           0 :                     while( IterateNumrulePiece( rRegEndNd,
     534             :                                                 aTmpStart, aTmpEnd ) )
     535             :                     {
     536           0 :                         SwPaM aTmpPam( aTmpStart, aTmpEnd );
     537             :                         // no start of a new list
     538           0 :                         pDoc->SetNumRule( aTmpPam, *pNumRule, false );
     539             : 
     540           0 :                         aTmpStart = aTmpEnd;    // here starts the next range
     541           0 :                         ++aTmpStart;
     542           0 :                     }
     543             :                 }
     544             :                 else
     545           0 :                     pDoc->DelNumRule( rNumNm );
     546             :             }
     547             :         }
     548           0 :         break;
     549             : 
     550             :     case RES_FLTR_NUMRULE_NUM:
     551           0 :         break;
     552             :     case RES_FLTR_BOOKMARK:
     553             :         {
     554          17 :             SwFltBookmark* pB = (SwFltBookmark*)rEntry.pAttr;
     555          17 :             const OUString& rName = ((SwFltBookmark*)rEntry.pAttr)->GetName();
     556             : 
     557          17 :             if (IsFlagSet(BOOK_TO_VAR_REF))
     558             :             {
     559           0 :                 SwFieldType* pFT = pDoc->GetFldType(RES_SETEXPFLD, rName, false);
     560           0 :                 if (!pFT)
     561             :                 {
     562           0 :                     SwSetExpFieldType aS(pDoc, rName, nsSwGetSetExpType::GSE_STRING);
     563           0 :                     pFT = pDoc->InsertFldType(aS);
     564             :                 }
     565           0 :                 SwSetExpField aFld((SwSetExpFieldType*)pFT, pB->GetValSys());
     566           0 :                 aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
     567           0 :                 MakePoint(rEntry, pDoc, aRegion);
     568           0 :                 pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0);
     569           0 :                 MoveAttrs( *(aRegion.GetPoint()) );
     570             :             }
     571          34 :             if ( ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) &&
     572          17 :                  !rEntry.bConsumedByField )
     573             :             {
     574          17 :                 MakeBookRegionOrPoint(rEntry, pDoc, aRegion, sal_True);
     575             :                 // #i120879# - create a cross reference heading bookmark if appropriate.
     576             :                 const IDocumentMarkAccess::MarkType eBookmarkType =
     577          17 :                     ( pB->IsTOCBookmark() &&
     578           0 :                       IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( aRegion ) )
     579             :                     ? IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK
     580          17 :                     : IDocumentMarkAccess::BOOKMARK;
     581          17 :                 pDoc->getIDocumentMarkAccess()->makeMark( aRegion, rName, eBookmarkType );
     582             :             }
     583             :         }
     584          17 :         break;
     585             :     case RES_FLTR_TOX:
     586             :         {
     587           0 :             MakePoint(rEntry, pDoc, aRegion);
     588             : 
     589           0 :             SwPosition* pPoint = aRegion.GetPoint();
     590             : 
     591           0 :             SwFltTOX* pTOXAttr = (SwFltTOX*)rEntry.pAttr;
     592             : 
     593             :             // test if on this node there had been a pagebreak BEFORE the
     594             :             //     tox attribute was put on the stack
     595           0 :             SfxItemSet aBkSet( pDoc->GetAttrPool(), RES_PAGEDESC, RES_BREAK );
     596           0 :             SwCntntNode* pNd = 0;
     597           0 :             if( !pTOXAttr->HadBreakItem() || !pTOXAttr->HadPageDescItem() )
     598             :             {
     599           0 :                 pNd = pPoint->nNode.GetNode().GetCntntNode();
     600           0 :                 if( pNd )
     601             :                 {
     602           0 :                     const SfxItemSet* pSet = pNd->GetpSwAttrSet();
     603             :                     const SfxPoolItem* pItem;
     604           0 :                     if( pSet )
     605             :                     {
     606           0 :                         if(    !pTOXAttr->HadBreakItem()
     607           0 :                             && SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, false, &pItem ) )
     608             :                         {
     609           0 :                             aBkSet.Put( *pItem );
     610           0 :                             pNd->ResetAttr( RES_BREAK );
     611             :                         }
     612           0 :                         if(    !pTOXAttr->HadPageDescItem()
     613           0 :                             && SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) )
     614             :                         {
     615           0 :                             aBkSet.Put( *pItem );
     616           0 :                             pNd->ResetAttr( RES_PAGEDESC );
     617             :                         }
     618             :                     }
     619             :                 }
     620             :             }
     621             : 
     622           0 :             delete pTOXAttr->GetBase();
     623             : 
     624             :             // set (aboved saved and removed) the break item at the node following the TOX
     625           0 :             if( aBkSet.Count() )
     626           0 :                 pNd->SetAttr( aBkSet );
     627             :         }
     628           0 :         break;
     629             :     case RES_FLTR_SECTION:
     630           0 :         MakePoint(rEntry, pDoc, aRegion);   // so far always Point==Mark
     631             :         pDoc->InsertSwSection(aRegion,
     632           0 :                 *(static_cast<SwFltSection*>(rEntry.pAttr))->GetSectionData(),
     633           0 :                 0, 0, false);
     634           0 :         delete (((SwFltSection*)rEntry.pAttr)->GetSectionData());
     635           0 :         break;
     636             :     case RES_FLTR_REDLINE:
     637             :         {
     638           0 :             if (rEntry.MakeRegion(pDoc, aRegion, true))
     639             :             {
     640             :               pDoc->SetRedlineMode((RedlineMode_t)(   nsRedlineMode_t::REDLINE_ON
     641             :                                               | nsRedlineMode_t::REDLINE_SHOW_INSERT
     642           0 :                                               | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
     643           0 :                 SwFltRedline& rFltRedline = *((SwFltRedline*)rEntry.pAttr);
     644             : 
     645           0 :                 if( USHRT_MAX != rFltRedline.nAutorNoPrev )
     646             :                 {
     647             :                     SwRedlineData aData(rFltRedline.eTypePrev,
     648             :                                         rFltRedline.nAutorNoPrev,
     649             :                                         rFltRedline.aStampPrev,
     650             :                                         OUString(),
     651             :                                         0
     652           0 :                                         );
     653           0 :                     pDoc->AppendRedline(new SwRangeRedline(aData, aRegion), true);
     654             :                 }
     655             :                 SwRedlineData aData(rFltRedline.eType,
     656             :                                     rFltRedline.nAutorNo,
     657             :                                     rFltRedline.aStamp,
     658             :                                     OUString(),
     659             :                                     0
     660           0 :                                     );
     661           0 :                 pDoc->AppendRedline( new SwRangeRedline(aData, aRegion), true );
     662             :                 pDoc->SetRedlineMode((RedlineMode_t)( nsRedlineMode_t::REDLINE_NONE
     663             :                                                 | nsRedlineMode_t::REDLINE_SHOW_INSERT
     664           0 :                                                 | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
     665             :             }
     666             :         }
     667           0 :         break;
     668             :     default:
     669             :         {
     670             :             // Revised for more complex situations should be considered
     671       21092 :             if ( !bSdODChecked )
     672             :             {
     673         129 :                 bHasSdOD = HasSdOD();
     674         129 :                 bSdODChecked = true;
     675             :             }
     676       21092 :             sal_Int32 nStart = rEntry.GetStartCP();
     677       21092 :             sal_Int32 nEnd = rEntry.GetEndCP();
     678       21092 :             if (nStart != -1 && nEnd != -1 && nEnd >= nStart )
     679             :             {
     680       21092 :                 rEntry.SetIsParaEnd( IsParaEndInCPs(nStart,nEnd,bHasSdOD) );
     681             :             }
     682       21092 :             if (rEntry.MakeRegion(pDoc, aRegion, false))
     683             :             {
     684       17669 :                 nStart = rEntry.GetStartCP();
     685       17669 :                 nEnd = rEntry.GetEndCP();
     686       17669 :                 if (rEntry.IsParaEnd())
     687             :                 {
     688        3304 :                     pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0, true);
     689             :                 }
     690             :                 else
     691             :                 {
     692       14365 :                     pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
     693             :                 }
     694             :             }
     695             :         }
     696       21092 :         break;
     697       21196 :     }
     698       21196 : }
     699             : 
     700           0 : bool SwFltControlStack::IsParaEndInCPs(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/,bool /*bSdOD*/) const
     701             : {
     702           0 :     return false;
     703             : }
     704             : 
     705           0 : bool SwFltControlStack::CheckSdOD(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/)
     706             : {
     707           0 :     return false;
     708             : }
     709             : 
     710           8 : SfxPoolItem* SwFltControlStack::GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
     711             : {
     712           8 :     size_t nSize = maEntries.size();
     713             : 
     714           8 :     while (nSize)
     715             :     {
     716             :         // is it the looked-for attribute ? (only applies to locked, meaning
     717             :         // currently set attributes!!)
     718           8 :         SwFltStackEntry &rEntry = maEntries[--nSize];
     719           8 :         if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich)
     720             :         {
     721           8 :             if (pPos)
     722           8 :                 *pPos = nSize;
     723           8 :             return (SfxPoolItem*)rEntry.pAttr;      // Ok, so stop
     724             :         }
     725             :     }
     726           0 :     return 0;
     727             : }
     728             : 
     729           0 : const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich)
     730             : {
     731           0 :     SwFltPosition aFltPos(rPos);
     732             : 
     733           0 :     size_t nSize = maEntries.size();
     734             : 
     735           0 :     while (nSize)
     736             :     {
     737           0 :         SwFltStackEntry &rEntry = maEntries[--nSize];
     738           0 :         if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
     739             :         {
     740           0 :             return (SfxPoolItem*)rEntry.pAttr;
     741             :         }
     742             :     }
     743           0 :     return 0;
     744             : }
     745             : 
     746           0 : const SfxPoolItem* SwFltControlStack::GetFmtAttr(const SwPosition& rPos, sal_uInt16 nWhich)
     747             : {
     748           0 :     SfxPoolItem* pHt = GetFmtStackAttr(nWhich);
     749           0 :     if (pHt)
     750           0 :         return (const SfxPoolItem*)pHt;
     751             : 
     752             :     // the attribute does not exist on the stack; query the document
     753           0 :     SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode();
     754             : 
     755           0 :     if (!pNd)           // no ContentNode, take the default attribute
     756           0 :         return &pDoc->GetAttrPool().GetDefaultItem(nWhich);
     757           0 :     return &pNd->GetAttr(nWhich);
     758             : }
     759             : 
     760           1 : void SwFltControlStack::Delete(const SwPaM &rPam)
     761             : {
     762           1 :     const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
     763             : 
     764           1 :     if( !rPam.HasMark() || *pStt >= *pEnd )
     765           0 :         return;
     766             : 
     767           1 :     SwNodeIndex aStartNode(pStt->nNode, -1);
     768           1 :     const sal_Int32 nStartIdx = pStt->nContent.GetIndex();
     769           2 :     SwNodeIndex aEndNode(pEnd->nNode, -1);
     770           1 :     const sal_Int32 nEndIdx = pEnd->nContent.GetIndex();
     771             : 
     772             :     // We don't support deleting content that is over one node, or removing a node.
     773             :     OSL_ENSURE(aEndNode == aStartNode, "nodes must be the same, or this method extended");
     774           1 :     if (aEndNode != aStartNode)
     775           0 :         return;
     776             : 
     777           2 :     for (size_t nSize = maEntries.size(); nSize > 0;)
     778             :     {
     779           0 :         SwFltStackEntry& rEntry = maEntries[--nSize];
     780             : 
     781             :         bool bEntryStartAfterSelStart =
     782           0 :             (rEntry.m_aMkPos.m_nNode == aStartNode &&
     783           0 :              rEntry.m_aMkPos.m_nCntnt >= nStartIdx);
     784             : 
     785             :         bool bEntryStartBeforeSelEnd =
     786           0 :             (rEntry.m_aMkPos.m_nNode == aEndNode &&
     787           0 :              rEntry.m_aMkPos.m_nCntnt <= nEndIdx);
     788             : 
     789           0 :         bool bEntryEndAfterSelStart = false;
     790           0 :         bool bEntryEndBeforeSelEnd = false;
     791           0 :         if (!rEntry.bOpen)
     792             :         {
     793             :             bEntryEndAfterSelStart =
     794           0 :                 (rEntry.m_aPtPos.m_nNode == aStartNode &&
     795           0 :                  rEntry.m_aPtPos.m_nCntnt >= nStartIdx);
     796             : 
     797             :             bEntryEndBeforeSelEnd =
     798           0 :                 (rEntry.m_aPtPos.m_nNode == aEndNode &&
     799           0 :                  rEntry.m_aPtPos.m_nCntnt <= nEndIdx);
     800             :         }
     801             : 
     802           0 :         bool bTotallyContained = false;
     803           0 :         if (
     804           0 :              bEntryStartAfterSelStart && bEntryStartBeforeSelEnd &&
     805           0 :              bEntryEndAfterSelStart && bEntryEndBeforeSelEnd
     806             :            )
     807             :         {
     808           0 :            bTotallyContained = true;
     809             :         }
     810             : 
     811           0 :         if (bTotallyContained)
     812             :         {
     813             :             // after start, before end, delete
     814           0 :             DeleteAndDestroy(nSize);
     815           0 :             continue;
     816             :         }
     817             : 
     818           0 :         const sal_Int32 nCntntDiff = nEndIdx - nStartIdx;
     819             : 
     820             :         // to be adjusted
     821           0 :         if (bEntryStartAfterSelStart)
     822             :         {
     823           0 :             if (bEntryStartBeforeSelEnd)
     824             :             {
     825             :                 // move start to new start
     826           0 :                 rEntry.m_aMkPos.SetPos(aStartNode, nStartIdx);
     827             :             }
     828             :             else
     829           0 :                 rEntry.m_aMkPos.m_nCntnt -= nCntntDiff;
     830             :         }
     831             : 
     832           0 :         if (bEntryEndAfterSelStart)
     833             :         {
     834           0 :             if (bEntryEndBeforeSelEnd)
     835           0 :                 rEntry.m_aPtPos.SetPos(aStartNode, nStartIdx);
     836             :             else
     837           0 :                 rEntry.m_aPtPos.m_nCntnt -= nCntntDiff;
     838             :         }
     839             : 
     840             :         //That's what Open is, end equal to start, and nPtCntnt is invalid
     841           0 :         if (rEntry.bOpen)
     842           0 :             rEntry.m_aPtPos = rEntry.m_aMkPos;
     843           1 :     }
     844             : }
     845             : 
     846             : // methods of SwFltAnchor follow
     847          87 : SwFltAnchor::SwFltAnchor(SwFrmFmt* pFmt) :
     848          87 :     SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(pFmt)
     849             : {
     850          87 :     pClient = new SwFltAnchorClient(this);
     851          87 :     pFrmFmt->Add(pClient);
     852          87 : }
     853             : 
     854          87 : SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) :
     855          87 :     SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(rCpy.pFrmFmt)
     856             : {
     857          87 :     pClient = new SwFltAnchorClient(this);
     858          87 :     pFrmFmt->Add(pClient);
     859          87 : }
     860             : 
     861         435 : SwFltAnchor::~SwFltAnchor()
     862             : {
     863         174 :     delete pClient;
     864         261 : }
     865             : 
     866           0 : void SwFltAnchor::SetFrmFmt(SwFrmFmt * _pFrmFmt)
     867             : {
     868           0 :     pFrmFmt = _pFrmFmt;
     869           0 : }
     870             : 
     871           0 : const SwFrmFmt * SwFltAnchor::GetFrmFmt() const
     872             : {
     873           0 :     return pFrmFmt;
     874             : }
     875             : 
     876          87 : SwFrmFmt * SwFltAnchor::GetFrmFmt()
     877             : {
     878          87 :     return pFrmFmt;
     879             : }
     880             : 
     881           0 : bool SwFltAnchor::operator==(const SfxPoolItem& rItem) const
     882             : {
     883           0 :     return pFrmFmt == ((SwFltAnchor&)rItem).pFrmFmt;
     884             : }
     885             : 
     886          87 : SfxPoolItem* SwFltAnchor::Clone(SfxItemPool*) const
     887             : {
     888          87 :     return new SwFltAnchor(*this);
     889             : }
     890             : 
     891             : // SwFltAnchorClient
     892             : 
     893         174 : SwFltAnchorClient::SwFltAnchorClient(SwFltAnchor * pFltAnchor)
     894         174 : : m_pFltAnchor(pFltAnchor)
     895             : {
     896         174 : }
     897             : 
     898          52 : void  SwFltAnchorClient::Modify(const SfxPoolItem *, const SfxPoolItem * pNew)
     899             : {
     900          52 :     if (pNew->Which() == RES_FMT_CHG)
     901             :     {
     902           0 :         const SwFmtChg * pFmtChg = dynamic_cast<const SwFmtChg *> (pNew);
     903             : 
     904           0 :         if (pFmtChg != NULL)
     905             :         {
     906           0 :             SwFrmFmt * pFrmFmt = dynamic_cast<SwFrmFmt *> (pFmtChg->pChangedFmt);
     907             : 
     908           0 :             if (pFrmFmt != NULL)
     909           0 :                 m_pFltAnchor->SetFrmFmt(pFrmFmt);
     910             :         }
     911             :     }
     912          52 : }
     913             : 
     914             : // methods of SwFltRedline follow
     915           0 : bool SwFltRedline::operator==(const SfxPoolItem& rItem) const
     916             : {
     917           0 :     return this == &rItem;
     918             : }
     919             : 
     920           0 : SfxPoolItem* SwFltRedline::Clone( SfxItemPool* ) const
     921             : {
     922           0 :     return new SwFltRedline(*this);
     923             : }
     924             : 
     925             : // methods of SwFltBookmark follow
     926          17 : SwFltBookmark::SwFltBookmark( const OUString& rNa, const OUString& rVa,
     927             :                               long nHand, const bool bIsTOCBookmark )
     928             :     : SfxPoolItem( RES_FLTR_BOOKMARK )
     929             :     , mnHandle( nHand )
     930             :     , maName( rNa )
     931             :     , maVal( rVa )
     932          17 :     , mbIsTOCBookmark( bIsTOCBookmark )
     933             : {
     934             :     // eSrc: CHARSET_DONTKNOW for no transform at operator <<
     935             :     // Upcase is always done.
     936             :     // Transform is never done at XXXStack.NewAttr(...).
     937             :     // otherwise: Src Charset from argument for aName
     938             :     // Src Charset from filter for aVal ( Text )
     939             : 
     940          17 :     if ( IsTOCBookmark() )
     941             :     {
     942           0 :         maName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
     943           0 :         maName += rNa;
     944             :     }
     945          17 : }
     946             : 
     947          17 : SwFltBookmark::SwFltBookmark(const SwFltBookmark& rCpy)
     948             :     : SfxPoolItem( RES_FLTR_BOOKMARK )
     949             :     , mnHandle( rCpy.mnHandle )
     950             :     , maName( rCpy.maName )
     951             :     , maVal( rCpy.maVal )
     952          17 :     , mbIsTOCBookmark( rCpy.mbIsTOCBookmark )
     953             : {
     954          17 : }
     955             : 
     956           0 : bool SwFltBookmark::operator==(const SfxPoolItem& rItem) const
     957             : {
     958           0 :     return ( maName == ((SwFltBookmark&)rItem).maName)
     959           0 :             && (mnHandle == ((SwFltBookmark&)rItem).mnHandle);
     960             : }
     961             : 
     962          17 : SfxPoolItem* SwFltBookmark::Clone(SfxItemPool*) const
     963             : {
     964          17 :     return new SwFltBookmark(*this);
     965             : }
     966             : 
     967             : // methods of SwFltTOX follow
     968           0 : SwFltTOX::SwFltTOX(SwTOXBase* pBase, sal_uInt16 _nCols)
     969             :     : SfxPoolItem(RES_FLTR_TOX), pTOXBase(pBase), nCols( _nCols ),
     970           0 :       bHadBreakItem( sal_False ), bHadPageDescItem( sal_False )
     971             : {
     972           0 : }
     973             : 
     974           0 : SwFltTOX::SwFltTOX(const SwFltTOX& rCpy)
     975             :     : SfxPoolItem(RES_FLTR_TOX), pTOXBase(rCpy.pTOXBase), nCols( rCpy.nCols ),
     976           0 :       bHadBreakItem( rCpy.bHadBreakItem ), bHadPageDescItem( rCpy.bHadPageDescItem )
     977             : {
     978           0 : }
     979             : 
     980           0 : bool SwFltTOX::operator==(const SfxPoolItem& rItem) const
     981             : {
     982           0 :     return pTOXBase == ((SwFltTOX&)rItem).pTOXBase;
     983             : }
     984             : 
     985           0 : SfxPoolItem* SwFltTOX::Clone(SfxItemPool*) const
     986             : {
     987           0 :     return new SwFltTOX(*this);
     988             : }
     989             : 
     990             : // methods of SwFltSwSection follow
     991           0 : SwFltSection::SwFltSection(SwSectionData *const pSect)
     992             :     : SfxPoolItem(RES_FLTR_SECTION)
     993           0 :     , m_pSection(pSect)
     994             : {
     995           0 : }
     996             : 
     997           0 : SwFltSection::SwFltSection(const SwFltSection& rCpy)
     998             :     : SfxPoolItem(RES_FLTR_SECTION)
     999           0 :     , m_pSection(rCpy.m_pSection)
    1000             : {
    1001           0 : }
    1002             : 
    1003           0 : bool SwFltSection::operator==(const SfxPoolItem& rItem) const
    1004             : {
    1005           0 :     return m_pSection == ((SwFltSection&)rItem).m_pSection;
    1006             : }
    1007             : 
    1008           0 : SfxPoolItem* SwFltSection::Clone(SfxItemPool*) const
    1009             : {
    1010           0 :     return new SwFltSection(*this);
    1011             : }
    1012             : 
    1013             : // here starts code generated by mdt. this is a shell, if possible, soon for
    1014             : // all filters. the whole trouble of inserting texts and formatting attributes,
    1015             : // manage positions, styles & headers/footers etc.
    1016             : 
    1017             : // SwFltShell
    1018           0 : SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, const OUString& rBaseURL, sal_Bool bNew, sal_uLong nFieldFl) :
    1019             :     pCurrentPageDesc(0),
    1020             :     pSavedPos(0),
    1021             :     eSubMode(None),
    1022             :     nAktStyle(0),
    1023             :     aStack(pDoc, nFieldFl),
    1024             :     aEndStack(pDoc, nFieldFl),
    1025           0 :     pPaM(new SwPaM(*(rPaM.GetPoint()))),
    1026             :     sBaseURL(rBaseURL),
    1027           0 :     nPageDescOffset(GetDoc().GetPageDescCnt()),
    1028             :     eSrcCharSet(RTL_TEXTENCODING_MS_1252),
    1029             :     bNewDoc(bNew),
    1030             :     bStdPD(sal_False),
    1031           0 :     bProtect(sal_False)
    1032             : {
    1033           0 :     memset( pColls, 0, sizeof( pColls ) );
    1034           0 :     pOutDoc = new SwFltOutDoc( *pDoc, pPaM, aStack, aEndStack );
    1035           0 :     pOut = pOutDoc;
    1036             : 
    1037           0 :     if( !bNewDoc ){     // insert into document ?
    1038             :                         // Because only entire lines are read, lines might need
    1039             :                         // to be inserted or broken up
    1040           0 :         const SwPosition* pPos = pPaM->GetPoint();
    1041           0 :         const SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
    1042           0 :         if (pPos->nContent.GetIndex() && !pSttNd->GetTxt().isEmpty())
    1043             :                                             // insert position not in empty line
    1044           0 :             pDoc->SplitNode( *pPos, false );        // make new line
    1045           0 :         if (!pSttNd->GetTxt().isEmpty())
    1046             :         {   // InsertPos not on empty line
    1047           0 :             pDoc->SplitNode( *pPos, false );        // new line
    1048           0 :             pPaM->Move( fnMoveBackward );   // go to empty line
    1049             :         }
    1050             : 
    1051             :         // prohibit reading tables in footnotes / tables
    1052           0 :         sal_uLong nNd = pPos->nNode.GetIndex();
    1053           0 :         bool bReadNoTbl = 0 != pSttNd->FindTableNode() ||
    1054           0 :             ( nNd < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
    1055           0 :             pDoc->GetNodes().GetEndOfInserts().StartOfSectionIndex() < nNd );
    1056           0 :         if( bReadNoTbl )
    1057           0 :             pOutDoc->SetReadNoTable();
    1058             :     }
    1059           0 :     pCurrentPageDesc =  &pDoc->GetPageDesc( 0 );  // Standard
    1060             : 
    1061           0 : }
    1062             : 
    1063           0 : SwFltShell::~SwFltShell()
    1064             : {
    1065             :     sal_uInt16 i;
    1066             : 
    1067           0 :     if (eSubMode == Style)
    1068           0 :         EndStyle();
    1069           0 :     if( pOutDoc->IsInTable() )          // if not properly terminated
    1070           0 :         EndTable();
    1071           0 :     if( pOutDoc->IsInFly() )
    1072           0 :         EndFly();
    1073             : 
    1074           0 :     GetDoc().SetUpdateExpFldStat(true);
    1075           0 :     GetDoc().SetInitDBFields(sal_True);
    1076           0 :     aStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
    1077           0 :     aStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
    1078           0 :     aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
    1079           0 :     aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
    1080           0 :     if( bProtect ){     // The entire document is supposed to be protected
    1081             : 
    1082           0 :         SwDoc& rDoc = GetDoc();
    1083             :                         // 1. Create SectionFmt and Section
    1084           0 :         SwSectionFmt* pSFmt = rDoc.MakeSectionFmt( 0 );
    1085           0 :         SwSectionData aSectionData(CONTENT_SECTION, OUString("PMW-Protect"));
    1086           0 :         aSectionData.SetProtectFlag( true );
    1087             :                         // 2. Look up Start- and EndIdx
    1088           0 :         const SwNode* pEndNd = &rDoc.GetNodes().GetEndOfContent();
    1089           0 :         SwNodeIndex aEndIdx( *pEndNd, -1L );
    1090           0 :         const SwStartNode* pSttNd = pEndNd->StartOfSectionNode();
    1091           0 :         SwNodeIndex aSttIdx( *pSttNd, 1L );         // +1 -> insert after StartNode
    1092             :                                                     // Section
    1093             :                         // insert Section
    1094           0 :         rDoc.GetNodes().InsertTextSection(
    1095           0 :                 aSttIdx, *pSFmt, aSectionData, 0, &aEndIdx, false );
    1096             : 
    1097           0 :         if( !IsFlagSet(SwFltControlStack::DONT_HARD_PROTECT) ){
    1098           0 :             SwDocShell* pDocSh = rDoc.GetDocShell();
    1099           0 :             if( pDocSh )
    1100           0 :                 pDocSh->SetReadOnlyUI( true );
    1101           0 :         }
    1102             :     }
    1103             :         // Update document page descriptors (only this way also left
    1104             :         // pages get adjusted)
    1105             : 
    1106           0 :     GetDoc().ChgPageDesc( 0, GetDoc().GetPageDesc( 0 ));    // PageDesc "Standard"
    1107           0 :     for (i=nPageDescOffset;i<GetDoc().GetPageDescCnt();i++)
    1108             :     {
    1109           0 :         const SwPageDesc& rPD = GetDoc().GetPageDesc(i);
    1110           0 :         GetDoc().ChgPageDesc(i, rPD);
    1111             :     }
    1112             : 
    1113           0 :     delete pPaM;
    1114           0 :     for (i=0; i<sizeof(pColls)/sizeof(*pColls); i++)
    1115           0 :         delete pColls[i];
    1116           0 :     delete pOutDoc;
    1117           0 : }
    1118             : 
    1119           0 : SwFltShell& SwFltShell::operator << ( const OUString& rStr )
    1120             : {
    1121             :     OSL_ENSURE(eSubMode != Style, "char insert while in style-mode");
    1122           0 :     GetDoc().InsertString( *pPaM, rStr );
    1123           0 :     return *this;
    1124             : }
    1125             : 
    1126           0 : OUString SwFltShell::ConvertUStr(const OUString& rInOut)
    1127             : {
    1128           0 :     return GetAppCharClass().uppercase(rInOut);
    1129             : }
    1130             : 
    1131             : // QuoteString() translates CRs to '\n' or "\0x0d", depending on nFieldIniFlags
    1132           0 : OUString SwFltShell::QuoteStr( const OUString& rIn )
    1133             : {
    1134           0 :     OUStringBuffer sOut( rIn );
    1135           0 :     sal_Bool bAllowCr = aStack.IsFlagSet( SwFltControlStack::ALLOW_FLD_CR );
    1136             : 
    1137           0 :     for( sal_Int32 n = 0; n < sOut.getLength(); ++n )
    1138             :     {
    1139           0 :         switch( sOut[ n ] )
    1140             :         {
    1141             :         case 0x0a:
    1142           0 :             sOut.remove( n, 1 );             // 0xd 0xa becomes \n
    1143           0 :             break;
    1144             : 
    1145             :         case 0x0b:
    1146             :         case 0x0c:
    1147             :         case 0x0d:
    1148           0 :             if( bAllowCr )
    1149           0 :                 sOut[n] = '\n';
    1150           0 :             break;
    1151             :         }
    1152             :     }
    1153           0 :     return sOut.makeStringAndClear();
    1154             : }
    1155             : 
    1156           0 : SwFltShell& SwFltShell::operator << ( const sal_Unicode c )
    1157             : {
    1158             :     OSL_ENSURE( eSubMode != Style, "char insert while in style-mode");
    1159           0 :     GetDoc().InsertString( *pPaM, OUString(c) );
    1160           0 :     return *this;
    1161             : }
    1162             : 
    1163           0 : SwFltShell& SwFltShell::AddError( const sal_Char* pErr )
    1164             : {
    1165           0 :     OUString aName("ErrorTag");
    1166           0 :     SwFieldType* pFT = GetDoc().GetFldType( RES_SETEXPFLD, aName, false );
    1167           0 :     if( pFT == 0)
    1168             :     {
    1169           0 :         SwSetExpFieldType aS(&GetDoc(), aName, nsSwGetSetExpType::GSE_STRING);
    1170           0 :         pFT = GetDoc().InsertFldType(aS);
    1171             :     }
    1172             :     SwSetExpField aFld( (SwSetExpFieldType*)pFT,
    1173           0 :                         OUString::createFromAscii( pErr ));
    1174             :     //, VVF_INVISIBLE
    1175           0 :     GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
    1176           0 :     return *this;
    1177             : }
    1178             : 
    1179           0 : SwFltShell& SwFltShell::operator << (Graphic& rGraphic)
    1180             : {
    1181             :     // embedded image !!
    1182           0 :     GetDoc().Insert(*pPaM, OUString(), OUString(), &rGraphic, NULL, NULL, NULL);
    1183           0 :     return *this;
    1184             : }
    1185             : 
    1186           0 : void SwFltShell::NextParagraph()
    1187             : {
    1188           0 :     GetDoc().AppendTxtNode(*pPaM->GetPoint());
    1189           0 : }
    1190             : 
    1191           0 : void SwFltShell::NextPage()
    1192             : {
    1193           0 :     NextParagraph();
    1194           0 :     GetDoc().InsertPoolItem(*pPaM,
    1195           0 :         SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
    1196           0 : }
    1197             : 
    1198           0 : SwFltShell& SwFltShell::AddGraphic( const OUString& rPicName )
    1199             : {
    1200             :     // embedded:
    1201           0 :     GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
    1202           0 :     Graphic aGraphic;
    1203             :     // one of: GFF_NOT GFF_BMP GFF_GIF GFF_JPG GFF_PCD GFF_PCX GFF_PNG
    1204             :     // GFF_TIF GFF_XBM GFF_DXF GFF_MET GFF_PCT GFF_SGF GFF_SVM GFF_WMF
    1205             :     // GFF_SGV GFF_XXX
    1206             :     INetURLObject aDir(
    1207             :         URIHelper::SmartRel2Abs(
    1208           0 :             INetURLObject(GetBaseURL()), rPicName,
    1209           0 :             URIHelper::GetMaybeFileHdl()) );
    1210           0 :     switch (rFilter.ImportGraphic(aGraphic, aDir))
    1211             :     {
    1212             :         case GRFILTER_OK:
    1213           0 :             *this << aGraphic;
    1214           0 :             break;
    1215             :         case GRFILTER_OPENERROR:
    1216             :         case GRFILTER_IOERROR:
    1217             :         case GRFILTER_FORMATERROR:
    1218             :         case GRFILTER_VERSIONERROR:
    1219             :         case GRFILTER_FILTERERROR:
    1220             :         case GRFILTER_ABORT:
    1221             :         case GRFILTER_TOOBIG:
    1222             :         default:
    1223           0 :             AddError( "picture import error" );
    1224           0 :             break;
    1225             :     }
    1226           0 :     return *this;
    1227             : }
    1228             : 
    1229           0 : SwFltShell& SwFltShell::SetStyle( sal_uInt16 nStyle )
    1230             : {
    1231           0 :     SwFltFormatCollection* p = pColls[ nStyle ];
    1232             : 
    1233           0 :     if (p)
    1234             :     {
    1235           0 :         if( !pOutDoc->IsInTable() && nStyle != nAktStyle )
    1236             :         {
    1237           0 :             if( pColls[nAktStyle]->IsInFly() && pOutDoc->IsInFly() )
    1238           0 :                 pOutDoc->EndFly();
    1239           0 :             if( p->IsInFly() )
    1240           0 :                 p->BeginStyleFly( pOutDoc );
    1241             :         }
    1242           0 :         GetDoc().SetTxtFmtColl(*pPaM, p->GetColl());
    1243           0 :         nAktStyle = nStyle;
    1244             :     }
    1245             :     else
    1246             :     {
    1247             :         OSL_FAIL( "Invalid SwFltStyleCode" );
    1248             :     }
    1249           0 :     return *this;
    1250             : }
    1251             : 
    1252           0 : SwFltShell& SwFltShell::operator << (SwFltBookmark& aBook)
    1253             : {
    1254           0 :     aBook.maName = ConvertUStr( aBook.maName );
    1255           0 :     aBook.maVal = QuoteStr(aBook.maVal);
    1256           0 :     aEndStack.NewAttr(*pPaM->GetPoint(), aBook);
    1257           0 :     return *this;
    1258             : }
    1259             : 
    1260           0 : void SwFltShell::SetBookEnd(long nHandle)
    1261             : {
    1262           0 :     aEndStack.SetAttr( *pPaM->GetPoint(), RES_FLTR_BOOKMARK, sal_True, nHandle );
    1263           0 : }
    1264             : 
    1265           0 : SwFltShell& SwFltShell::EndItem( sal_uInt16 nAttrId )
    1266             : {
    1267           0 :     switch( nAttrId )
    1268             :     {
    1269             :     case RES_FLTR_BOOKMARK:
    1270             :         OSL_FAIL( "Wrong invocation for bookmark end" );
    1271           0 :         break;
    1272             : 
    1273             :     case RES_FLTR_TOX:
    1274           0 :         aEndStack.SetAttr(*pPaM->GetPoint(), nAttrId);
    1275           0 :         break;
    1276             : 
    1277             :     default:
    1278           0 :         aStack.SetAttr(*pPaM->GetPoint(), nAttrId);
    1279           0 :         break;
    1280             :     }
    1281           0 :     return *this;
    1282             : }
    1283             : 
    1284           0 : SwFltShell& SwFltShell::operator << (const SwField& rField)
    1285             : {
    1286           0 :     GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0);
    1287           0 :     return *this;
    1288             : }
    1289             : 
    1290           0 : /*virtual*/ SwFltOutBase& SwFltOutDoc::operator << (const SfxPoolItem& rItem)
    1291             : {
    1292           0 :     rStack.NewAttr(*pPaM->GetPoint(), rItem);
    1293           0 :     return *this;
    1294             : }
    1295             : 
    1296           0 : /*virtual*/ SwFltOutBase& SwFltFormatCollection::operator <<
    1297             :                                 (const SfxPoolItem& rItem)
    1298             : {
    1299           0 :     pColl->SetFmtAttr(rItem);
    1300           0 :     return *this;
    1301             : }
    1302             : 
    1303           0 : const SfxPoolItem& SwFltOutDoc::GetAttr(sal_uInt16 nWhich)
    1304             : {
    1305           0 :     return *rStack.GetFmtAttr(*pPaM->GetPoint(), nWhich);
    1306             : }
    1307             : 
    1308           0 : const SfxPoolItem& SwFltFormatCollection::GetAttr(sal_uInt16 nWhich)
    1309             : {
    1310           0 :     return GetColl()->GetFmtAttr(nWhich);   // with Parents
    1311             : }
    1312             : 
    1313             : // GetNodeOrStyAttr fetches attributes for toggle and modify attributes:
    1314             : // For format definitions, the current style with parents is
    1315             : // consulted, otherwise the node with parents.
    1316             : // The stack is never used.
    1317           0 : const SfxPoolItem& SwFltOutDoc::GetNodeOrStyAttr(sal_uInt16 nWhich)
    1318             : {
    1319           0 :     SwCntntNode * pNd = pPaM->GetPoint()->nNode.GetNode().GetCntntNode();
    1320           0 :     if (pNd)            // ContentNode: Attribute with Parent
    1321           0 :         return pNd->GetAttr(nWhich);
    1322             :     else                // no ContentNode, take the default attribute
    1323           0 :         return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1324             : }
    1325             : 
    1326           0 : const SfxPoolItem& SwFltFormatCollection::GetNodeOrStyAttr(sal_uInt16 nWhich)
    1327             : {
    1328           0 :     return GetColl()->GetFmtAttr(nWhich);   // with Parents
    1329             : }
    1330             : 
    1331           0 : const SfxPoolItem& SwFltShell::GetNodeOrStyAttr(sal_uInt16 nWhich)
    1332             : {
    1333           0 :     return pOut->GetNodeOrStyAttr( nWhich );
    1334             : }
    1335             : 
    1336           0 : const SfxPoolItem& SwFltShell::GetAttr(sal_uInt16 nWhich)
    1337             : {
    1338           0 :     return pOut->GetAttr( nWhich );
    1339             : }
    1340             : 
    1341           0 : const SfxPoolItem& SwFltShell::GetFlyFrmAttr(sal_uInt16 nWhich)
    1342             : {
    1343           0 :     return pOut->GetFlyFrmAttr( nWhich );
    1344             : }
    1345             : 
    1346           0 : SwFieldType* SwFltShell::GetSysFldType(sal_uInt16 eWhich)
    1347             : {
    1348           0 :     return GetDoc().GetSysFldType(eWhich);
    1349             : }
    1350             : 
    1351           0 : bool SwFltShell::GetWeightBold()
    1352             : {
    1353           0 :     return ((SvxWeightItem&)GetNodeOrStyAttr(RES_CHRATR_WEIGHT)).GetWeight()
    1354           0 :                                 != WEIGHT_NORMAL;
    1355             : }
    1356             : 
    1357           0 : bool SwFltShell::GetPostureItalic()
    1358             : {
    1359           0 :     return ((SvxPostureItem&)GetNodeOrStyAttr(RES_CHRATR_POSTURE)).GetPosture()
    1360           0 :                                 != ITALIC_NONE;
    1361             : }
    1362             : 
    1363           0 : bool SwFltShell::GetCrossedOut()
    1364             : {
    1365           0 :     return ((SvxCrossedOutItem&)GetNodeOrStyAttr(RES_CHRATR_CROSSEDOUT))
    1366           0 :                                     .GetStrikeout() != STRIKEOUT_NONE;
    1367             : }
    1368             : 
    1369           0 : bool SwFltShell::GetContour()
    1370             : {
    1371           0 :     return ((SvxContourItem&)GetNodeOrStyAttr(RES_CHRATR_CONTOUR)).GetValue();
    1372             : }
    1373             : 
    1374           0 : bool SwFltShell::GetCaseKapitaelchen()
    1375             : {
    1376           0 :     return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
    1377           0 :                                     .GetCaseMap() == SVX_CASEMAP_KAPITAELCHEN;
    1378             : }
    1379             : 
    1380           0 : bool SwFltShell::GetCaseVersalien()
    1381             : {
    1382           0 :     return ((SvxCaseMapItem&)GetNodeOrStyAttr(RES_CHRATR_CASEMAP))
    1383           0 :                                     .GetCaseMap() == SVX_CASEMAP_VERSALIEN;
    1384             : }
    1385             : 
    1386             : // Tables
    1387           0 : SwFltOutBase::~SwFltOutBase()
    1388             : {
    1389           0 : }
    1390             : 
    1391           0 : SwFltOutBase::SwFltOutBase(SwDoc& rDocu)
    1392           0 :     : rDoc(rDocu), eFlyAnchor(FLY_AT_PARA), bFlyAbsPos(false)
    1393             : {
    1394           0 : }
    1395             : 
    1396           0 : const SfxPoolItem& SwFltOutBase::GetCellAttr(sal_uInt16 nWhich)
    1397             : {
    1398             :     OSL_FAIL("GetCellAttr outside of normal text");
    1399           0 :     return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1400             : }
    1401             : 
    1402           0 : bool SwFltOutBase::BeginTable()
    1403             : {
    1404             :     OSL_FAIL("BeginTable outside of normal text");
    1405           0 :     return false;
    1406             : }
    1407             : 
    1408           0 : void SwFltOutBase::NextTableCell()
    1409             : {
    1410             :     OSL_FAIL("NextTableCell outside of normal text");
    1411           0 : }
    1412             : 
    1413           0 : void SwFltOutBase::NextTableRow()
    1414             : {
    1415             :     OSL_FAIL("NextTableRow outside of normal text");
    1416           0 : }
    1417             : 
    1418           0 : void SwFltOutBase::SetTableWidth(SwTwips /*nW*/)
    1419             : {
    1420             :     OSL_FAIL("SetTableWidth outside of normal text");
    1421           0 : }
    1422             : 
    1423           0 : void SwFltOutBase::SetTableOrient(sal_Int16 /*eOri*/)
    1424             : {
    1425             :     OSL_FAIL("SetTableOrient outside of normal text");
    1426           0 : }
    1427             : 
    1428           0 : void SwFltOutBase::SetCellWidth(SwTwips /*nWidth*/, sal_uInt16 /*nCell*/)
    1429             : {
    1430             :     OSL_FAIL("SetCellWidth outside of normal text");
    1431           0 : }
    1432             : 
    1433           0 : void SwFltOutBase::SetCellHeight(SwTwips /*nH*/)
    1434             : {
    1435             :     OSL_FAIL("SetCellHeight outside of normal text");
    1436           0 : }
    1437             : 
    1438           0 : void SwFltOutBase::SetCellBorder(const SvxBoxItem& /*rFmtBox*/, sal_uInt16 /*nCell*/)
    1439             : {
    1440             :     OSL_FAIL("SetCellBorder outside of normal text");
    1441           0 : }
    1442             : 
    1443           0 : void SwFltOutBase::SetCellSpace(sal_uInt16 /*nSp*/)
    1444             : {
    1445             :     OSL_FAIL("SetCellSpace outside of normal text");
    1446           0 : }
    1447             : 
    1448           0 : void SwFltOutBase::DeleteCell(sal_uInt16 /*nCell*/)
    1449             : {
    1450             :     OSL_FAIL("DeleteCell outside of normal text");
    1451           0 : }
    1452             : 
    1453           0 : void SwFltOutBase::EndTable()
    1454             : {
    1455             :     OSL_FAIL("EndTable outside of normal text");
    1456           0 : }
    1457             : 
    1458           0 : /*virtual*/ sal_Bool SwFltOutDoc::IsInTable()
    1459             : {
    1460           0 :     return pTable != 0;
    1461             : };
    1462             : 
    1463           0 : bool SwFltOutDoc::BeginTable()
    1464             : {
    1465           0 :     if(bReadNoTbl)
    1466           0 :         return false;
    1467             : 
    1468           0 :     if (pTable){
    1469             :         OSL_FAIL("BeginTable in Table");
    1470           0 :         return false;
    1471             :     }
    1472             :                             // Close all attributes, because otherwise
    1473             :                             // attributes extending into Flys might be created
    1474           0 :     rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1475           0 :     rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1476             : 
    1477             : // create table:
    1478             :     OSL_ENSURE(pTabSavedPos == NULL, "SwFltOutDoc");
    1479           0 :     pTabSavedPos = new SwPosition(*pPaM->GetPoint());
    1480           0 :     pTable = GetDoc().InsertTable(
    1481             :             SwInsertTableOptions( tabopts::HEADLINE_NO_BORDER, 1 ),
    1482           0 :             *pTabSavedPos, 1, 1, text::HoriOrientation::LEFT, 0, 0, sal_False, sal_False ); // TODO MULTIHEADER
    1483           0 :     nTableWidth = 0;
    1484           0 :     ((SwTable*)pTable)->LockModify();   // Don't adjust anything automatically!
    1485             : // set pam in 1st table cell
    1486             :     usTableX =
    1487           0 :     usTableY = 0;
    1488           0 :     SeekCell(usTableY, usTableX, sal_True);
    1489           0 :     return true;
    1490             : }
    1491             : 
    1492           0 : SwTableBox* SwFltOutDoc::GetBox(sal_uInt16 ny, sal_uInt16 nx /*= USHRT_MAX */)
    1493             : {
    1494           0 :     if(!pTable){
    1495             :         OSL_ENSURE(pTable, "GetBox without table");
    1496           0 :         return 0;
    1497             :     }
    1498           0 :     if( nx == USHRT_MAX )   // current cell
    1499           0 :         nx = usTableX;
    1500             : 
    1501             :     // get structs to table cells
    1502           0 :     const SwTableLines* pTableLines = &pTable->GetTabLines();
    1503           0 :     if(!pTableLines){
    1504             :         OSL_FAIL("SwFltOutDoc:GetBox:pTableLines");
    1505           0 :         return 0;
    1506             :     }
    1507           0 :     if( ny >= pTableLines->size() ){   // emergency break
    1508             :         OSL_FAIL( "SwFltOutDoc:GetBox:ny >= Count()");
    1509           0 :         ny = pTableLines->size() - 1;
    1510             :     }
    1511           0 :     SwTableLine* pTableLine = (*pTableLines)[ny];
    1512           0 :     if(!pTableLine){
    1513             :         OSL_FAIL("SwFltOutDoc:GetBox:pTableLine");
    1514           0 :         return 0;
    1515             :     }
    1516           0 :     SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
    1517           0 :     if(!pTableBoxes){
    1518             :         OSL_FAIL("SwFltOutDoc:GetBox:pTableBoxes");
    1519           0 :         return 0;
    1520             :     }
    1521           0 :     if( nx >= pTableBoxes->size() ){   // emergency break
    1522             :         OSL_FAIL("SwFltOutDoc:GetBox:nx >= Count()");
    1523           0 :         nx = pTableBoxes->size() - 1;
    1524             :     }
    1525           0 :     SwTableBox* pTableBox = (*pTableBoxes)[nx];
    1526             : 
    1527             :     OSL_ENSURE(pTableBox != 0, "SwFltOutDoc:GetBox:pTableBox");
    1528           0 :     return pTableBox;
    1529             : }
    1530             : 
    1531           0 : void SwFltOutDoc::NextTableCell()
    1532             : {
    1533           0 :     if(!pTable){
    1534             :         OSL_ENSURE(pTable, "NextTableCell without table");
    1535           0 :         return;
    1536             :     }
    1537           0 :     const SwTableLines* pTableLines = &pTable->GetTabLines();
    1538           0 :     SwTableLine* pTableLine = (*pTableLines)[usTableY];
    1539           0 :     SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
    1540           0 :     SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
    1541             :     OSL_ENSURE(pTableBox != 0, "SwFltOutDoc:NextTableCell:pTableBox");
    1542           0 :     if(!pTableBox)
    1543           0 :         return;
    1544             :     //#pragma message(__FILE__ "(?) : Sw's const problem")
    1545             :     // insert cells:
    1546           0 :     if (++usTableX >= pTableBoxes->size())
    1547           0 :         GetDoc().GetNodes().InsBoxen(
    1548           0 :          GetDoc().IsIdxInTbl(pPaM->GetPoint()->nNode),
    1549             :          pTableLine,
    1550           0 :          (SwTableBoxFmt*)pTableBox->GetFrmFmt(),
    1551           0 :          GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ),
    1552             :          0,
    1553           0 :          pTableBoxes->size());
    1554           0 :     SeekCell(usTableY, usTableX, sal_True);
    1555           0 :     pTableBox = (*pTableBoxes)[usTableX];
    1556             :     OSL_ENSURE(pTableBox != 0, "SwFltOutDoc:pTableBox");
    1557           0 :     if(pTableBox)
    1558           0 :         (*pTableBoxes)[usTableX]->ClaimFrmFmt();
    1559             : }
    1560             : 
    1561           0 : void SwFltOutDoc::NextTableRow()
    1562             : {
    1563           0 :     SwTableBox* pTableBox = GetBox(usTableY, 0);
    1564           0 :     if (pTableBox)
    1565             :     {
    1566             :         // duplicate row:
    1567           0 :         SwSelBoxes aSelBoxes;
    1568           0 :         aSelBoxes.insert( pTableBox );
    1569           0 :         GetDoc().InsertRow(aSelBoxes);
    1570           0 :         usTableX = 0;
    1571           0 :         SeekCell(++usTableY, usTableX, sal_True);
    1572           0 :         GetDoc().SetTxtFmtColl(*pPaM,
    1573           0 :             GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ));
    1574             :     }
    1575           0 : }
    1576             : 
    1577           0 : void SwFltOutDoc::SetTableWidth(SwTwips nSwWidth)
    1578             : {
    1579           0 :     if(!pTable){
    1580             :         OSL_ENSURE(pTable, "SetTableWidth without table");
    1581           0 :         return;
    1582             :     }
    1583             :     OSL_ENSURE( nSwWidth > MINLAY, "Table width <= MINLAY" );
    1584           0 :     if( nSwWidth != nTableWidth ){
    1585           0 :         if( nTableWidth )           // don't set the first time
    1586           0 :             SplitTable();
    1587           0 :         pTable->GetFrmFmt()->SetFmtAttr( SwFmtFrmSize(ATT_VAR_SIZE, nSwWidth));
    1588           0 :         nTableWidth = nSwWidth;
    1589             :     }
    1590             : }
    1591             : 
    1592           0 : void SwFltOutDoc::SetTableOrient(sal_Int16 eOri)
    1593             : {
    1594           0 :     if(!pTable){
    1595             :         OSL_ENSURE(pTable, "SetTableOrient without table");
    1596           0 :         return;
    1597             :     }
    1598           0 :     pTable->GetFrmFmt()->SetFmtAttr( SwFmtHoriOrient( 0, eOri ));
    1599             : }
    1600             : 
    1601           0 : void SwFltOutDoc::SetCellWidth(SwTwips nWidth, sal_uInt16 nCell /* = USHRT_MAX */ )
    1602             : {
    1603           0 :     if(!pTable){
    1604             :         OSL_ENSURE(pTable, "SetCellWidth without table");
    1605           0 :         return;
    1606             :     }
    1607             :     OSL_ENSURE( nWidth > MINLAY, "Table cell width <= MINLAY" );
    1608           0 :     if (nWidth < MINLAY)
    1609           0 :         nWidth = MINLAY;
    1610             : 
    1611           0 :     SwTableBox* pTableBox = GetBox(usTableY, nCell);
    1612           0 :     if(pTableBox && pTableBox->GetFrmFmt() ){
    1613           0 :         SwFmtFrmSize aFmtFrmSize(ATT_FIX_SIZE);
    1614           0 :         aFmtFrmSize.SetWidth(nWidth);
    1615           0 :         pTableBox->GetFrmFmt()->SetFmtAttr(aFmtFrmSize);
    1616             :     }
    1617             : }
    1618             : 
    1619           0 : void SwFltOutDoc::SetCellHeight(SwTwips nHeight)
    1620             : {
    1621           0 :     if(!pTable){
    1622             :         OSL_ENSURE(pTable, "SetCellHeight without table");
    1623           0 :         return;
    1624             :     }
    1625             : 
    1626           0 :     const SwTableLines* pTableLines = &pTable->GetTabLines();
    1627           0 :     SwTableLine* pTableLine = (*pTableLines)[usTableY];
    1628           0 :     SwFmtFrmSize aFmtFrmSize(ATT_MIN_SIZE, 0, 0);
    1629           0 :     if (nHeight < MINLAY)
    1630           0 :         nHeight = MINLAY;
    1631           0 :     aFmtFrmSize.SetHeight(nHeight);
    1632           0 :     pTableLine->GetFrmFmt()->SetFmtAttr(aFmtFrmSize);
    1633             : }
    1634             : 
    1635           0 : const SfxPoolItem& SwFltOutDoc::GetCellAttr(sal_uInt16 nWhich)
    1636             : {
    1637           0 :     if (!pTable){
    1638             :         OSL_ENSURE(pTable, "GetCellAttr without table");
    1639           0 :         return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1640             :     }
    1641             : 
    1642           0 :     SwTableBox* pTableBox = GetBox(usTableY, usTableX);
    1643           0 :     if(!pTableBox)
    1644           0 :         return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1645           0 :     return pTableBox->GetFrmFmt()->GetFmtAttr( nWhich );
    1646             : }
    1647             : 
    1648           0 : void SwFltOutDoc::SetCellBorder(const SvxBoxItem& rFmtBox,
    1649             :                                sal_uInt16 nCell /* = USHRT_MAX */ )
    1650             : {
    1651           0 :     SwTableBox* pTableBox = GetBox(usTableY, nCell);
    1652           0 :     if(pTableBox)
    1653           0 :         pTableBox->GetFrmFmt()->SetFmtAttr(rFmtBox);
    1654           0 : }
    1655             : 
    1656             : // not activated!
    1657           0 : void SwFltOutDoc::SetCellSpace(sal_uInt16 nDist)
    1658             : {
    1659           0 :     if(!pTable){
    1660             :         OSL_ENSURE(pTable, "SetCellSpace without table");
    1661           0 :         return;
    1662             :     }
    1663           0 :     SwTableBox* pTableBox = GetBox(usTableY, usTableX);
    1664           0 :     if(!pTableBox)
    1665           0 :         return;
    1666             : 
    1667             :     SvxBoxItem aFmtBox( *((SvxBoxItem*)
    1668           0 :                         &pTableBox->GetFrmFmt()->GetFmtAttr( RES_BOX )));
    1669             : 
    1670             :     // I don't get it, sven: if (!nDist) nDist = 18; // ca. 0.03 cm
    1671           0 :     if (nDist > 42) // max. 0.7 mm
    1672           0 :         nDist = 42;
    1673             :     else
    1674           0 :         if (nDist < MIN_BORDER_DIST)
    1675           0 :             nDist = MIN_BORDER_DIST;
    1676           0 :     aFmtBox.SetDistance(nDist);
    1677           0 :     pTableBox->GetFrmFmt()->SetFmtAttr(aFmtBox);
    1678             : }
    1679             : 
    1680           0 : void SwFltOutDoc::DeleteCell(sal_uInt16 nCell /* = USHRT_MAX */)
    1681             : {
    1682           0 :     SwTableBox* pTableBox = GetBox(usTableY, nCell);
    1683           0 :     if( pTableBox )
    1684             :     {
    1685           0 :         SwSelBoxes aSelBoxes;
    1686           0 :         aSelBoxes.insert( pTableBox );
    1687           0 :         GetDoc().DeleteRowCol(aSelBoxes);
    1688           0 :         usTableX--;
    1689             :     }
    1690           0 : }
    1691             : 
    1692           0 : void SwFltOutDoc::SplitTable()
    1693             : {
    1694           0 :     if(!pTable)
    1695             :     {
    1696             :         OSL_ENSURE(pTable, "SplitTable without table");
    1697           0 :         return;
    1698             :     }
    1699           0 :     SwTableBox* pAktBox = GetBox(usTableY, usTableX);
    1700           0 :     SwTableBox* pSplitBox = GetBox(usTableY - 1, 0);
    1701           0 :     GetDoc().GetNodes().SplitTable(SwNodeIndex(*pSplitBox->GetSttNd()), false);
    1702           0 :     pTable = &pAktBox->GetSttNd()->FindTableNode()->GetTable();
    1703           0 :     usTableY = 0;
    1704             : }
    1705             : 
    1706           0 : void SwFltOutDoc::EndTable()
    1707             : {
    1708           0 :     if (!pTable){
    1709             :         OSL_ENSURE(pTable, "EndTable without table");
    1710           0 :         return;
    1711             :     }
    1712             :     // Close all attributes, because otherwise
    1713             :     // attributes extending into Flys might be created
    1714           0 :     rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1715           0 :     rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1716             : 
    1717           0 :     if (GetDoc().GetCurrentViewShell()){
    1718           0 :         SwTableNode* pTableNode = GetDoc().IsIdxInTbl(
    1719           0 :             pPaM->GetPoint()->nNode);
    1720           0 :         pTableNode->DelFrms();
    1721           0 :         pTableNode->MakeFrms(&pPaM->GetPoint()->nNode);
    1722             :     }
    1723             : 
    1724           0 :     *pPaM->GetPoint() = *pTabSavedPos;              // restore Cursor
    1725           0 :     delete pTabSavedPos;
    1726           0 :     pTabSavedPos = 0;
    1727           0 :     ((SwTable*)pTable)->UnlockModify(); // Test, doesn't help against assert
    1728           0 :     pTable = 0;
    1729           0 :     nTableWidth = 0;
    1730             : }
    1731             : 
    1732           0 : sal_Bool SwFltOutDoc::SeekCell(short nRow, short nCol, sal_Bool bPam)
    1733             : {
    1734             :     // get structs to table cells
    1735           0 :     const SwTableLines* pTableLines = &pTable->GetTabLines();
    1736           0 :     SwTableLine* pTableLine = (*pTableLines)[usTableY];
    1737           0 :     SwTableBoxes* pTableBoxes = &pTableLine->GetTabBoxes();
    1738           0 :     SwTableBox* pTableBox = (*pTableBoxes)[usTableX];
    1739             : 
    1740           0 :     if ((sal_uInt16)nRow >= pTableLines->size())
    1741             :     {
    1742             :        OSL_ENSURE((sal_uInt16)nRow >= pTableLines->size(), "SwFltOutDoc");
    1743           0 :         return sal_False;
    1744             :     }
    1745           0 :     pTableLine = (*pTableLines)[nRow];
    1746           0 :     pTableBoxes = &pTableLine->GetTabBoxes();
    1747           0 :     if (nCol >= (short)pTableBoxes->size())
    1748           0 :         return sal_False;
    1749           0 :     pTableBox = (*pTableBoxes)[nCol];
    1750           0 :     if( !pTableBox->GetSttNd() )
    1751             :     {
    1752             :         OSL_ENSURE(pTableBox->GetSttNd(), "SwFltOutDoc");
    1753           0 :         return sal_False;
    1754             :     }
    1755           0 :     if(bPam)
    1756             :     {
    1757           0 :         pPaM->GetPoint()->nNode = pTableBox->GetSttIdx() + 1;
    1758           0 :         pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
    1759           0 :         GetDoc().SetTxtFmtColl(*pPaM,
    1760           0 :             GetDoc().GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false ));
    1761             :     }
    1762           0 :     return sal_True;
    1763             : }
    1764             : 
    1765             : // Flys in SwFltOutBase
    1766           0 : SfxItemSet* SwFltOutBase::NewFlyDefaults()
    1767             : {
    1768             :     // Set required default values ( except when they will be explicitly set
    1769             :     // later )
    1770           0 :     SfxItemSet* p = new SfxItemSet( GetDoc().GetAttrPool(),
    1771           0 :                                     RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
    1772           0 :     SwFmtFrmSize aSz( ATT_VAR_SIZE, MINFLY, MINFLY );
    1773             :                                         // Default: width 100% ( = PMW:Auto )
    1774           0 :     aSz.SetWidthPercent( 100 );         // Height: Auto
    1775           0 :     p->Put( aSz );
    1776           0 :     p->Put( SwFmtHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
    1777           0 :     return p;
    1778             : }
    1779             : 
    1780           0 : bool SwFltOutBase::BeginFly( RndStdIds eAnchor /*= FLY_AT_PARA*/,
    1781             :                            sal_Bool bAbsolutePos /*= sal_False*/,
    1782             :                            const SfxItemSet* pMoreAttrs /*= 0*/)
    1783             : {
    1784             :     (void) pMoreAttrs; // unused in non-debug
    1785             :     OSL_ENSURE(!pMoreAttrs, "SwFltOutBase:BeginFly with pMoreAttrs" );
    1786           0 :     eFlyAnchor = eAnchor;
    1787           0 :     bFlyAbsPos = bAbsolutePos;      // nonsense, actually
    1788           0 :     return true;
    1789             : }
    1790             : 
    1791           0 : /*virtual*/ void SwFltOutBase::SetFlyAnchor( RndStdIds eAnchor )
    1792             : {
    1793           0 :     if( !IsInFly() ){
    1794             :         OSL_FAIL( "SetFlyAnchor() without Fly" );
    1795           0 :         return;
    1796             :     }
    1797           0 :     if ( eAnchor == FLY_AS_CHAR ){
    1798             :         OSL_FAIL( "SetFlyAnchor( FLY_AS_CHAR ) not implemented" );
    1799           0 :         return;
    1800             :     }
    1801           0 :     SwFmtAnchor& rAnchor = (SwFmtAnchor&)GetFlyFrmAttr( RES_ANCHOR );
    1802           0 :     rAnchor.SetType( eAnchor );
    1803             : }
    1804             : 
    1805           0 : void SwFltOutBase::EndFly()
    1806             : {
    1807           0 :     if( bFlyAbsPos ){
    1808             :         // here, the absolute positions on the Fly need to be transformed to
    1809             :         // writer coordinates
    1810             :     }
    1811           0 : }
    1812             : 
    1813             : // Flys in SwFltDoc
    1814           0 : /* virtual */ bool SwFltOutDoc::IsInFly()
    1815             : {
    1816           0 :     return pFly != 0;
    1817             : };
    1818             : 
    1819           0 : SwFrmFmt* SwFltOutDoc::MakeFly( RndStdIds eAnchor, SfxItemSet* pSet )
    1820             : {
    1821           0 :     pFly = (SwFlyFrmFmt*)GetDoc().MakeFlySection( eAnchor, pPaM->GetPoint(),
    1822           0 :                                                     pSet );
    1823           0 :     return pFly;
    1824             : }
    1825             : 
    1826           0 : bool SwFltOutDoc::BeginFly( RndStdIds eAnchor,
    1827             :                            sal_Bool bAbsolutePos ,
    1828             :                            const SfxItemSet* pMoreAttrs)
    1829             : 
    1830             : {
    1831           0 :     SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, 0 );
    1832           0 :     SfxItemSet* pSet = NewFlyDefaults();
    1833             : 
    1834             :     // Close all attributes, because otherwise attributes extending into Flys might
    1835             :     // be created
    1836           0 :     rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1837           0 :     rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1838             : 
    1839             :     // create Fly:
    1840             :     OSL_ENSURE(pFlySavedPos == NULL, "BeginFly in Fly");    // recursive doesn't work yet
    1841           0 :     pFlySavedPos = new SwPosition(*pPaM->GetPoint());
    1842             : 
    1843           0 :     SwFmtAnchor aAnchor( eAnchor, 1 );
    1844             : 
    1845             :     // If the style contained Fly attributes, use them as defaults now
    1846           0 :     if (pMoreAttrs)
    1847           0 :         pSet->Put(*pMoreAttrs);
    1848             : 
    1849             :     // this NOT for page-dependent Fly with page NUMBER !
    1850           0 :     aAnchor.SetAnchor(pPaM->GetPoint());    // surprisingly, doesn't require
    1851             :                                             // the stack
    1852             : 
    1853           0 :     pSet->Put( aAnchor );
    1854           0 :     SwFrmFmt* pF = MakeFly( eAnchor, pSet );
    1855           0 :     delete pSet;
    1856             : 
    1857             :     // set pam in Fly
    1858           0 :     const SwFmtCntnt& rCntnt = pF->GetCntnt();
    1859             :     OSL_ENSURE( rCntnt.GetCntntIdx(), "No prepared content." );
    1860           0 :     pPaM->GetPoint()->nNode = rCntnt.GetCntntIdx()->GetIndex() + 1;
    1861           0 :     SwCntntNode *pNode = pPaM->GetCntntNode();
    1862           0 :     pPaM->GetPoint()->nContent.Assign( pNode, 0 );
    1863             : 
    1864           0 :     return true;
    1865             : }
    1866             : 
    1867           0 : /*virtual*/ void SwFltOutDoc::SetFlyFrmAttr(const SfxPoolItem& rAttr)
    1868             : {
    1869           0 :     if (pFly){
    1870           0 :         pFly->SetFmtAttr( rAttr );
    1871             :     }else{
    1872             :         OSL_ENSURE(pFly, "SetFlyAttr without Doc-Fly");
    1873           0 :         return;
    1874             :     }
    1875             : }
    1876             : 
    1877           0 : /*virtual*/ const SfxPoolItem& SwFltOutDoc::GetFlyFrmAttr(sal_uInt16 nWhich)
    1878             : {
    1879           0 :     if (pFly){
    1880           0 :         return pFly->GetFmtAttr( nWhich );
    1881             :     }else{
    1882             :         OSL_ENSURE(pFly, "GetFlyAttr without Fly");
    1883           0 :         return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1884             :     }
    1885             : }
    1886             : 
    1887           0 : void SwFltOutDoc::EndFly()
    1888             : {
    1889           0 :     if( pTable ){
    1890             :         OSL_FAIL( "SwFltOutDoc::EndFly() in Table" );
    1891           0 :         return;
    1892             :     }
    1893             :     // Close all attributes, because otherwise
    1894             :     // attributes extending into Flys might be created
    1895           0 :     rStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1896           0 :     rEndStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    1897             : 
    1898           0 :     *pPaM->GetPoint() = *pFlySavedPos;              // restore Cursor
    1899           0 :     delete pFlySavedPos;
    1900           0 :     pFlySavedPos = 0;
    1901           0 :     SwFltOutBase::EndFly();
    1902           0 :     pFly = 0;
    1903             : }
    1904             : 
    1905           0 : /*virtual*/ bool SwFltFormatCollection::IsInFly()
    1906             : {
    1907           0 :     return bHasFly;
    1908             : };
    1909             : 
    1910           0 : /*virtual*/ void SwFltFormatCollection::SetFlyFrmAttr(const SfxPoolItem& rAttr)
    1911             : {
    1912           0 :     if (!pFlyAttrs)
    1913           0 :         pFlyAttrs = new SfxItemSet( GetDoc().GetAttrPool(),
    1914           0 :                              RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
    1915           0 :     pFlyAttrs->Put( rAttr );
    1916           0 : }
    1917             : 
    1918           0 : /*virtual*/ const SfxPoolItem& SwFltFormatCollection::GetFlyFrmAttr(sal_uInt16 nWhich)
    1919             : {
    1920           0 :     if( pFlyAttrs )
    1921           0 :         return pFlyAttrs->Get( nWhich, false );
    1922             :     else
    1923           0 :         return GetDoc().GetAttrPool().GetDefaultItem(nWhich);
    1924             : }
    1925             : 
    1926           0 : bool SwFltFormatCollection::BeginFly( RndStdIds eAnchor,
    1927             :                            sal_Bool bAbsolutePos,
    1928             :                            const SfxItemSet* pMoreAttrs)
    1929             : 
    1930             : {
    1931           0 :     SwFltOutBase::BeginFly( eAnchor, bAbsolutePos, pMoreAttrs );
    1932           0 :     bHasFly = true;
    1933           0 :     return true;
    1934             : }
    1935             : 
    1936           0 : void SwFltFormatCollection::EndFly()    // never gets called
    1937             : {
    1938           0 : }
    1939             : 
    1940           0 : bool SwFltFormatCollection::BeginStyleFly( SwFltOutDoc* pOutDoc )
    1941             : {
    1942             :     OSL_ENSURE( pOutDoc, "BeginStyleFly without pOutDoc" );
    1943             :     OSL_ENSURE( pOutDoc && !pOutDoc->IsInFly(), "BeginStyleFly in Fly" );
    1944           0 :     if( pOutDoc && !pOutDoc->IsInFly() )
    1945           0 :         return pOutDoc->BeginFly( eFlyAnchor, bFlyAbsPos, pFlyAttrs );
    1946             :     else
    1947           0 :         return false;
    1948             : }
    1949             : 
    1950           0 : bool SwFltShell::BeginFly( RndStdIds eAnchor,
    1951             :                            sal_Bool bAbsolutePos)
    1952             : {
    1953           0 :     if (pOut->IsInFly()){
    1954             :         OSL_FAIL("BeginFly in Fly");
    1955           0 :         return false;
    1956             :     }
    1957           0 :     if (pOutDoc->IsInTable()){
    1958             :         OSL_FAIL("BeginFly in Table");
    1959           0 :         return false;
    1960             :     }
    1961           0 :     pOut->BeginFly( eAnchor, bAbsolutePos, pColls[nAktStyle]->GetpFlyAttrs() );
    1962           0 :     eSubMode = Fly;
    1963           0 :     return true;
    1964             : }
    1965             : 
    1966           0 : void SwFltShell::SetFlyXPos( short nXPos, sal_Int16 eHRel,
    1967             :                              sal_Int16 eHAlign)
    1968             : {
    1969           0 :     SetFlyFrmAttr( SwFmtHoriOrient( nXPos, eHAlign, eHRel ) );
    1970           0 : }
    1971             : 
    1972           0 : void SwFltShell::SetFlyYPos( short nYPos, sal_Int16 eVRel,
    1973             :                              sal_Int16 eVAlign)
    1974             : {
    1975           0 :     SetFlyFrmAttr( SwFmtVertOrient( nYPos, eVAlign, eVRel ) );
    1976           0 : }
    1977             : 
    1978           0 : void SwFltShell::EndFly()
    1979             : {
    1980           0 :     if (!pOut->IsInFly()){
    1981             :         OSL_FAIL("EndFly without Fly");
    1982           0 :         return;
    1983             :     }
    1984           0 :     if (pOutDoc->IsInTable()){      // Table intermingled with Fly doesn't make sense
    1985             :         OSL_FAIL("EndFly in Table ( intermingled )");
    1986           0 :         EndTable();
    1987             :     }
    1988           0 :     pOut->EndFly();
    1989           0 :     eSubMode = None;
    1990             : }
    1991             : 
    1992           0 : void SwFltShell::BeginFootnote()
    1993             : {
    1994           0 :     if( pOut->IsInFly() ){          // Happens at footnote in Fly, among others
    1995             :         OSL_FAIL("Footnote in Fly not permitted");
    1996           0 :         return;
    1997             :     }
    1998           0 :     if( pOutDoc->IsInTable() ){
    1999             :         OSL_FAIL("Footnote in table currently not allowed");
    2000           0 :         return;
    2001             :     }
    2002             : 
    2003             :     // Close all attributes, because otherwise attributes extending into
    2004             :     // footnotes might be created
    2005           0 :     aStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    2006             :     //  Don't force-close EndStack for now, so bookmarks on footnotes can
    2007             :     //  be applied to PMW
    2008             : 
    2009           0 :     SwFmtFtn aFtn;
    2010           0 :     GetDoc().InsertPoolItem(*pPaM, aFtn, 0);
    2011             :     OSL_ENSURE(pSavedPos == NULL, "SwFltShell");
    2012           0 :     pSavedPos = new SwPosition(*pPaM->GetPoint());
    2013           0 :     pPaM->Move(fnMoveBackward, fnGoCntnt);
    2014           0 :     SwTxtNode* pTxt = pPaM->GetNode()->GetTxtNode();
    2015             :     SwTxtAttr *const pFN = pTxt->GetTxtAttrForCharAt(
    2016           0 :         pPaM->GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
    2017           0 :     if( !pFN ){         // Happens at footnote in Fly, among others
    2018             :         OSL_ENSURE(pFN, "Problems with creating footnote text");
    2019           0 :         return;
    2020             :     }
    2021           0 :     const SwNodeIndex* pStartIndex = ((SwTxtFtn*)pFN)->GetStartNode();
    2022             :     OSL_ENSURE(pStartIndex, "Problems with creating footnote text");
    2023           0 :     pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
    2024           0 :     pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
    2025           0 :     eSubMode = Footnote;
    2026             : }
    2027             : 
    2028           0 : void SwFltShell::EndFootnote()
    2029             : {
    2030           0 :     if(!pSavedPos)
    2031           0 :         return;
    2032             :     // Close all attributes, because otherwise
    2033             :     // attributes extending out of footnotes might
    2034             :     // be created
    2035           0 :     aStack.SetAttr( *pPaM->GetPoint(), 0, sal_False );
    2036             :     //  Don't force-close EndStack for now, so bookmarks on footnotes can
    2037             :     //  be applied to PMW
    2038             : 
    2039           0 :     *pPaM->GetPoint() = *pSavedPos;             // restore Cursor
    2040           0 :     delete pSavedPos;
    2041           0 :     pSavedPos = 0;
    2042             : }
    2043             : 
    2044           0 : void SwFltShell::BeginHeader(SwPageDesc* /*pPD*/)
    2045             : {
    2046           0 :     SwFrmFmt* pFmt = &pCurrentPageDesc->GetMaster();
    2047             :     SwFrmFmt* pHdFtFmt;
    2048           0 :     pFmt->SetFmtAttr(SwFmtHeader(sal_True));
    2049           0 :     pHdFtFmt = (SwFrmFmt*)pFmt->GetHeader().GetHeaderFmt();
    2050           0 :     const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
    2051           0 :     if (!pStartIndex)
    2052           0 :         return;
    2053             :     OSL_ENSURE(pSavedPos == NULL, "SwFltShell");
    2054           0 :     pSavedPos = new SwPosition(*pPaM->GetPoint());
    2055           0 :     pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
    2056           0 :     pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
    2057           0 :     eSubMode = Header;
    2058             : }
    2059             : 
    2060           0 : void SwFltShell::BeginFooter(SwPageDesc* /*pPD*/)
    2061             : {
    2062           0 :     SwFrmFmt* pFmt =  &pCurrentPageDesc->GetMaster();
    2063             :     SwFrmFmt* pHdFtFmt;
    2064           0 :     pFmt->SetFmtAttr(SwFmtFooter(sal_True));
    2065           0 :     pHdFtFmt = (SwFrmFmt*)pFmt->GetFooter().GetFooterFmt();
    2066           0 :     const SwNodeIndex* pStartIndex = pHdFtFmt->GetCntnt().GetCntntIdx();
    2067           0 :     if (!pStartIndex)
    2068           0 :         return;
    2069             :     OSL_ENSURE(pSavedPos == NULL, "SwFltShell");
    2070           0 :     pSavedPos = new SwPosition(*pPaM->GetPoint());
    2071           0 :     pPaM->GetPoint()->nNode = pStartIndex->GetIndex() + 1;
    2072           0 :     pPaM->GetPoint()->nContent.Assign(pPaM->GetCntntNode(), 0);
    2073           0 :     eSubMode = Footer;
    2074             : }
    2075             : 
    2076           0 : void SwFltShell::EndHeaderFooter()
    2077             : {
    2078           0 :     *pPaM->GetPoint() = *pSavedPos;             // restore Cursor
    2079           0 :     delete pSavedPos;
    2080           0 :     pSavedPos = 0;
    2081           0 : }
    2082             : 
    2083           0 : SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc)
    2084             : {
    2085           0 :     if(bStdPD)                      // no new PageDescs
    2086           0 :         return pCurrentPageDesc;
    2087             : 
    2088           0 :     bool bFollow = (pFirstPageDesc != 0);
    2089             :     SwPageDesc* pNewPD;
    2090             :     sal_uInt16 nPos;
    2091           0 :     if (bFollow && pFirstPageDesc->GetFollow() != pFirstPageDesc)
    2092           0 :         return pFirstPageDesc;      // Error: already has Follow
    2093             :     // Detection of duplicate names still missing (low probability of this
    2094             :     // actually occurring)
    2095             : 
    2096           0 :     nPos = GetDoc().MakePageDesc( SwViewShell::GetShellRes()->GetPageDescName(
    2097           0 :                                    GetDoc().GetPageDescCnt(), bFollow ? ShellResource::FOLLOW_PAGE : ShellResource::NORMAL_PAGE),
    2098           0 :                                 pFirstPageDesc, false );
    2099             : 
    2100           0 :     pNewPD =  &GetDoc().GetPageDesc(nPos);
    2101           0 :     if (bFollow)
    2102             :     {
    2103             :         // This one follows pPageDesc
    2104           0 :         pFirstPageDesc->SetFollow(pNewPD);
    2105           0 :         pNewPD->SetFollow(pNewPD);
    2106             :     }
    2107             :     else
    2108             :     {
    2109           0 :         GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 );
    2110             :     }
    2111             :     pNewPD->WriteUseOn( // all pages
    2112           0 :      (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE));
    2113           0 :     return pNewPD;
    2114             : }
    2115             : 
    2116           0 : SwFltFormatCollection::SwFltFormatCollection(
    2117             :     SwDoc& _rDoc, RES_POOL_COLLFMT_TYPE nType ) :
    2118             :     SwFltOutBase(_rDoc),
    2119           0 :     pColl(_rDoc.GetTxtCollFromPool( static_cast< sal_uInt16 >(nType), false )),
    2120             :     pFlyAttrs( 0 ),
    2121           0 :     bHasFly( false )
    2122             : {
    2123           0 :     Reset();            // reset default attrs and auto flag
    2124           0 : }
    2125             : 
    2126           0 : SwFltFormatCollection::SwFltFormatCollection(
    2127             :     SwDoc& _rDoc, const OUString& rName ) :
    2128             :     SwFltOutBase(_rDoc),
    2129             :     pFlyAttrs( 0 ),
    2130           0 :     bHasFly( false )
    2131             : {
    2132           0 :     pColl = _rDoc.MakeTxtFmtColl(rName, (SwTxtFmtColl*)_rDoc.GetDfltTxtFmtColl());
    2133           0 :     Reset();            // reset default attrs and auto flag
    2134           0 : }
    2135             : 
    2136           0 : void SwFltShell::NextStyle(sal_uInt16 nWhich, sal_uInt16 nNext)
    2137             : {
    2138             :         OSL_ENSURE(pColls[nWhich], "Next style for noexistent style" );
    2139             :         OSL_ENSURE(pColls[nNext], "Next style to noexistent style" );
    2140           0 :         if( pColls[nWhich] && pColls[nNext] )
    2141           0 :             pColls[nWhich]->GetColl()->SetNextTxtFmtColl(
    2142           0 :                  *pColls[nNext]->GetColl() );
    2143           0 : }
    2144             : 
    2145             : // UpdatePageDescs needs to be called at end of parsing to make Writer actually
    2146             : // accept Pagedescs contents
    2147          73 : void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset)
    2148             : {
    2149             :     // Update document page descriptors (only this way also left pages
    2150             :     // get adjusted)
    2151             : 
    2152             :     // PageDesc "Standard"
    2153          73 :     rDoc.ChgPageDesc(0, rDoc.GetPageDesc(0));
    2154             : 
    2155             :     // PageDescs "Convert..."
    2156          85 :     for (sal_uInt16 i = nInPageDescOffset; i < rDoc.GetPageDescCnt(); ++i)
    2157          12 :         rDoc.ChgPageDesc(i, rDoc.GetPageDesc(i));
    2158          73 : }
    2159             : 
    2160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10