LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/unocore - unocrsrhelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 161 502 32.1 %
Date: 2012-12-27 Functions: 9 13 69.2 %
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 <svx/svxids.hrc>
      21             : #include <map>
      22             : #include <com/sun/star/text/XTextSection.hpp>
      23             : #include <cmdid.h>
      24             : #include <unocrsrhelper.hxx>
      25             : #include <unofootnote.hxx>
      26             : #include <unorefmark.hxx>
      27             : #include <unostyle.hxx>
      28             : #include <unoidx.hxx>
      29             : #include <unofield.hxx>
      30             : #include <unotbl.hxx>
      31             : #include <unosett.hxx>
      32             : #include <unoframe.hxx>
      33             : #include <unocrsr.hxx>
      34             : #include <doc.hxx>
      35             : #include <IDocumentUndoRedo.hxx>
      36             : #include <IDocumentRedlineAccess.hxx>
      37             : #include <fmtftn.hxx>
      38             : #include <fmtpdsc.hxx>
      39             : #include <charfmt.hxx>
      40             : #include <pagedesc.hxx>
      41             : #include <docstyle.hxx>
      42             : #include <ndtxt.hxx>
      43             : #include <txtrfmrk.hxx>
      44             : #include <fmtfld.hxx>
      45             : #include <docsh.hxx>
      46             : #include <section.hxx>
      47             : #include <shellio.hxx>
      48             : #include <edimp.hxx>
      49             : #include <swundo.hxx>
      50             : #include <cntfrm.hxx>
      51             : #include <pagefrm.hxx>
      52             : #include <svl/eitem.hxx>
      53             : #include <docary.hxx>
      54             : #include <swtable.hxx>
      55             : #include <tox.hxx>
      56             : #include <doctxm.hxx>
      57             : #include <fchrfmt.hxx>
      58             : #include <editeng/flstitem.hxx>
      59             : #include <vcl/metric.hxx>
      60             : #include <svtools/ctrltool.hxx>
      61             : #include <sfx2/docfilt.hxx>
      62             : #include <sfx2/docfile.hxx>
      63             : #include <sfx2/fcontnr.hxx>
      64             : #include <svl/stritem.hxx>
      65             : #include <com/sun/star/beans/PropertyState.hpp>
      66             : #include <SwStyleNameMapper.hxx>
      67             : #include <redline.hxx>
      68             : #include <numrule.hxx>
      69             : #include <comphelper/storagehelper.hxx>
      70             : #include <comphelper/mediadescriptor.hxx>
      71             : #include <comphelper/sequenceashashmap.hxx>
      72             : #include <com/sun/star/embed/ElementModes.hpp>
      73             : #include <com/sun/star/embed/XStorage.hpp>
      74             : #include <SwNodeNum.hxx>
      75             : #include <fmtmeta.hxx>
      76             : 
      77             : 
      78             : using namespace ::com::sun::star;
      79             : using namespace ::com::sun::star::uno;
      80             : using namespace ::com::sun::star::beans;
      81             : using namespace ::com::sun::star::text;
      82             : using namespace ::com::sun::star::table;
      83             : using namespace ::com::sun::star::container;
      84             : using namespace ::com::sun::star::lang;
      85             : using ::rtl::OUString;
      86             : 
      87             : namespace SwUnoCursorHelper
      88             : {
      89             : 
      90             : uno::Reference<text::XTextContent>
      91           0 : GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
      92             :         bool const bParent)
      93             : {
      94             :     // these should be unambiguous because of the dummy character
      95             :     SwTxtNode::GetTxtAttrMode const eMode( (bParent)
      96           0 :         ? SwTxtNode::PARENT : SwTxtNode::EXPAND );
      97             :     SwTxtAttr *const pMetaTxtAttr =
      98           0 :         rTextNode.GetTxtAttrAt(nIndex, RES_TXTATR_META, eMode);
      99             :     SwTxtAttr *const pMetaFieldTxtAttr =
     100           0 :         rTextNode.GetTxtAttrAt(nIndex, RES_TXTATR_METAFIELD, eMode);
     101             :     // which is innermost?
     102             :     SwTxtAttr *const pTxtAttr = (pMetaTxtAttr)
     103             :         ? ((pMetaFieldTxtAttr)
     104           0 :             ? ((*pMetaFieldTxtAttr->GetStart() >
     105           0 :                     *pMetaTxtAttr->GetStart())
     106             :                 ? pMetaFieldTxtAttr : pMetaTxtAttr)
     107             :             : pMetaTxtAttr)
     108           0 :         : pMetaFieldTxtAttr;
     109           0 :     uno::Reference<XTextContent> xRet;
     110           0 :     if (pTxtAttr)
     111             :     {
     112             :         ::sw::Meta *const pMeta(
     113           0 :             static_cast<SwFmtMeta &>(pTxtAttr->GetAttr()).GetMeta());
     114             :         OSL_ASSERT(pMeta);
     115           0 :         xRet.set(pMeta->MakeUnoObject(), uno::UNO_QUERY);
     116             :     }
     117           0 :     return xRet;
     118             : }
     119             : 
     120             : /* --------------------------------------------------
     121             :  *  Read the special properties of the cursor
     122             :  * --------------------------------------------------*/
     123         809 : bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
     124             :                                         , SwPaM& rPam
     125             :                                         , Any *pAny
     126             :                                         , PropertyState& eState
     127             :                                         , const SwTxtNode* pNode  )
     128             : {
     129         809 :     PropertyState eNewState = PropertyState_DIRECT_VALUE;
     130             : //    PropertyState_DEFAULT_VALUE
     131             : //    PropertyState_AMBIGUOUS_VALUE
     132         809 :     bool bDone = true;
     133         809 :     switch(rEntry.nWID)
     134             :     {
     135             :         case FN_UNO_PARA_CONT_PREV_SUBTREE:
     136           0 :             if (pAny)
     137             :             {
     138           0 :                 const SwTxtNode * pTmpNode = pNode;
     139             : 
     140           0 :                 if (!pTmpNode)
     141           0 :                     pTmpNode = rPam.GetNode()->GetTxtNode();
     142             : 
     143           0 :                 bool bRet = false;
     144             : 
     145           0 :                 if ( pTmpNode &&
     146           0 :                      pTmpNode->GetNum() &&
     147           0 :                      pTmpNode->GetNum()->IsContinueingPreviousSubTree() )
     148             :                 {
     149           0 :                     bRet = true;
     150             :                 }
     151             : 
     152           0 :                 *pAny <<= bRet;
     153             :             }
     154           0 :         break;
     155             :         case FN_UNO_PARA_NUM_STRING:
     156           0 :             if (pAny)
     157             :             {
     158           0 :                 const SwTxtNode * pTmpNode = pNode;
     159             : 
     160           0 :                 if (!pTmpNode)
     161           0 :                     pTmpNode = rPam.GetNode()->GetTxtNode();
     162             : 
     163           0 :                 String sRet;
     164           0 :                 if ( pTmpNode && pTmpNode->GetNum() )
     165             :                 {
     166           0 :                     sRet = pTmpNode->GetNumString();
     167             :                 }
     168             : 
     169           0 :                 *pAny <<= OUString(sRet);
     170             :             }
     171           0 :         break;
     172             :         case RES_PARATR_OUTLINELEVEL:
     173         245 :             if (pAny)
     174             :             {
     175         245 :                 const SwTxtNode * pTmpNode = pNode;
     176             : 
     177         245 :                 if (!pTmpNode)
     178         226 :                     pTmpNode = rPam.GetNode()->GetTxtNode();
     179             : 
     180         245 :                 sal_Int16 nRet = -1;
     181         245 :                 if ( pTmpNode )
     182         245 :                     nRet = sal::static_int_cast< sal_Int16 >( pTmpNode->GetAttrOutlineLevel() );
     183             : 
     184         245 :                 *pAny <<= nRet;
     185             :             }
     186         245 :         break;
     187             :         case FN_UNO_PARA_CONDITIONAL_STYLE_NAME:
     188             :         case FN_UNO_PARA_STYLE :
     189             :         {
     190          63 :             SwFmtColl* pFmt = 0;
     191          63 :             if(pNode)
     192             :                 pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID
     193          63 :                             ? pNode->GetFmtColl() : &pNode->GetAnyFmtColl();
     194             :             else
     195             :             {
     196             :                 pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(rPam,
     197           0 :                         FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID);
     198             :             }
     199          63 :             if(pFmt)
     200             :             {
     201          63 :                 if( pAny )
     202             :                 {
     203          63 :                     String sVal;
     204          63 :                     SwStyleNameMapper::FillProgName(pFmt->GetName(), sVal, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true );
     205          63 :                     *pAny <<= OUString(sVal);
     206             :                 }
     207             :             }
     208             :             else
     209           0 :                 eNewState = PropertyState_AMBIGUOUS_VALUE;
     210             :         }
     211          63 :         break;
     212             :         case FN_UNO_PAGE_STYLE :
     213             :         {
     214          13 :             String sVal;
     215          13 :             GetCurPageStyle(rPam, sVal);
     216          13 :             if( pAny )
     217          13 :                 *pAny <<= OUString(sVal);
     218          13 :             if(!sVal.Len())
     219           0 :                 eNewState = PropertyState_AMBIGUOUS_VALUE;
     220             :         }
     221          13 :         break;
     222             :         case FN_UNO_NUM_START_VALUE  :
     223           0 :             if( pAny )
     224             :             {
     225           0 :                 sal_Int16 nValue = IsNodeNumStart(rPam, eNewState);
     226           0 :                 *pAny <<= nValue;
     227             :             }
     228           0 :         break;
     229             :         case FN_UNO_NUM_LEVEL  :
     230             :         case FN_UNO_IS_NUMBER  :
     231             :         // #i91601#
     232             :         case FN_UNO_LIST_ID:
     233             :         case FN_NUMBER_NEWSTART:
     234             :         {
     235             :             // a multi selection is not considered
     236          38 :             const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode();
     237          38 :             if ( pTxtNd && pTxtNd->IsInList() )
     238             :             {
     239           0 :                 if( pAny )
     240             :                 {
     241           0 :                     if(rEntry.nWID == FN_UNO_NUM_LEVEL)
     242           0 :                         *pAny <<= (sal_Int16)(pTxtNd->GetActualListLevel());
     243           0 :                     else if(rEntry.nWID == FN_UNO_IS_NUMBER)
     244             :                     {
     245           0 :                         sal_Bool bIsNumber = pTxtNd->IsCountedInList();
     246           0 :                         pAny->setValue(&bIsNumber, ::getBooleanCppuType());
     247             :                     }
     248             :                     // #i91601#
     249           0 :                     else if ( rEntry.nWID == FN_UNO_LIST_ID )
     250             :                     {
     251           0 :                         const String sListId = pTxtNd->GetListId();
     252           0 :                         *pAny <<= OUString(sListId);
     253             :                     }
     254             :                     else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/
     255             :                     {
     256           0 :                         sal_Bool bIsRestart = pTxtNd->IsListRestart();
     257           0 :                         pAny->setValue(&bIsRestart, ::getBooleanCppuType());
     258             :                     }
     259             :                 }
     260             :             }
     261             :             else
     262             :             {
     263          38 :                 eNewState = PropertyState_DEFAULT_VALUE;
     264             : 
     265          38 :                 if( pAny )
     266             :                 {
     267             :                     // #i30838# set default values for default properties
     268          38 :                     if(rEntry.nWID == FN_UNO_NUM_LEVEL)
     269          19 :                         *pAny <<= static_cast<sal_Int16>( 0 );
     270          19 :                     else if(rEntry.nWID == FN_UNO_IS_NUMBER)
     271          19 :                         *pAny <<= false;
     272             :                     // #i91601#
     273           0 :                     else if ( rEntry.nWID == FN_UNO_LIST_ID )
     274             :                     {
     275           0 :                         *pAny <<= OUString();
     276             :                     }
     277             :                     else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/
     278           0 :                         *pAny <<= false;
     279             :                 }
     280             :             }
     281             :             //PROPERTY_MAYBEVOID!
     282             :         }
     283          38 :         break;
     284             :         case FN_UNO_NUM_RULES  :
     285         240 :             if( pAny )
     286         240 :                 getNumberingProperty(rPam, eNewState, pAny);
     287             :             else
     288             :             {
     289           0 :                 if( !rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() ) )
     290           0 :                     eNewState = PropertyState_DEFAULT_VALUE;
     291             :             }
     292         240 :             break;
     293             :         case FN_UNO_DOCUMENT_INDEX_MARK:
     294             :         {
     295             :             ::std::vector<SwTxtAttr *> const marks(
     296             :                 rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
     297           0 :                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK));
     298           0 :             if (marks.size())
     299             :             {
     300           0 :                 if( pAny )
     301             :                 {   // hmm... can only return 1 here
     302             :                     SwTOXMark & rMark =
     303           0 :                         static_cast<SwTOXMark &>((*marks.begin())->GetAttr());
     304             :                     const uno::Reference< text::XDocumentIndexMark > xRef =
     305             :                         SwXDocumentIndexMark::CreateXDocumentIndexMark(
     306           0 :                             *rPam.GetDoc(),
     307           0 :                             *const_cast<SwTOXType*>(rMark.GetTOXType()), rMark);
     308           0 :                     (*pAny) <<= xRef;
     309             :                 }
     310             :             }
     311             :             else
     312             :                 //also here - indistinguishable
     313           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     314             :         }
     315           0 :         break;
     316             :         case FN_UNO_DOCUMENT_INDEX:
     317             :         {
     318             :             const SwTOXBase* pBase = rPam.GetDoc()->GetCurTOX(
     319           0 :                                                     *rPam.Start() );
     320           0 :             if( pBase )
     321             :             {
     322           0 :                 if( pAny )
     323             :                 {
     324             :                     const uno::Reference< text::XDocumentIndex > xRef =
     325           0 :                         SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(),
     326           0 :                             *static_cast<SwTOXBaseSection const*>(pBase));
     327           0 :                     (*pAny) <<= xRef;
     328             :                 }
     329             :             }
     330             :             else
     331           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     332             :         }
     333           0 :         break;
     334             :         case FN_UNO_TEXT_FIELD:
     335             :         {
     336           0 :             const SwPosition *pPos = rPam.Start();
     337             :             const SwTxtNode *pTxtNd =
     338           0 :                 rPam.GetDoc()->GetNodes()[pPos->nNode.GetIndex()]->GetTxtNode();
     339             :             SwTxtAttr *const pTxtAttr = (pTxtNd)
     340             :                 ? pTxtNd->GetTxtAttrForCharAt(
     341           0 :                         pPos->nContent.GetIndex(), RES_TXTATR_FIELD)
     342           0 :                 : 0;
     343           0 :             if(pTxtAttr)
     344             :             {
     345           0 :                 if( pAny )
     346             :                 {
     347           0 :                     SwXTextField* pField = SwXTextField::CreateSwXTextField(*rPam.GetDoc(),
     348           0 :                            pTxtAttr->GetFld());
     349           0 :                     *pAny <<= uno::Reference< XTextField >( pField );
     350             :                 }
     351             :             }
     352             :             else
     353           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     354             :         }
     355           0 :         break;
     356             :         case FN_UNO_TEXT_TABLE:
     357             :         case FN_UNO_CELL:
     358             :         {
     359           0 :             SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode();
     360           0 :             SwStartNodeType eType = pSttNode->GetStartNodeType();
     361           0 :             if(SwTableBoxStartNode == eType)
     362             :             {
     363           0 :                 if( pAny )
     364             :                 {
     365           0 :                     const SwTableNode* pTblNode = pSttNode->FindTableNode();
     366           0 :                     SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt();
     367             :                     //SwTable& rTable = ((SwTableNode*)pSttNode)->GetTable();
     368           0 :                     if(FN_UNO_TEXT_TABLE == rEntry.nWID)
     369             :                     {
     370           0 :                         uno::Reference< XTextTable >  xTable = SwXTextTables::GetObject(*pTableFmt);
     371           0 :                         pAny->setValue(&xTable, ::getCppuType((uno::Reference<XTextTable>*)0));
     372             :                     }
     373             :                     else
     374             :                     {
     375           0 :                         SwTableBox* pBox = pSttNode->GetTblBox();
     376           0 :                         uno::Reference< XCell >  xCell = SwXCell::CreateXCell(pTableFmt, pBox);
     377           0 :                         pAny->setValue(&xCell, ::getCppuType((uno::Reference<XCell>*)0));
     378             :                     }
     379             :                 }
     380             :             }
     381             :             else
     382           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     383             :         }
     384           0 :         break;
     385             :         case FN_UNO_TEXT_FRAME:
     386             :         {
     387           2 :             SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode();
     388           2 :             SwStartNodeType eType = pSttNode->GetStartNodeType();
     389             : 
     390             :             SwFrmFmt* pFmt;
     391           2 :             if(eType == SwFlyStartNode && 0 != (pFmt = pSttNode->GetFlyFmt()))
     392             :             {
     393           0 :                 if( pAny )
     394             :                 {
     395           0 :                     uno::Reference< XTextFrame >  xFrm = (SwXTextFrame*) SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM);
     396           0 :                     pAny->setValue(&xFrm, ::getCppuType((uno::Reference<XTextFrame>*)0));
     397             :                 }
     398             :             }
     399             :             else
     400           2 :                 eNewState = PropertyState_DEFAULT_VALUE;
     401             :         }
     402           2 :         break;
     403             :         case FN_UNO_TEXT_SECTION:
     404             :         {
     405          31 :             SwSection* pSect = rPam.GetDoc()->GetCurrSection(*rPam.GetPoint());
     406          31 :             if(pSect)
     407             :             {
     408           0 :                 if( pAny )
     409             :                 {
     410           0 :                     uno::Reference< XTextSection >  xSect = SwXTextSections::GetObject( *pSect->GetFmt() );
     411           0 :                     pAny->setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0) );
     412             :                 }
     413             :             }
     414             :             else
     415          31 :                 eNewState = PropertyState_DEFAULT_VALUE;
     416             :         }
     417          31 :         break;
     418             :         case FN_UNO_ENDNOTE:
     419             :         case FN_UNO_FOOTNOTE:
     420             :         {
     421             :             SwTxtAttr *const pTxtAttr =
     422             :                 rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
     423           0 :                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
     424           0 :             if(pTxtAttr)
     425             :             {
     426           0 :                 const SwFmtFtn& rFtn = pTxtAttr->GetFtn();
     427           0 :                 if(rFtn.IsEndNote() == (FN_UNO_ENDNOTE == rEntry.nWID))
     428             :                 {
     429           0 :                     if( pAny )
     430             :                     {
     431             :                         const uno::Reference< text::XFootnote > xFootnote =
     432           0 :                             SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn);
     433           0 :                         *pAny <<= xFootnote;
     434             :                     }
     435             :                 }
     436             :                 else
     437           0 :                     eNewState = PropertyState_DEFAULT_VALUE;
     438             :             }
     439             :             else
     440           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     441             :         }
     442           0 :         break;
     443             :         case FN_UNO_REFERENCE_MARK:
     444             :         {
     445             :             ::std::vector<SwTxtAttr *> const marks(
     446             :                 rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
     447           0 :                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK));
     448           0 :             if (marks.size())
     449             :             {
     450           0 :                 if( pAny )
     451             :                 {   // hmm... can only return 1 here
     452           0 :                     const SwFmtRefMark& rRef = (*marks.begin())->GetRefMark();
     453           0 :                     uno::Reference< XTextContent >  xRef = SwXReferenceMarks::GetObject( rPam.GetDoc(), &rRef );
     454           0 :                     pAny->setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
     455             :                 }
     456             :             }
     457             :             else
     458           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     459             :         }
     460           0 :         break;
     461             :         case FN_UNO_NESTED_TEXT_CONTENT:
     462             :         {
     463             :             uno::Reference<XTextContent> const xRet(
     464           0 :                 GetNestedTextContent(*rPam.GetNode()->GetTxtNode(),
     465           0 :                     rPam.GetPoint()->nContent.GetIndex(), false));
     466           0 :             if (xRet.is())
     467             :             {
     468           0 :                 if (pAny)
     469             :                 {
     470           0 :                     (*pAny) <<= xRet;
     471             :                 }
     472             :             }
     473             :             else
     474             :             {
     475           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     476           0 :             }
     477             :         }
     478           0 :         break;
     479             :         case FN_UNO_CHARFMT_SEQUENCE:
     480             :         {
     481             : 
     482             :             SwTxtNode* pTxtNode;
     483           0 :             if((pTxtNode = (SwTxtNode*)rPam.GetNode( sal_True )) == rPam.GetNode(sal_False) &&
     484           0 :                     pTxtNode->GetpSwpHints())
     485             :             {
     486           0 :                 sal_uInt16 nPaMStart = rPam.GetPoint()->nContent.GetIndex();
     487           0 :                 sal_uInt16 nPaMEnd = rPam.GetMark() ? rPam.GetMark()->nContent.GetIndex() : nPaMStart;
     488           0 :                 if(nPaMStart > nPaMEnd)
     489             :                 {
     490           0 :                     sal_uInt16 nTmp = nPaMStart;
     491           0 :                     nPaMStart = nPaMEnd;
     492           0 :                     nPaMEnd = nTmp;
     493             :                 }
     494           0 :                 Sequence< ::rtl::OUString> aCharStyles;
     495           0 :                 SwpHints* pHints = pTxtNode->GetpSwpHints();
     496           0 :                 for(sal_uInt16 nAttr = 0; nAttr < pHints->GetStartCount(); nAttr++ )
     497             :                 {
     498           0 :                     SwTxtAttr* pAttr = pHints->GetStart( nAttr );
     499           0 :                     if(pAttr->Which() != RES_TXTATR_CHARFMT)
     500           0 :                         continue;
     501           0 :                     sal_uInt16 nAttrStart = *pAttr->GetStart();
     502           0 :                     sal_uInt16 nAttrEnd = *pAttr->GetEnd();
     503             :                     //check if the attribute touches the selection
     504           0 :                     if( ( nAttrEnd > nPaMStart && nAttrStart < nPaMEnd ) ||
     505             :                         ( !nAttrStart && !nAttrEnd && !nPaMStart && !nPaMEnd ) )
     506             :                     {
     507             :                         //check for overlapping
     508           0 :                         if(nAttrStart > nPaMStart ||
     509             :                                     nAttrEnd < nPaMEnd)
     510             :                         {
     511           0 :                             aCharStyles.realloc(0);
     512           0 :                             eNewState = PropertyState_AMBIGUOUS_VALUE;
     513           0 :                             break;
     514             :                         }
     515             :                         else
     516             :                         {
     517             :                             //now the attribute should start before or at the selection
     518             :                             //and it should end at the end of the selection or behind
     519             :                             OSL_ENSURE(nAttrStart <= nPaMStart && nAttrEnd >=nPaMEnd,
     520             :                                     "attribute overlaps or is outside");
     521             :                             //now the name of the style has to be added to the sequence
     522           0 :                             aCharStyles.realloc(aCharStyles.getLength() + 1);
     523             :                             OSL_ENSURE(pAttr->GetCharFmt().GetCharFmt(), "no character format set");
     524           0 :                             aCharStyles.getArray()[aCharStyles.getLength() - 1] =
     525             :                                         SwStyleNameMapper::GetProgName(
     526           0 :                                             pAttr->GetCharFmt().GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
     527             :                         }
     528             :                     }
     529             : 
     530             :                 }
     531             :                 eNewState =
     532           0 :                     aCharStyles.getLength() ?
     533           0 :                         PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
     534           0 :                 if(pAny)
     535           0 :                     (*pAny) <<= aCharStyles;
     536             :             }
     537             :             else
     538           0 :                 eNewState = PropertyState_DEFAULT_VALUE;
     539             :         }
     540           0 :         break;
     541             :         case RES_TXTATR_CHARFMT:
     542             :         // no break here!
     543         177 :         default: bDone = false;
     544             :     }
     545         809 :     if( bDone )
     546         632 :         eState = eNewState;
     547         809 :     return bDone;
     548             : };
     549             : 
     550           0 : sal_Int16 IsNodeNumStart(SwPaM& rPam, PropertyState& eState)
     551             : {
     552           0 :     const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode();
     553             :     // correction: check, if restart value is set at the text node and use
     554             :     // new method <SwTxtNode::GetAttrListRestartValue()> to retrieve the value
     555           0 :     if ( pTxtNd && pTxtNd->GetNumRule() && pTxtNd->IsListRestart() &&
     556           0 :          pTxtNd->HasAttrListRestartValue() )
     557             :     {
     558           0 :         eState = PropertyState_DIRECT_VALUE;
     559           0 :         sal_Int16 nTmp = sal::static_int_cast< sal_Int16 >(pTxtNd->GetAttrListRestartValue());
     560           0 :         return nTmp;
     561             :     }
     562           0 :     eState = PropertyState_DEFAULT_VALUE;
     563           0 :     return -1;
     564             : }
     565             : 
     566          29 : void setNumberingProperty(const Any& rValue, SwPaM& rPam)
     567             : {
     568          29 :     uno::Reference<XIndexReplace> xIndexReplace;
     569          29 :     if(rValue >>= xIndexReplace)
     570             :     {
     571          29 :         SwXNumberingRules* pSwNum = 0;
     572             : 
     573          29 :         uno::Reference<XUnoTunnel> xNumTunnel(xIndexReplace, UNO_QUERY);
     574          29 :         if(xNumTunnel.is())
     575             :         {
     576             :             pSwNum = reinterpret_cast< SwXNumberingRules * >(
     577          29 :                 sal::static_int_cast< sal_IntPtr >( xNumTunnel->getSomething( SwXNumberingRules::getUnoTunnelId() )));
     578             :         }
     579             : 
     580          29 :         if(pSwNum)
     581             :         {
     582          29 :             SwDoc* pDoc = rPam.GetDoc();
     583          29 :             if(pSwNum->GetNumRule())
     584             :             {
     585          29 :                 SwNumRule aRule(*pSwNum->GetNumRule());
     586          29 :                 const String* pNewCharStyles =  pSwNum->GetNewCharStyleNames();
     587          29 :                 const String* pBulletFontNames = pSwNum->GetBulletFontNames();
     588         319 :                 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
     589             :                 {
     590         290 :                     SwNumFmt aFmt(aRule.Get( i ));
     591        1156 :                     if( pNewCharStyles[i].Len() &&
     592         866 :                         !SwXNumberingRules::isInvalidStyle(pNewCharStyles[i]) &&
     593           0 :                         (!aFmt.GetCharFmt() || pNewCharStyles[i] != aFmt.GetCharFmt()->GetName()))
     594             :                     {
     595           0 :                         if(!pNewCharStyles[i].Len())
     596           0 :                             aFmt.SetCharFmt(0);
     597             :                         else
     598             :                         {
     599             : 
     600             :                             // get CharStyle and set the rule
     601           0 :                             sal_uInt16 nChCount = pDoc->GetCharFmts()->size();
     602           0 :                             SwCharFmt* pCharFmt = 0;
     603           0 :                             for(sal_uInt16 nCharFmt = 0; nCharFmt < nChCount; nCharFmt++)
     604             :                             {
     605           0 :                                 SwCharFmt& rChFmt = *((*(pDoc->GetCharFmts()))[nCharFmt]);
     606           0 :                                 if(rChFmt.GetName() == pNewCharStyles[i])
     607             :                                 {
     608           0 :                                     pCharFmt = &rChFmt;
     609           0 :                                     break;
     610             :                                 }
     611             :                             }
     612             : 
     613           0 :                             if(!pCharFmt)
     614             :                             {
     615           0 :                                 SfxStyleSheetBasePool* pPool = pDoc->GetDocShell()->GetStyleSheetPool();
     616             :                                 SfxStyleSheetBase* pBase;
     617           0 :                                 pBase = pPool->Find(pNewCharStyles[i], SFX_STYLE_FAMILY_CHAR);
     618             :                             // shall it really be created?
     619           0 :                                 if(!pBase)
     620           0 :                                     pBase = &pPool->Make(pNewCharStyles[i], SFX_STYLE_FAMILY_PAGE);
     621           0 :                                 pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
     622             :                             }
     623           0 :                             if(pCharFmt)
     624           0 :                                 aFmt.SetCharFmt(pCharFmt);
     625             :                         }
     626             :                     }
     627             :                     //Now again for fonts
     628        1160 :                     if(
     629         870 :                        !SwXNumberingRules::isInvalidStyle(pBulletFontNames[i]) &&
     630             :                        (
     631           0 :                         (pBulletFontNames[i].Len() && !aFmt.GetBulletFont()) ||
     632           0 :                         (pBulletFontNames[i].Len() &&
     633           0 :                             aFmt.GetBulletFont()->GetName() != pBulletFontNames[i])
     634             :                        )
     635             :                       )
     636             :                     {
     637             :                         const SvxFontListItem* pFontListItem =
     638           0 :                                 (const SvxFontListItem* )pDoc->GetDocShell()
     639           0 :                                                     ->GetItem( SID_ATTR_CHAR_FONTLIST );
     640           0 :                         const FontList*  pList = pFontListItem->GetFontList();
     641             : 
     642             :                         FontInfo aInfo = pList->Get(
     643           0 :                             pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
     644           0 :                         Font aFont(aInfo);
     645           0 :                         aFmt.SetBulletFont(&aFont);
     646             :                     }
     647         290 :                     aRule.Set( i, aFmt );
     648         290 :                 }
     649          29 :                 UnoActionContext aAction(pDoc);
     650             : 
     651          29 :                 if( rPam.GetNext() != &rPam )           // Multiple selection?
     652             :                 {
     653           0 :                     pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
     654           0 :                     SwPamRanges aRangeArr( rPam );
     655           0 :                     SwPaM aPam( *rPam.GetPoint() );
     656           0 :                     for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
     657             :                     {
     658             :                         // no start of a new list
     659           0 :                         pDoc->SetNumRule( aRangeArr.SetPam( n, aPam ), aRule, false );
     660             :                     }
     661           0 :                     pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
     662             :                 }
     663             :                 else
     664             :                 {
     665             :                     // no start of a new list
     666          29 :                     pDoc->SetNumRule( rPam, aRule, false );
     667          29 :                 }
     668             : 
     669             : 
     670             :             }
     671           0 :             else if(pSwNum->GetCreatedNumRuleName().Len())
     672             :             {
     673           0 :                 UnoActionContext aAction(pDoc);
     674           0 :                 SwNumRule* pRule = pDoc->FindNumRulePtr( pSwNum->GetCreatedNumRuleName() );
     675           0 :                 if(!pRule)
     676           0 :                     throw RuntimeException();
     677             :                 // no start of a new list
     678           0 :                 pDoc->SetNumRule( rPam, *pRule, false );
     679             :             }
     680             :             // #i103817#
     681             :             // outline numbering
     682             :             else
     683             :             {
     684           0 :                 UnoActionContext aAction(pDoc);
     685           0 :                 SwNumRule* pRule = pDoc->GetOutlineNumRule();
     686           0 :                 if(!pRule)
     687           0 :                     throw RuntimeException();
     688           0 :                 pDoc->SetNumRule( rPam, *pRule, false );
     689             :             }
     690          29 :         }
     691             :     }
     692           0 :     else if(rValue.getValueType() == ::getVoidCppuType())
     693             :     {
     694           0 :         rPam.GetDoc()->DelNumRules(rPam);
     695          29 :     }
     696          29 : }
     697             : 
     698         240 : void  getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny )
     699             : {
     700         240 :     const SwNumRule* pNumRule = rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() );
     701         240 :     if(pNumRule)
     702             :     {
     703           7 :         uno::Reference< XIndexReplace >  xNum = new SwXNumberingRules(*pNumRule);
     704           7 :         if ( pAny )
     705           7 :             pAny->setValue(&xNum, ::getCppuType((const uno::Reference<XIndexReplace>*)0));
     706           7 :         eState = PropertyState_DIRECT_VALUE;
     707             :     }
     708             :     else
     709         233 :         eState = PropertyState_DEFAULT_VALUE;
     710         240 : }
     711             : 
     712          13 : void GetCurPageStyle(SwPaM& rPaM, String &rString)
     713             : {
     714          13 :     const SwPageFrm* pPage = rPaM.GetCntntNode()->getLayoutFrm(rPaM.GetDoc()->GetCurrentLayout())->FindPageFrm();
     715          13 :     if(pPage)
     716          13 :         SwStyleNameMapper::FillProgName( pPage->GetPageDesc()->GetName(), rString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
     717          13 : }
     718             : 
     719             : /* --------------------------------------------------
     720             :  * reset special properties of the cursor
     721             :  * --------------------------------------------------*/
     722           0 : void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam)
     723             : {
     724           0 :     SwDoc* pDoc = rPam.GetDoc();
     725           0 :     switch(rEntry.nWID)
     726             :     {
     727             :         case FN_UNO_PARA_STYLE :
     728             : //          lcl_SetTxtFmtColl(aValue, pUnoCrsr);
     729           0 :         break;
     730             :         case FN_UNO_PAGE_STYLE :
     731           0 :         break;
     732             :         case FN_UNO_NUM_START_VALUE  :
     733             :         {
     734           0 :             UnoActionContext aAction(pDoc);
     735             : 
     736           0 :             if( rPam.GetNext() != &rPam )           // Multiple selection?
     737             :             {
     738           0 :                 pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
     739           0 :                 SwPamRanges aRangeArr( rPam );
     740           0 :                 SwPaM aPam( *rPam.GetPoint() );
     741           0 :                 for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
     742           0 :                     pDoc->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), 1 );
     743           0 :                 pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
     744             :             }
     745             :             else
     746           0 :                 pDoc->SetNodeNumStart( *rPam.GetPoint(), 0 );
     747             :         }
     748             : 
     749           0 :         break;
     750             :         case FN_UNO_NUM_LEVEL  :
     751           0 :         break;
     752             :         case FN_UNO_NUM_RULES:
     753             : //          lcl_setNumberingProperty(aValue, pUnoCrsr);
     754           0 :         break;
     755             :         case FN_UNO_CHARFMT_SEQUENCE:
     756             :         {
     757           0 :             std::set<sal_uInt16> aWhichIds;
     758           0 :             aWhichIds.insert( RES_TXTATR_CHARFMT);
     759           0 :             pDoc->ResetAttrs(rPam, true, aWhichIds);
     760             :         }
     761           0 :         break;
     762             :     }
     763           0 : }
     764             : 
     765           0 : void InsertFile(SwUnoCrsr* pUnoCrsr,
     766             :     const String& rURL,
     767             :     const uno::Sequence< beans::PropertyValue >& rOptions
     768             :     ) throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException )
     769             : {
     770           0 :     SfxMedium* pMed = 0;
     771           0 :     SwDoc* pDoc = pUnoCrsr->GetDoc();
     772           0 :     SwDocShell* pDocSh = pDoc->GetDocShell();
     773           0 :     comphelper::MediaDescriptor aMediaDescriptor( rOptions );
     774           0 :     ::rtl::OUString sFileName = rURL;
     775           0 :     ::rtl::OUString sFilterName, sFilterOptions, sPassword, sBaseURL;
     776           0 :     uno::Reference < io::XStream > xStream;
     777           0 :     uno::Reference < io::XInputStream > xInputStream;
     778             : 
     779           0 :     if( sFileName.isEmpty() )
     780           0 :         aMediaDescriptor[comphelper::MediaDescriptor::PROP_URL()] >>= sFileName;
     781           0 :     if( sFileName.isEmpty() )
     782           0 :         aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILENAME()] >>= sFileName;
     783           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
     784           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_STREAM()] >>= xStream;
     785           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
     786           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTERNAME()] >>= sFilterName;
     787           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTEROPTIONS()] >>= sFilterOptions;
     788           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_PASSWORD()] >>= sPassword;
     789           0 :     aMediaDescriptor[comphelper::MediaDescriptor::PROP_DOCUMENTBASEURL() ] >>= sBaseURL;
     790           0 :     if ( !xInputStream.is() && xStream.is() )
     791           0 :         xInputStream = xStream->getInputStream();
     792             : 
     793           0 :     if(!pDocSh || (sFileName.isEmpty() && !xInputStream.is()))
     794             :         return;
     795             : 
     796           0 :     SfxObjectFactory& rFact = pDocSh->GetFactory();
     797           0 :     const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( sFilterName );
     798           0 :     uno::Reference < embed::XStorage > xReadStorage;
     799           0 :     if( xInputStream.is() )
     800             :     {
     801           0 :         uno::Sequence< uno::Any > aArgs( 2 );
     802           0 :         aArgs[0] <<= xInputStream;
     803           0 :         aArgs[1] <<= embed::ElementModes::READ;
     804             :         try
     805             :         {
     806             :             xReadStorage = uno::Reference< embed::XStorage >(
     807           0 :                             ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ),
     808           0 :                             uno::UNO_QUERY );
     809             :         }
     810           0 :         catch( const io::IOException& rEx)
     811             :         {
     812             :             (void)rEx;
     813           0 :         }
     814             :     }
     815           0 :     if ( !pFilter )
     816             :     {
     817           0 :         if( xInputStream.is() && !xReadStorage.is())
     818             :         {
     819           0 :             pMed = new SfxMedium;
     820           0 :             pMed->setStreamToLoadFrom(xInputStream, sal_True );
     821             :         }
     822             :         else
     823           0 :             pMed = xReadStorage.is() ?
     824           0 :                 new SfxMedium(xReadStorage, sBaseURL, 0 ) :
     825           0 :                 new SfxMedium(sFileName, STREAM_READ, 0, 0 );
     826           0 :         if( !sBaseURL.isEmpty() )
     827           0 :             pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
     828             : 
     829           0 :         SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
     830           0 :         ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
     831           0 :         if ( nErr || !pFilter)
     832           0 :             DELETEZ(pMed);
     833             :         else
     834           0 :             pMed->SetFilter( pFilter );
     835             :     }
     836             :     else
     837             :     {
     838           0 :         if(!pMed)
     839             :         {
     840           0 :             if( xInputStream.is() && !xReadStorage.is())
     841             :             {
     842           0 :                 pMed = new SfxMedium;
     843           0 :                 pMed->setStreamToLoadFrom(xInputStream, sal_True );
     844           0 :                 pMed->SetFilter( pFilter );
     845             :             }
     846             :             else
     847             :             {
     848           0 :                 if( xReadStorage.is() )
     849             :                 {
     850           0 :                     pMed = new SfxMedium(xReadStorage, sBaseURL, 0 );
     851           0 :                     pMed->SetFilter( pFilter );
     852             :                 }
     853             :                 else
     854           0 :                     pMed = new SfxMedium(sFileName, STREAM_READ, pFilter, 0);
     855             :             }
     856             :         }
     857           0 :         if(!sFilterOptions.isEmpty())
     858           0 :             pMed->GetItemSet()->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sFilterOptions ) );
     859           0 :         if(!sBaseURL.isEmpty())
     860           0 :             pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
     861             :     }
     862             : 
     863           0 :     if( !pMed )
     864             :         return;
     865             : 
     866             :     // this sourcecode is not responsible for the lifetime of the shell, SfxObjectShellLock should not be used
     867           0 :     SfxObjectShellRef aRef( pDocSh );
     868             : 
     869           0 :     pMed->DownLoad();   // if necessary: start the download
     870           0 :     if( aRef.Is() && 1 < aRef->GetRefCount() )  // Ref still valid?
     871             :     {
     872             :         SwReader* pRdr;
     873           0 :         SfxItemSet* pSet =  pMed->GetItemSet();
     874           0 :         pSet->Put(SfxBoolItem(FN_API_CALL, sal_True));
     875           0 :         if(!sPassword.isEmpty())
     876           0 :             pSet->Put(SfxStringItem(SID_PASSWORD, sPassword));
     877           0 :         Reader *pRead = pDocSh->StartConvertFrom( *pMed, &pRdr, 0, pUnoCrsr);
     878           0 :         if( pRead )
     879             :         {
     880             : 
     881           0 :             UnoActionContext aContext(pDoc);
     882             : 
     883           0 :             if(pUnoCrsr->HasMark())
     884           0 :                 pDoc->DeleteAndJoin(*pUnoCrsr);
     885             : 
     886           0 :             SwNodeIndex aSave(  pUnoCrsr->GetPoint()->nNode, -1 );
     887           0 :             xub_StrLen nCntnt = pUnoCrsr->GetPoint()->nContent.GetIndex();
     888             : 
     889           0 :             sal_uInt32 nErrno = pRdr->Read( *pRead );   // and paste the document
     890             : 
     891           0 :             if(!nErrno)
     892             :             {
     893           0 :                 ++aSave;
     894           0 :                 pUnoCrsr->SetMark();
     895           0 :                 pUnoCrsr->GetMark()->nNode = aSave;
     896             : 
     897           0 :                 SwCntntNode* pCntNode = aSave.GetNode().GetCntntNode();
     898           0 :                 if( !pCntNode )
     899           0 :                     nCntnt = 0;
     900           0 :                 pUnoCrsr->GetMark()->nContent.Assign( pCntNode, nCntnt );
     901             :             }
     902             : 
     903           0 :             delete pRdr;
     904             : 
     905             : 
     906             :         }
     907             :     }
     908           0 :     delete pMed;
     909             : }
     910             : 
     911             : // insert text and scan for CR characters in order to insert
     912             : // paragraph breaks at those positions by calling SplitNode
     913         662 : bool DocInsertStringSplitCR(
     914             :         SwDoc &rDoc,
     915             :         const SwPaM &rNewCursor, const String &rText,
     916             :         const bool bForceExpandHints )
     917             : {
     918         662 :     bool bOK = true;
     919             : 
     920             :         const enum IDocumentContentOperations::InsertFlags nInsertFlags =
     921             :             (bForceExpandHints)
     922             :             ? static_cast<IDocumentContentOperations::InsertFlags>(
     923             :                     IDocumentContentOperations::INS_FORCEHINTEXPAND |
     924             :                     IDocumentContentOperations::INS_EMPTYEXPAND)
     925         662 :             : IDocumentContentOperations::INS_EMPTYEXPAND;
     926             : 
     927             :     // grouping done in InsertString is intended for typing, not API calls
     928         662 :     ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
     929         662 :     OUString aTxt;
     930         662 :     xub_StrLen nStartIdx = 0;
     931             :     SwTxtNode* const pTxtNd =
     932         662 :         rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode();
     933             :     const xub_StrLen nMaxLength = ( pTxtNd )
     934         662 :         ? STRING_LEN - pTxtNd->GetTxt().Len()
     935        1324 :         : STRING_LEN;
     936         662 :     xub_StrLen nIdx = rText.Search( '\r', nStartIdx );
     937         662 :     if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) ||
     938             :         ( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) )
     939             :     {
     940           0 :         nIdx = nMaxLength;
     941             :     }
     942        1324 :     while (nIdx != STRING_NOTFOUND )
     943             :     {
     944             :         OSL_ENSURE( nIdx - nStartIdx >= 0, "index negative!" );
     945           0 :         aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx );
     946           0 :         if (!aTxt.isEmpty() &&
     947           0 :             !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
     948             :         {
     949             :             OSL_FAIL( "Doc->Insert(Str) failed." );
     950           0 :             bOK = false;
     951             :         }
     952           0 :         if (!rDoc.SplitNode( *rNewCursor.GetPoint(), false ) )
     953             :         {
     954             :             OSL_FAIL( "SplitNode failed" );
     955           0 :             bOK = false;
     956             :         }
     957           0 :         nStartIdx = nIdx + 1;
     958           0 :         nIdx = rText.Search( '\r', nStartIdx );
     959             :     }
     960         662 :     aTxt = rText.Copy( nStartIdx );
     961        2648 :     if (!aTxt.isEmpty() &&
     962        1986 :         !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
     963             :     {
     964             :         OSL_FAIL( "Doc->Insert(Str) failed." );
     965           0 :         bOK = false;
     966             :     }
     967             : 
     968         662 :     return bOK;
     969             : }
     970             : 
     971           2 : void makeRedline( SwPaM& rPaM,
     972             :     const ::rtl::OUString& rRedlineType,
     973             :     const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
     974             :         throw (lang::IllegalArgumentException, uno::RuntimeException)
     975             : {
     976           2 :     IDocumentRedlineAccess* pRedlineAccess = rPaM.GetDoc();
     977             : 
     978           2 :     RedlineType_t eType = nsRedlineType_t::REDLINE_INSERT;
     979           2 :     if ( rRedlineType == "Delete" )
     980           2 :         eType = nsRedlineType_t::REDLINE_DELETE;
     981           0 :     else if ( rRedlineType == "Format" )
     982           0 :         eType = nsRedlineType_t::REDLINE_FORMAT;
     983           0 :     else if ( rRedlineType == "TextTable" )
     984           0 :         eType = nsRedlineType_t::REDLINE_TABLE;
     985           0 :     else if( !rRedlineType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Insert" ) ))
     986           0 :         throw lang::IllegalArgumentException();
     987             : 
     988             :     //todo: what about REDLINE_FMTCOLL?
     989           2 :     comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
     990           2 :     uno::Any aAuthorValue;
     991           2 :     aAuthorValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RedlineAuthor")), aAuthorValue);
     992           2 :     sal_uInt16 nAuthor = 0;
     993           2 :     ::rtl::OUString sAuthor;
     994           2 :     if( aAuthorValue >>= sAuthor )
     995           2 :         nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor);
     996             : 
     997           2 :     ::rtl::OUString sComment;
     998           2 :     uno::Any aCommentValue;
     999           2 :     aCommentValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RedlineComment")), aCommentValue);
    1000             : 
    1001           2 :     SwRedlineData aRedlineData( eType, nAuthor );
    1002           2 :     if( aCommentValue >>= sComment )
    1003           0 :         aRedlineData.SetComment( sComment );
    1004             : 
    1005           2 :     ::util::DateTime aStamp;
    1006           2 :     uno::Any aDateTimeValue;
    1007           2 :     aDateTimeValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RedlineDateTime")), aDateTimeValue);
    1008           2 :     if( aDateTimeValue >>= aStamp )
    1009             :     {
    1010             :        aRedlineData.SetTimeStamp(
    1011           2 :         DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
    1012             :     }
    1013             : 
    1014           2 :     SwRedline* pRedline = new SwRedline( aRedlineData, rPaM );
    1015           2 :     RedlineMode_t nPrevMode = pRedlineAccess->GetRedlineMode( );
    1016             : 
    1017           2 :     pRedlineAccess->SetRedlineMode_intern(nsRedlineMode_t::REDLINE_ON);
    1018           2 :     bool bRet = pRedlineAccess->AppendRedline( pRedline, false );
    1019           2 :     pRedlineAccess->SetRedlineMode_intern( nPrevMode );
    1020           2 :     if( !bRet )
    1021           0 :         throw lang::IllegalArgumentException();
    1022           2 : }
    1023             : 
    1024         386 : SwAnyMapHelper::~SwAnyMapHelper()
    1025             : {
    1026         193 :     AnyMapHelper_t::iterator aIt = begin();
    1027        1901 :     while( aIt != end() )
    1028             :     {
    1029        1515 :         delete ( aIt->second );
    1030        1515 :         ++aIt;
    1031             :     }
    1032         193 : }
    1033             : 
    1034        1545 : void SwAnyMapHelper::SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rAny )
    1035             : {
    1036        1545 :     sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
    1037        1545 :     AnyMapHelper_t::iterator aIt = find( nKey );
    1038        1545 :     if( aIt != end() )
    1039             :     {
    1040          30 :         *(aIt->second) = rAny;
    1041             :     }
    1042             :     else
    1043        1515 :         insert( value_type(nKey, new uno::Any( rAny )) );
    1044        1545 : }
    1045             : 
    1046       13819 : bool    SwAnyMapHelper::FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& pAny )
    1047             : {
    1048       13819 :     bool bRet = false;
    1049       13819 :     sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
    1050       13819 :     AnyMapHelper_t::iterator aIt = find( nKey );
    1051       13819 :     if( aIt != end() )
    1052             :     {
    1053        1679 :         pAny = aIt->second;
    1054        1679 :         bRet = true;
    1055             :     }
    1056       13819 :     return bRet;
    1057             : }
    1058             : 
    1059             : }//namespace SwUnoCursorHelper
    1060             : 
    1061             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10