Files
libreoffice/sw/source/core/unocore/unoobj.cxx

2355 lines
84 KiB
C++
Raw Normal View History

2000-09-18 23:08:29 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 23:08:29 +00:00
*
* Copyright 2008 by Sun Microsystems, Inc.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 23:08:29 +00:00
*
* $RCSfile: unoobj.cxx,v $
* $Revision: 1.110 $
2000-09-18 23:08:29 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 23:08:29 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 23:08:29 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 23:08:29 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"
2000-09-18 23:08:29 +00:00
#include <osl/endian.h>
2000-09-18 23:08:29 +00:00
#include <rtl/ustrbuf.hxx>
#include <swtypes.hxx>
#include <hintids.hxx>
#include <cmdid.h>
#include <hints.hxx>
#include <bookmrk.hxx>
#include <frmfmt.hxx>
#include <doc.hxx>
#include <istyleaccess.hxx>
2000-09-18 23:08:29 +00:00
#include <ndtxt.hxx>
#include <ndnotxt.hxx>
#include <unocrsrhelper.hxx>
2000-09-18 23:08:29 +00:00
#include <swundo.hxx>
#include <rootfrm.hxx>
#include <flyfrm.hxx>
#include <ftnidx.hxx>
#include <sfx2/linkmgr.hxx>
2000-09-18 23:08:29 +00:00
#include <docary.hxx>
#include <paratr.hxx>
#include <tools/urlobj.hxx>
#include <pam.hxx>
#include <tools/cachestr.hxx>
#include <shellio.hxx>
#include <swerror.h>
#include <swtblfmt.hxx>
2001-02-19 07:04:57 +00:00
#include <fmtruby.hxx>
2000-09-18 23:08:29 +00:00
#include <fmthbsh.hxx>
#include <docsh.hxx>
#include <docstyle.hxx>
#include <charfmt.hxx>
#include <txtfld.hxx>
#include <fmtfld.hxx>
#include <fmtpdsc.hxx>
#include <pagedesc.hxx>
#ifndef _POOLFMT_HRC
#include <poolfmt.hrc>
#endif
#include <poolfmt.hxx>
#include <edimp.hxx>
#include <fchrfmt.hxx>
#include <fmtautofmt.hxx>
2000-09-18 23:08:29 +00:00
#include <cntfrm.hxx>
#include <pagefrm.hxx>
#include <doctxm.hxx>
2000-09-18 23:08:29 +00:00
#include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx>
#include <sfx2/fcontnr.hxx>
#include <fmtrfmrk.hxx>
#include <txtrfmrk.hxx>
#include <unoclbck.hxx>
#include <unoobj.hxx>
#include <unomap.hxx>
#include <unosett.hxx>
#include <unoprnms.hxx>
#include <unotbl.hxx>
#include <unodraw.hxx>
#include <unocoll.hxx>
#include <unostyle.hxx>
#include <unofield.hxx>
#include <fmtanchr.hxx>
#include <svx/flstitem.hxx>
#include <svtools/ctrltool.hxx>
#include <flypos.hxx>
#include <txtftn.hxx>
#include <fmtftn.hxx>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/style/PageStyleLayout.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
2000-10-20 07:57:03 +00:00
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
2000-09-18 23:08:29 +00:00
#include <unoidx.hxx>
#include <unoframe.hxx>
#include <fmthdft.hxx>
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx>
#include <fmtflcnt.hxx>
#define _SVSTDARR_USHORTS
#define _SVSTDARR_USHORTSSORT
#include <svtools/svstdarr.hxx>
#include <svx/brshitem.hxx>
#include <fmtclds.hxx>
2000-10-20 07:57:03 +00:00
#include <dcontact.hxx>
#include <SwStyleNameMapper.hxx>
#include <crsskip.hxx>
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#include <memory>
2000-09-18 23:08:29 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
2000-09-18 23:08:29 +00:00
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::beans;
2000-10-20 07:57:03 +00:00
using namespace ::com::sun::star::drawing;
using std::auto_ptr;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
2000-09-18 23:08:29 +00:00
/****************************************************************************
static methods
****************************************************************************/
uno::Sequence< sal_Int8 > CreateUnoTunnelId()
2000-09-18 23:08:29 +00:00
{
static osl::Mutex aCreateMutex;
osl::Guard<osl::Mutex> aGuard( aCreateMutex );
uno::Sequence< sal_Int8 > aSeq( 16 );
rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
return aSeq;
}
/****************************************************************************
Hilfsklassen
****************************************************************************/
SwParaSelection::SwParaSelection(SwUnoCrsr* pCrsr) :
pUnoCrsr(pCrsr)
{
if(pUnoCrsr->HasMark())
pUnoCrsr->DeleteMark();
// steht er schon am Anfang?
if(pUnoCrsr->GetPoint()->nContent != 0)
pUnoCrsr->MovePara(fnParaCurr, fnParaStart);
// oder gleichzeitig am Ende?
if(pUnoCrsr->GetPoint()->nContent != pUnoCrsr->GetCntntNode()->Len())
{
pUnoCrsr->SetMark();
pUnoCrsr->MovePara(fnParaCurr, fnParaEnd);
}
}
SwParaSelection::~SwParaSelection()
{
if(pUnoCrsr->GetPoint()->nContent != 0)
{
pUnoCrsr->DeleteMark();
pUnoCrsr->MovePara(fnParaCurr, fnParaStart);
}
}
/* -----------------13.05.98 12:15-------------------
*
* --------------------------------------------------*/
SwUnoInternalPaM::SwUnoInternalPaM(SwDoc& rDoc) :
SwPaM(rDoc.GetNodes())
{
}
SwUnoInternalPaM::~SwUnoInternalPaM()
{
while( GetNext() != this)
{
delete GetNext();
}
}
SwUnoInternalPaM& SwUnoInternalPaM::operator=(const SwPaM& rPaM)
{
const SwPaM* pTmp = &rPaM;
*GetPoint() = *rPaM.GetPoint();
if(rPaM.HasMark())
{
SetMark();
*GetMark() = *rPaM.GetMark();
}
else
DeleteMark();
while(&rPaM != (pTmp = (const SwPaM*)pTmp->GetNext()))
{
if(pTmp->HasMark())
new SwPaM(*pTmp->GetMark(), *pTmp->GetPoint(), this);
else
new SwPaM(*pTmp->GetPoint(), this);
}
return *this;
}
/****************************************************************************
ActionContext
****************************************************************************/
UnoActionContext::UnoActionContext(SwDoc* pDc) :
pDoc(pDc)
{
SwRootFrm* pRootFrm = pDoc->GetRootFrm();
if(pRootFrm)
pRootFrm->StartAllAction();
}
/*-----------------04.03.98 11:56-------------------
--------------------------------------------------*/
UnoActionContext::~UnoActionContext()
{
//das Doc kann hier schon entfernt worden sein
if(pDoc)
{
SwRootFrm* pRootFrm = pDoc->GetRootFrm();
if(pRootFrm)
pRootFrm->EndAllAction();
}
}
/****************************************************************************
ActionRemoveContext
****************************************************************************/
UnoActionRemoveContext::UnoActionRemoveContext(SwDoc* pDc) :
pDoc(pDc)
{
SwRootFrm* pRootFrm = pDoc->GetRootFrm();
if(pRootFrm)
pRootFrm->UnoRemoveAllActions();
}
/* -----------------07.07.98 12:05-------------------
*
* --------------------------------------------------*/
UnoActionRemoveContext::~UnoActionRemoveContext()
{
SwRootFrm* pRootFrm = pDoc->GetRootFrm();
if(pRootFrm)
pRootFrm->UnoRestoreAllActions();
}
/*-----------------09.03.98 08:29-------------------
--------------------------------------------------*/
void SwXTextCursor::SelectPam(SwPaM& rCrsr, sal_Bool bExpand)
{
if(bExpand)
{
if(!rCrsr.HasMark())
rCrsr.SetMark();
}
else if(rCrsr.HasMark())
rCrsr.DeleteMark();
}
2000-09-18 23:08:29 +00:00
/* -----------------20.05.98 14:59-------------------
*
* --------------------------------------------------*/
void SwXTextCursor::getTextFromPam(SwPaM& aCrsr, OUString& rBuffer)
{
if(!aCrsr.HasMark())
return;
SvCacheStream aStream( 20480 );
#ifdef OSL_BIGENDIAN
aStream.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
#else
aStream.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
#endif
2000-09-18 23:08:29 +00:00
WriterRef xWrt;
// TODO/MBA: looks like a BaseURL doesn't make sense here
SwIoSystem::GetWriter( C2S(FILTER_TEXT_DLG), String(), xWrt );
2000-09-18 23:08:29 +00:00
if( xWrt.Is() )
{
SwWriter aWriter( aStream, aCrsr );
2000-09-18 23:08:29 +00:00
xWrt->bASCII_NoLastLineEnd = sal_True;
SwAsciiOptions aOpt = xWrt->GetAsciiOptions();
aOpt.SetCharSet( RTL_TEXTENCODING_UNICODE );
xWrt->SetAsciiOptions( aOpt );
xWrt->bUCS2_WithStartChar = FALSE;
// --> FME #i68522#
const BOOL bOldShowProgress = xWrt->bShowProgress;
xWrt->bShowProgress = FALSE;
// <--
2000-09-18 23:08:29 +00:00
long lLen;
if( !IsError( aWriter.Write( xWrt ) ) &&
0x7ffffff > (( lLen = aStream.GetSize() )
/ sizeof( sal_Unicode )) + 1 )
2000-09-18 23:08:29 +00:00
{
aStream << (sal_Unicode)'\0';
long lUniLen = (lLen / sizeof( sal_Unicode ));
::rtl::OUStringBuffer aStrBuffer( lUniLen );
aStream.Seek( 0 );
aStream.ResetError();
while(lUniLen)
2000-09-18 23:08:29 +00:00
{
String sBuf;
sal_Int32 nLocalLen = 0;
if( lUniLen >= STRING_MAXLEN )
nLocalLen = STRING_MAXLEN - 1;
else
nLocalLen = lUniLen;
sal_Unicode* pStrBuf = sBuf.AllocBuffer( xub_StrLen( nLocalLen + 1));
aStream.Read( pStrBuf, 2 * nLocalLen );
pStrBuf[ nLocalLen ] = '\0';
aStrBuffer.append( pStrBuf, nLocalLen );
lUniLen -= nLocalLen;
2000-09-18 23:08:29 +00:00
}
rBuffer = aStrBuffer.makeStringAndClear();
2000-09-18 23:08:29 +00:00
}
xWrt->bShowProgress = bOldShowProgress;
2000-09-18 23:08:29 +00:00
}
}
/* -----------------06.07.98 07:33-------------------
*
* --------------------------------------------------*/
void lcl_setCharStyle(SwDoc* pDoc, const uno::Any aValue, SfxItemSet& rSet)
throw (lang::IllegalArgumentException)
{
SwDocShell* pDocSh = pDoc->GetDocShell();
if(pDocSh)
{
OUString uStyle;
aValue >>= uStyle;
String sStyle;
SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2000-09-18 23:08:29 +00:00
SwDocStyleSheet* pStyle =
(SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
if(pStyle)
{
SwFmtCharFmt aFmt(pStyle->GetCharFmt());
rSet.Put(aFmt);
}
else
{
throw lang::IllegalArgumentException();
}
}
};
/* -----------------08.06.06 10:43-------------------
*
* --------------------------------------------------*/
void lcl_setAutoStyle(IStyleAccess& rStyleAccess, const uno::Any aValue, SfxItemSet& rSet, bool bPara )
throw (lang::IllegalArgumentException)
{
OUString uStyle;
aValue >>= uStyle;
String sStyle;
StylePool::SfxItemSet_Pointer_t pStyle = bPara ?
rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ):
rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR );
if(pStyle.get())
{
SwFmtAutoFmt aFmt( bPara ? sal::static_int_cast< USHORT >(RES_AUTO_STYLE)
: sal::static_int_cast< USHORT >(RES_TXTATR_AUTOFMT) );
aFmt.SetStyleHandle( pStyle );
rSet.Put(aFmt);
}
else
{
throw lang::IllegalArgumentException();
}
};
2000-09-18 23:08:29 +00:00
/* -----------------30.06.98 08:46-------------------
*
* --------------------------------------------------*/
void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM)
throw (lang::IllegalArgumentException)
{
SwDoc* pDoc = rPaM.GetDoc();
SwDocShell* pDocSh = pDoc->GetDocShell();
if(!pDocSh)
return;
OUString uStyle;
rAny >>= uStyle;
String sStyle;
SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
2000-09-18 23:08:29 +00:00
SwDocStyleSheet* pStyle =
(SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_PARA);
if(pStyle)
{
SwTxtFmtColl *pLocal = pStyle->GetCollection();
UnoActionContext aAction(pDoc);
pDoc->StartUndo( UNDO_START, NULL );
2000-09-18 23:08:29 +00:00
FOREACHUNOPAM_START(&rPaM)
pDoc->SetTxtFmtColl(*PUNOPAM, pLocal);
FOREACHUNOPAM_END()
pDoc->EndUndo( UNDO_END, NULL );
2000-09-18 23:08:29 +00:00
}
else
{
throw lang::IllegalArgumentException();
}
}
/* -----------------06.07.98 07:38-------------------
*
* --------------------------------------------------*/
void lcl_setPageDesc(SwDoc* pDoc, const uno::Any& aValue, SfxItemSet& rSet)
{
if(aValue.getValueType() != ::getCppuType((const OUString*)0))
return;
SwFmtPageDesc *pNewDesc = 0 ;
2000-09-18 23:08:29 +00:00
const SfxPoolItem* pItem;
if(SFX_ITEM_SET == rSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
{
pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
}
if(!pNewDesc)
pNewDesc = new SwFmtPageDesc();
OUString uDescName;
aValue >>= uDescName;
String sDescName;
SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2000-09-18 23:08:29 +00:00
if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
{
sal_Bool bPut = sal_False;
if(sDescName.Len())
{
SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName);
if(pPageDesc)
{
pPageDesc->Add( pNewDesc );
bPut = sal_True;
}
else
{
throw lang::IllegalArgumentException();
}
}
if(!bPut)
{
rSet.ClearItem(RES_BREAK);
rSet.Put(SwFmtPageDesc());
}
else
rSet.Put(*pNewDesc);
}
delete pNewDesc;
}
/* -----------------30.06.98 10:29-------------------
*
* --------------------------------------------------*/
void lcl_SetNodeNumStart( SwPaM& rCrsr, uno::Any aValue )
{
sal_Int16 nTmp = 1;
2000-09-18 23:08:29 +00:00
aValue >>= nTmp;
sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : (sal_uInt16)nTmp);
SwDoc* pDoc = rCrsr.GetDoc();
UnoActionContext aAction(pDoc);
if( rCrsr.GetNext() != &rCrsr ) // Mehrfachselektion ?
{
pDoc->StartUndo( UNDO_START, NULL );
2000-09-18 23:08:29 +00:00
SwPamRanges aRangeArr( rCrsr );
SwPaM aPam( *rCrsr.GetPoint() );
for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
{
pDoc->SetNumRuleStart(*aRangeArr.SetPam( n, aPam ).GetPoint());
pDoc->SetNodeNumStart(*aRangeArr.SetPam( n, aPam ).GetPoint(),
nStt );
}
pDoc->EndUndo( UNDO_END, NULL);
2000-09-18 23:08:29 +00:00
}
else
{
pDoc->SetNumRuleStart( *rCrsr.GetPoint());
2000-09-18 23:08:29 +00:00
pDoc->SetNodeNumStart( *rCrsr.GetPoint(), nStt );
}
2000-09-18 23:08:29 +00:00
}
/* -----------------17.09.98 09:44-------------------
*
* --------------------------------------------------*/
sal_Bool lcl_setCrsrPropertyValue(const SfxItemPropertyMap* pMap,
SwPaM& rPam,
SfxItemSet& rItemSet,
const uno::Any& aValue ) throw (lang::IllegalArgumentException)
2000-09-18 23:08:29 +00:00
{
sal_Bool bRet = sal_True;
if(0 ==(pMap->nFlags&PropertyAttribute::MAYBEVOID) &&
aValue.getValueType() == ::getCppuVoidType())
2000-09-18 23:08:29 +00:00
bRet = sal_False;
else
{
switch(pMap->nWID)
{
case RES_TXTATR_CHARFMT:
lcl_setCharStyle(rPam.GetDoc(), aValue, rItemSet );
2000-09-18 23:08:29 +00:00
break;
case RES_TXTATR_AUTOFMT:
lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, false );
break;
case FN_UNO_CHARFMT_SEQUENCE:
{
Sequence<OUString> aCharStyles;
if(aValue >>= aCharStyles)
{
for(sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++)
{
Any aStyle;
rPam.GetDoc()->StartUndo( UNDO_START, NULL);
aStyle <<= aCharStyles.getConstArray()[nStyle];
//create a local set and apply each format directly
SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT );
lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet );
//the first style should replace the current attributes, all other have to be added
SwXTextCursor::SetCrsrAttr(rPam, aSet, nStyle ? CRSR_ATTR_MODE_DONTREPLACE : 0);
rPam.GetDoc()->EndUndo( UNDO_START, NULL );
}
}
else
bRet = sal_False;
}
break;
2000-09-18 23:08:29 +00:00
case FN_UNO_PARA_STYLE :
lcl_SetTxtFmtColl(aValue, rPam);
break;
case RES_AUTO_STYLE:
lcl_setAutoStyle(rPam.GetDoc()->GetIStyleAccess(), aValue, rItemSet, true );
break;
2000-09-18 23:08:29 +00:00
case FN_UNO_PAGE_STYLE :
break;
case FN_UNO_NUM_START_VALUE :
lcl_SetNodeNumStart( rPam, aValue );
break;
case FN_UNO_PARA_CHAPTER_NUMBERING_LEVEL:
{
/* Will be used in OOo 3.0
SwTxtNode * pTmpNode = rPam.GetNode()->GetTxtNode();
BYTE nLevel;
aValue >>= nLevel;
if ( pTmpNode )
{
pTmpNode->SetOutlineLevel(nLevel);
// --> OD 2005-09-01 #i53198# - update outline nodes array
rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode );
// <--
}*/
}
break;
2000-09-18 23:08:29 +00:00
case FN_UNO_NUM_LEVEL :
case FN_UNO_IS_NUMBER :
{
// multi selection is not considered
2000-09-18 23:08:29 +00:00
SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode();
// --> OD 2008-05-14 #refactorlists# - check on list style not needed
// const SwNumRule* pRule = pTxtNd->GetNumRule();
// if( FN_UNO_NUM_LEVEL == pMap->nWID && pRule != NULL )
if ( FN_UNO_NUM_LEVEL == pMap->nWID )
// <--
2000-09-18 23:08:29 +00:00
{
sal_Int16 nLevel = 0;
aValue >>= nLevel;
2000-09-18 23:08:29 +00:00
pTxtNd->SetAttrListLevel(nLevel);
}
else if( FN_UNO_IS_NUMBER == pMap->nWID )
{
BOOL bIsNumber = *(sal_Bool*) aValue.getValue();
if(!bIsNumber)
pTxtNd->SetCountedInList( false );
2000-09-18 23:08:29 +00:00
}
//PROPERTY_MAYBEVOID!
}
break;
case FN_NUMBER_NEWSTART :
{
sal_Bool bVal = sal_False;
if (aValue >>= bVal)
rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal);
else
throw lang::IllegalArgumentException();
}
break;
2000-09-18 23:08:29 +00:00
case FN_UNO_NUM_RULES:
SwUnoCursorHelper::setNumberingProperty(aValue, rPam);
2000-09-18 23:08:29 +00:00
break;
case RES_PARATR_DROP:
{
if( MID_DROPCAP_CHAR_STYLE_NAME == pMap->nMemberId)
{
2001-02-19 07:04:57 +00:00
OUString uStyle;
if(aValue >>= uStyle)
2000-09-18 23:08:29 +00:00
{
String sStyle;
SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
SwDoc* pDoc = rPam.GetDoc();
//default character style mustn't be set as default format
2000-09-18 23:08:29 +00:00
SwDocStyleSheet* pStyle =
(SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
SwFmtDrop* pDrop = 0;
if(pStyle &&
((SwDocStyleSheet*)pStyle)->GetCharFmt() != pDoc->GetDfltCharFmt())
{
const SfxPoolItem* pItem;
if(SFX_ITEM_SET == rItemSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) )
pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
if(!pDrop)
pDrop = new SwFmtDrop();
rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pStyle ) );
pDrop->SetCharFmt(xStyle->GetCharFmt());
}
2000-09-18 23:08:29 +00:00
else
throw lang::IllegalArgumentException();
rItemSet.Put(*pDrop);
2000-09-18 23:08:29 +00:00
delete pDrop;
}
else
throw lang::IllegalArgumentException();
}
else
bRet = sal_False;
}
break;
2001-02-19 07:04:57 +00:00
case RES_TXTATR_CJK_RUBY:
if(MID_RUBY_CHARSTYLE == pMap->nMemberId )
{
OUString sTmp;
if(aValue >>= sTmp)
{
SwFmtRuby* pRuby = 0;
const SfxPoolItem* pItem;
if(SFX_ITEM_SET == rItemSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) )
2001-02-19 07:04:57 +00:00
pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
if(!pRuby)
pRuby = new SwFmtRuby(aEmptyStr);
String sStyle;
SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
pRuby->SetCharFmtName( sStyle );
2001-02-19 07:04:57 +00:00
pRuby->SetCharFmtId( 0 );
if(sStyle.Len() > 0)
2001-02-19 07:04:57 +00:00
{
sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
2001-02-19 07:04:57 +00:00
pRuby->SetCharFmtId(nId);
}
rItemSet.Put(*pRuby);
2001-02-19 07:04:57 +00:00
delete pRuby;
}
else
throw lang::IllegalArgumentException();
bRet = sal_True;
2001-02-19 07:04:57 +00:00
}
else
bRet = sal_False;
2001-02-19 07:04:57 +00:00
break;
2000-09-18 23:08:29 +00:00
case RES_PAGEDESC :
if(MID_PAGEDESC_PAGEDESCNAME == pMap->nMemberId )
{
lcl_setPageDesc(rPam.GetDoc(), aValue, rItemSet);
2000-09-18 23:08:29 +00:00
break;
}
//hier kein break
default: bRet = sal_False;
}
}
return bRet;
}
/* -----------------30.06.98 08:39-------------------
*
* --------------------------------------------------*/
SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional)
{
static const sal_uInt16 nMaxLookup = 1000;
2000-09-18 23:08:29 +00:00
SwFmtColl *pFmt = 0;
// if ( GetCrsrCnt() > nMaxLookup )
// return 0;
sal_Bool bError = sal_False;
FOREACHUNOPAM_START(&rPam)
ULONG nSttNd = PUNOPAM->GetMark()->nNode.GetIndex(),
2000-09-18 23:08:29 +00:00
nEndNd = PUNOPAM->GetPoint()->nNode.GetIndex();
xub_StrLen nSttCnt = PUNOPAM->GetMark()->nContent.GetIndex(),
nEndCnt = PUNOPAM->GetPoint()->nContent.GetIndex();
if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
{
sal_uInt32 nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
nTmp = nSttCnt; nSttCnt = nEndCnt; nEndCnt = (sal_uInt16)nTmp;
}
if( nEndNd - nSttNd >= nMaxLookup )
{
pFmt = 0;
break;
}
const SwNodes& rNds = rPam.GetDoc()->GetNodes();
for( ULONG n = nSttNd; n <= nEndNd; ++n )
2000-09-18 23:08:29 +00:00
{
const SwTxtNode* pNd = rNds[ n ]->GetTxtNode();
if( pNd )
{
SwFmtColl* pNdFmt = bConditional ? pNd->GetFmtColl()
: &pNd->GetAnyFmtColl();
if( !pFmt )
pFmt = pNdFmt;
else if( pFmt != pNdFmt )
{
bError = sal_True;
break;
}
}
}
if(bError)
break;
FOREACHUNOPAM_END()
return bError ? 0 : pFmt;
}
/* -----------------26.06.98 16:20-------------------
* Hilfsfunktion fuer PageDesc
* --------------------------------------------------*/
SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName)
{
SwPageDesc* pRet = 0;
sal_uInt16 nDCount = rDoc.GetPageDescCnt();
sal_uInt16 i;
for( i = 0; i < nDCount; i++ )
2000-09-18 23:08:29 +00:00
{
SwPageDesc* pDsc = &rDoc._GetPageDesc( i );
if(pDsc->GetName() == rName)
{
pRet = pDsc;
break;
}
}
if(!pRet)
{
for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_ENDNOTE; ++i)
{
const String aFmtName(SW_RES(i));
if(aFmtName == rName)
{
pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
2000-09-18 23:08:29 +00:00
break;
}
}
}
return pRet;
}
/******************************************************************************
******************************************************************************
******************************************************************************
* Taskforce ONE51
******************************************************************************/
/******************************************************************
* SwXTextCursor
******************************************************************/
/*-- 09.12.98 14:19:19---------------------------------------------------
-----------------------------------------------------------------------*/
OUString SwXTextCursor::getImplementationName(void) throw( RuntimeException )
{
return C2U("SwXTextCursor");
}
/*-- 09.12.98 14:19:19---------------------------------------------------
-----------------------------------------------------------------------*/
BOOL SwXTextCursor::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
String sServiceName(rServiceName);
return sServiceName.EqualsAscii("com.sun.star.text.TextCursor") ||
sServiceName.EqualsAscii("com.sun.star.style.CharacterProperties")||
2001-04-23 09:01:41 +00:00
sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesAsian")||
sServiceName.EqualsAscii("com.sun.star.style.CharacterPropertiesComplex")||
2002-09-26 06:18:30 +00:00
sServiceName.EqualsAscii("com.sun.star.style.ParagraphProperties") ||
sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
2002-10-10 10:08:28 +00:00
sServiceName.EqualsAscii("com.sun.star.style.ParagraphPropertiesComplex") ||
sServiceName.EqualsAscii("com.sun.star.text.TextSortable");
2000-09-18 23:08:29 +00:00
}
/*-- 09.12.98 14:19:19---------------------------------------------------
-----------------------------------------------------------------------*/
Sequence< OUString > SwXTextCursor::getSupportedServiceNames(void) throw( RuntimeException )
{
2002-10-10 10:08:28 +00:00
Sequence< OUString > aRet(8);
2000-09-18 23:08:29 +00:00
OUString* pArray = aRet.getArray();
pArray[0] = C2U("com.sun.star.text.TextCursor");
pArray[1] = C2U("com.sun.star.style.CharacterProperties");
2001-04-23 09:01:41 +00:00
pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
pArray[4] = C2U("com.sun.star.style.ParagraphProperties");
2002-09-26 06:18:30 +00:00
pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
2002-10-10 10:08:28 +00:00
pArray[7] = C2U("com.sun.star.text.TextSortable");
2000-09-18 23:08:29 +00:00
return aRet;
}
/*-- 09.12.98 14:19:19---------------------------------------------------
-----------------------------------------------------------------------*/
SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent, const SwPosition& rPos,
CursorType eSet, SwDoc* pDoc, const SwPosition* pMark) :
aLstnrCntnr(( util::XSortable*)this),
aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_CURSOR)),
xParentText(xParent),
2000-09-18 23:08:29 +00:00
pLastSortOptions(0),
eType(eSet),
mbRemoveUserEvent( false )
2000-09-18 23:08:29 +00:00
{
SwUnoCrsr* pUnoCrsr = pDoc->CreateUnoCrsr(rPos, sal_False);
if(pMark)
{
pUnoCrsr->SetMark();
*pUnoCrsr->GetMark() = *pMark;
}
pUnoCrsr->Add(this);
}
/* -----------------04.03.99 09:02-------------------
*
* --------------------------------------------------*/
SwXTextCursor::SwXTextCursor(uno::Reference< XText > xParent,
SwUnoCrsr* pSourceCrsr, CursorType eSet) :
aLstnrCntnr( (util::XSortable*)this),
aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_CURSOR)),
xParentText(xParent),
2000-09-18 23:08:29 +00:00
pLastSortOptions(0),
eType(eSet),
mbRemoveUserEvent( false )
2000-09-18 23:08:29 +00:00
{
SwUnoCrsr* pUnoCrsr = pSourceCrsr->GetDoc()->CreateUnoCrsr(*pSourceCrsr->GetPoint(), sal_False);
if(pSourceCrsr->HasMark())
{
pUnoCrsr->SetMark();
*pUnoCrsr->GetMark() = *pSourceCrsr->GetMark();
}
pUnoCrsr->Add(this);
}
/*-- 09.12.98 14:19:20---------------------------------------------------
-----------------------------------------------------------------------*/
SwXTextCursor::~SwXTextCursor()
{
vos::OGuard aGuard(Application::GetSolarMutex());
// --> FME 2006-03-07 #126177# A user event has been posted in order
// to delete the SwUnoCursor. Remove the user event if the SwXTextCursor
// is destroyed before the user event could be handled.
if ( mbRemoveUserEvent )
{
mbRemoveUserEvent = false;
Application::RemoveUserEvent( mnUserEventId );
}
// <--
2000-09-18 23:08:29 +00:00
SwUnoCrsr* pUnoCrsr = GetCrsr();
delete pUnoCrsr;
delete pLastSortOptions;
}
/*-- 09.12.98 14:19:18---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::DeleteAndInsert(const String& rText)
{
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
// Start/EndAction
SwDoc* pDoc = pUnoCrsr->GetDoc();
UnoActionContext aAction(pDoc);
xub_StrLen nTxtLen = rText.Len();
pDoc->StartUndo(UNDO_INSERT, NULL);
2000-09-18 23:08:29 +00:00
SwCursor *_pStartCrsr = pUnoCrsr;
do
{
if(_pStartCrsr->HasMark())
{
pDoc->DeleteAndJoin(*_pStartCrsr);
}
if(nTxtLen)
{
if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *_pStartCrsr, rText ) )
{
DBG_ASSERT( sal_False, "Doc->Insert(Str) failed." )
}
SwXTextCursor::SelectPam(*pUnoCrsr, sal_True);
_pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
}
} while( (_pStartCrsr=(SwCursor*)_pStartCrsr->GetNext()) != pUnoCrsr );
pDoc->EndUndo(UNDO_INSERT, NULL);
2000-09-18 23:08:29 +00:00
}
}
/* -----------------------------10.03.00 18:02--------------------------------
---------------------------------------------------------------------------*/
const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId()
{
static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
return aSeq;
}
/* -----------------------------10.03.00 18:04--------------------------------
---------------------------------------------------------------------------*/
sal_Int64 SAL_CALL SwXTextCursor::getSomething( const uno::Sequence< sal_Int8 >& rId )
throw(uno::RuntimeException)
{
if( rId.getLength() == 16
&& 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
rId.getConstArray(), 16 ) )
{
return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
2000-09-18 23:08:29 +00:00
}
return OTextCursorHelper::getSomething(rId);
2000-09-18 23:08:29 +00:00
}
/*-- 09.12.98 14:18:12---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::collapseToStart(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
if(pUnoCrsr->HasMark())
{
if(*pUnoCrsr->GetPoint() > *pUnoCrsr->GetMark())
pUnoCrsr->Exchange();
2000-09-18 23:08:29 +00:00
pUnoCrsr->DeleteMark();
}
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
}
/*-- 09.12.98 14:18:14---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::collapseToEnd(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
if(pUnoCrsr->HasMark())
{
if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
pUnoCrsr->Exchange();
pUnoCrsr->DeleteMark();
}
}
else
{
throw uno::RuntimeException();
}
}
/*-- 09.12.98 14:18:41---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isCollapsed(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_True;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr && pUnoCrsr->GetMark())
{
bRet = (*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark());
}
return bRet;
}
/*-- 09.12.98 14:18:42---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
return bRet;
}
/*-- 09.12.98 14:18:42---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
return bRet;
}
/*-- 09.12.98 14:18:43---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
if(eType == CURSOR_BODY)
{
pUnoCrsr->Move( fnMoveBackward, fnGoDoc );
//check, that the cursor is not in a table
SwTableNode* pTblNode = pUnoCrsr->GetNode()->FindTableNode();
SwCntntNode* pCont = 0;
while( pTblNode )
{
pUnoCrsr->GetPoint()->nNode = *pTblNode->EndOfSectionNode();
pCont = GetDoc()->GetNodes().GoNext(&pUnoCrsr->GetPoint()->nNode);
pTblNode = pCont ? pCont->FindTableNode() : 0;
2000-09-18 23:08:29 +00:00
}
if(pCont)
pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
const SwStartNode* pTmp = pUnoCrsr->GetNode()->StartOfSectionNode();
2000-09-18 23:08:29 +00:00
if(pTmp->IsSectionNode())
{
SwSectionNode* pSectionStartNode = (SwSectionNode*)pTmp;
if(pSectionStartNode->GetSection().IsHiddenFlag())
{
pCont = GetDoc()->GetNodes().GoNextSection(
&pUnoCrsr->GetPoint()->nNode, sal_True, sal_False);
if(pCont)
pUnoCrsr->GetPoint()->nContent.Assign(pCont, 0);
}
}
}
else if(eType == CURSOR_FRAME ||
eType == CURSOR_TBLTEXT ||
eType == CURSOR_HEADER ||
eType == CURSOR_FOOTER ||
eType == CURSOR_FOOTNOTE||
eType == CURSOR_REDLINE)
2000-09-18 23:08:29 +00:00
{
pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart);
}
}
else
{
throw uno::RuntimeException();
}
}
/*-- 09.12.98 14:18:43---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
if(eType == CURSOR_BODY)
pUnoCrsr->Move( fnMoveForward, fnGoDoc );
else if(eType == CURSOR_FRAME ||
eType == CURSOR_TBLTEXT ||
eType == CURSOR_HEADER ||
eType == CURSOR_FOOTER ||
eType == CURSOR_FOOTNOTE||
eType == CURSOR_REDLINE)
2000-09-18 23:08:29 +00:00
{
pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd);
}
}
else
{
throw uno::RuntimeException();
}
}
/* -----------------05.03.99 07:27-------------------
*
* --------------------------------------------------*/
void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_Bool bExpand )
throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pOwnCursor = GetCrsr();
if(!pOwnCursor || !xRange.is())
{
throw uno::RuntimeException();
}
uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
SwXTextRange* pRange = 0;
OTextCursorHelper* pCursor = 0;
2000-09-18 23:08:29 +00:00
if(xRangeTunnel.is())
{
pRange = reinterpret_cast< SwXTextRange * >(
sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
pCursor = reinterpret_cast< OTextCursorHelper * >(
sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2000-09-18 23:08:29 +00:00
}
SwStartNodeType eSearchNodeType = SwNormalStartNode;
switch(eType)
{
case CURSOR_FRAME: eSearchNodeType = SwFlyStartNode; break;
case CURSOR_TBLTEXT: eSearchNodeType = SwTableBoxStartNode; break;
case CURSOR_FOOTNOTE: eSearchNodeType = SwFootnoteStartNode; break;
case CURSOR_HEADER: eSearchNodeType = SwHeaderStartNode; break;
case CURSOR_FOOTER: eSearchNodeType = SwFooterStartNode; break;
//case CURSOR_INVALID:
//case CURSOR_BODY:
default:
;
2000-09-18 23:08:29 +00:00
}
const SwStartNode* pOwnStartNode = pOwnCursor->GetNode()->
FindSttNodeByType(eSearchNodeType);
const SwNode* pSrcNode = 0;
if(pCursor && pCursor->GetPaM())
2000-09-18 23:08:29 +00:00
{
pSrcNode = pCursor->GetPaM()->GetNode();
2000-09-18 23:08:29 +00:00
}
else if(pRange && pRange->GetBookmark())
{
SwBookmark* pBkm = pRange->GetBookmark();
pSrcNode = &pBkm->GetBookmarkPos().nNode.GetNode();
2000-09-18 23:08:29 +00:00
}
const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0;
//SectionNodes ueberspringen
while(pTmp && pTmp->IsSectionNode())
{
pTmp = pTmp->StartOfSectionNode();
2000-09-18 23:08:29 +00:00
}
while(pOwnStartNode && pOwnStartNode->IsSectionNode())
{
pOwnStartNode = pOwnStartNode->StartOfSectionNode();
}
2000-09-18 23:08:29 +00:00
if(pOwnStartNode != pTmp)
{
throw uno::RuntimeException();
}
//jetzt muss die Selektion erweitert werden
if(bExpand)
{
// der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen
// Range eingeschlossen wurde
SwPosition aOwnLeft(*pOwnCursor->GetPoint());
SwPosition aOwnRight(pOwnCursor->HasMark() ? *pOwnCursor->GetMark() : aOwnLeft);
if(aOwnRight < aOwnLeft)
{
SwPosition aTmp = aOwnLeft;
aOwnLeft = aOwnRight;
aOwnRight = aTmp;
}
SwPosition* pParamLeft;
SwPosition* pParamRight;
if(pCursor)
{
const SwPaM* pTmp2 = pCursor->GetPaM();
pParamLeft = new SwPosition(*pTmp2->GetPoint());
pParamRight = new SwPosition(pTmp2->HasMark() ? *pTmp2->GetMark() : *pParamLeft);
2000-09-18 23:08:29 +00:00
}
else
{
SwBookmark* pBkm = pRange->GetBookmark();
pParamLeft = new SwPosition(pBkm->GetBookmarkPos());
pParamRight = new SwPosition(pBkm->GetOtherBookmarkPos() ? *pBkm->GetOtherBookmarkPos() : *pParamLeft);
2000-09-18 23:08:29 +00:00
}
if(*pParamRight < *pParamLeft)
{
SwPosition* pTmp2 = pParamLeft;
2000-09-18 23:08:29 +00:00
pParamLeft = pParamRight;
pParamRight = pTmp2;
2000-09-18 23:08:29 +00:00
}
// jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche?
if(aOwnRight > *pParamRight)
2000-09-18 23:08:29 +00:00
*pOwnCursor->GetPoint() = aOwnRight;
else
*pOwnCursor->GetPoint() = *pParamRight;
pOwnCursor->SetMark();
if(aOwnLeft < *pParamLeft)
*pOwnCursor->GetMark() = aOwnLeft;
else
*pOwnCursor->GetMark() = *pParamLeft;
2000-09-18 23:08:29 +00:00
delete pParamLeft;
delete pParamRight;
}
else
{
//der Cursor soll dem uebergebenen Range entsprechen
if(pCursor)
{
const SwPaM* pTmp2 = pCursor->GetPaM();
*pOwnCursor->GetPoint() = *pTmp2->GetPoint();
if(pTmp2->HasMark())
2000-09-18 23:08:29 +00:00
{
pOwnCursor->SetMark();
*pOwnCursor->GetMark() = *pTmp2->GetMark();
2000-09-18 23:08:29 +00:00
}
else
pOwnCursor->DeleteMark();
}
else
{
SwBookmark* pBkm = pRange->GetBookmark();
*pOwnCursor->GetPoint() = pBkm->GetBookmarkPos();
if(pBkm->GetOtherBookmarkPos())
2000-09-18 23:08:29 +00:00
{
pOwnCursor->SetMark();
*pOwnCursor->GetMark() = *pBkm->GetOtherBookmarkPos();
2000-09-18 23:08:29 +00:00
}
else
pOwnCursor->DeleteMark();
}
}
}
/*-- 09.12.98 14:18:44---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isStartOfWord(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
bRet = pUnoCrsr->IsStartWordWT( i18n::WordType::DICTIONARY_WORD );
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
return bRet;
}
/*-- 09.12.98 14:18:44---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isEndOfWord(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
bRet = pUnoCrsr->IsEndWordWT( i18n::WordType::DICTIONARY_WORD );
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
return bRet;
}
/*-- 09.12.98 14:18:44---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
//Probleme gibt's noch mit einem Absatzanfang, an dem kein Wort beginnt.
2000-09-18 23:08:29 +00:00
SwUnoCrsr* pUnoCrsr = GetCrsr();
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
if(pUnoCrsr)
{
// remember old position to check if cursor has moved
// since the called functions are sometimes a bit unreliable
// in specific cases...
SwPosition *pPoint = pUnoCrsr->GetPoint();
SwNode *pOldNode = &pPoint->nNode.GetNode();
xub_StrLen nOldIndex = pPoint->nContent.GetIndex();
2000-09-18 23:08:29 +00:00
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
//Absatzende?
if(pUnoCrsr->GetCntntNode() &&
pPoint->nContent == pUnoCrsr->GetCntntNode()->Len())
pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
else
{
sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
2000-09-18 23:08:29 +00:00
//if there is no next word within the current paragraph try to go to the start of the next paragraph
if(!bTmp)
pUnoCrsr->MovePara(fnParaNext, fnParaStart);
2000-09-18 23:08:29 +00:00
}
// return true if cursor has moved
bRet = &pPoint->nNode.GetNode() != pOldNode ||
pPoint->nContent.GetIndex() != nOldIndex;
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:45---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
// hier machen Leerzeichen am Absatzanfang Probleme
SwUnoCrsr* pUnoCrsr = GetCrsr();
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
if(pUnoCrsr)
{
SwPosition *pPoint = pUnoCrsr->GetPoint();
SwNode *pOldNode = &pPoint->nNode.GetNode();
xub_StrLen nOldIndex = pPoint->nContent.GetIndex();
2000-09-18 23:08:29 +00:00
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
//Absatzanfang ?
if(pPoint->nContent == 0)
pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
else
{
pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
if(pPoint->nContent == 0)
pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE);
2000-09-18 23:08:29 +00:00
}
// return true if cursor has moved
bRet = &pPoint->nNode.GetNode() != pOldNode ||
pPoint->nContent.GetIndex() != nOldIndex;
2000-09-18 23:08:29 +00:00
}
else
{
throw uno::RuntimeException();
}
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:45---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
if(pUnoCrsr)
{
SwPosition *pPoint = pUnoCrsr->GetPoint();
SwNode &rOldNode = pPoint->nNode.GetNode();
xub_StrLen nOldIndex = pPoint->nContent.GetIndex();
sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
2000-09-18 23:08:29 +00:00
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
if(!pUnoCrsr->IsEndWordWT( nWordType ))
pUnoCrsr->GoEndWordWT( nWordType );
// restore old cursor if we are not at the end of a word by now
// otherwise use current one
bRet = pUnoCrsr->IsEndWordWT( nWordType );
if (!bRet)
2000-09-18 23:08:29 +00:00
{
pPoint->nNode = rOldNode;
pPoint->nContent = nOldIndex;
2000-09-18 23:08:29 +00:00
}
}
else
{
throw uno::RuntimeException();
}
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:46---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
if(pUnoCrsr)
{
SwPosition *pPoint = pUnoCrsr->GetPoint();
SwNode &rOldNode = pPoint->nNode.GetNode();
xub_StrLen nOldIndex = pPoint->nContent.GetIndex();
sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
2000-09-18 23:08:29 +00:00
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
if(!pUnoCrsr->IsStartWordWT( nWordType ))
pUnoCrsr->GoStartWordWT( nWordType );
// restore old cursor if we are not at the start of a word by now
// otherwise use current one
bRet = pUnoCrsr->IsStartWordWT( nWordType );
if (!bRet)
2000-09-18 23:08:29 +00:00
{
pPoint->nNode = rOldNode;
pPoint->nContent = nOldIndex;
2000-09-18 23:08:29 +00:00
}
}
else
{
throw uno::RuntimeException();
}
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:46---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isStartOfSentence(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
// start of paragraph?
2000-09-18 23:08:29 +00:00
bRet = pUnoCrsr->GetPoint()->nContent == 0;
// with mark ->no sentence start
// (check if cursor is no selection, i.e. it does not have
// a mark or else point and mark are identical)
if(!bRet && (!pUnoCrsr->HasMark() ||
*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark()))
2000-09-18 23:08:29 +00:00
{
SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false);
SwPosition aOrigPos = *aCrsr.GetPoint();
aCrsr.GoSentence(SwCursor::START_SENT );
bRet = aOrigPos == *aCrsr.GetPoint();
2000-09-18 23:08:29 +00:00
}
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:47---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isEndOfSentence(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
//end of paragraph?
2000-09-18 23:08:29 +00:00
bRet = pUnoCrsr->GetCntntNode() &&
pUnoCrsr->GetPoint()->nContent == pUnoCrsr->GetCntntNode()->Len();
// with mark->no sentence end
// (check if cursor is no selection, i.e. it does not have
// a mark or else point and mark are identical)
if(!bRet && (!pUnoCrsr->HasMark() ||
*pUnoCrsr->GetPoint() == *pUnoCrsr->GetMark()))
2000-09-18 23:08:29 +00:00
{
SwCursor aCrsr(*pUnoCrsr->GetPoint(),0,false);
SwPosition aOrigPos = *aCrsr.GetPoint();
aCrsr.GoSentence(SwCursor::END_SENT );
bRet = aOrigPos == *aCrsr.GetPoint();
2000-09-18 23:08:29 +00:00
}
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:47---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
BOOL bWasEOS = isEndOfSentence();
2000-09-18 23:08:29 +00:00
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->GoSentence(SwCursor::NEXT_SENT);
if(!bRet)
bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart);
// if at the end of the sentence (i.e. at the space after the '.')
// advance to next word in order for GoSentence to work properly
// next time and have isStartOfSentence return true after this call
if (!pUnoCrsr->IsStartWord())
{
BOOL bNextWord = pUnoCrsr->GoNextWord();
if (bWasEOS && !bNextWord)
bRet = sal_False;
}
2000-09-18 23:08:29 +00:00
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:47---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->GoSentence(SwCursor::PREV_SENT);
if(!bRet)
{
if(0 != (bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart)))
{
pUnoCrsr->MovePara(fnParaCurr, fnParaEnd);
//at the end of a paragraph move to the sentence end again
//
pUnoCrsr->GoSentence(SwCursor::PREV_SENT);
}
}
}
else
throw uno::RuntimeException();
return bRet;
}
/* -----------------15.10.99 08:24-------------------
--------------------------------------------------*/
sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
// if we're at the para start then we wont move
// but bRet is also true if GoSentence failed but
// the start of the sentence is reached
bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr)
2000-09-18 23:08:29 +00:00
|| pUnoCrsr->GoSentence(SwCursor::START_SENT) ||
SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
}
else
throw uno::RuntimeException();
return bRet;
}
/* -----------------15.10.99 08:24-------------------
--------------------------------------------------*/
sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
// bRet is true if GoSentence() succeeded or if the
// MovePara() succeeded while the end of the para is
// not reached already
sal_Bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
bRet = !bAlreadyParaEnd &&
(pUnoCrsr->GoSentence(SwCursor::END_SENT) ||
pUnoCrsr->MovePara(fnParaCurr, fnParaEnd));
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:48---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isStartOfParagraph(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:48---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::isEndOfParagraph(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:49---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr )
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
if(!bRet)
bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaStart);
}
else
throw uno::RuntimeException();
// since MovePara(fnParaCurr, fnParaStart) only returns false
// if we were already at the start of the paragraph this function
// should always complete successfully.
DBG_ASSERT( bRet, "gotoStartOfParagraph failed" );
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:49---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = SwUnoCursorHelper::IsEndOfPara(*pUnoCrsr);
2000-09-18 23:08:29 +00:00
if(!bRet)
bRet = pUnoCrsr->MovePara(fnParaCurr, fnParaEnd);
2000-09-18 23:08:29 +00:00
}
else
throw uno::RuntimeException();
// since MovePara(fnParaCurr, fnParaEnd) only returns false
// if we were already at the end of the paragraph this function
// should always complete successfully.
DBG_ASSERT( bRet, "gotoEndOfParagraph failed" );
2000-09-18 23:08:29 +00:00
return bRet;
}
/*-- 09.12.98 14:18:50---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->MovePara(fnParaNext, fnParaStart);
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:50---------------------------------------------------
-----------------------------------------------------------------------*/
sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Bool bRet = sal_False;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwXTextCursor::SelectPam(*pUnoCrsr, Expand);
bRet = pUnoCrsr->MovePara(fnParaPrev, fnParaStart);
}
else
throw uno::RuntimeException();
return bRet;
}
/*-- 09.12.98 14:18:50---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Reference< XText > SwXTextCursor::getText(void) throw( uno::RuntimeException )
{
return xParentText;
}
/*-- 09.12.98 14:18:50---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference< XTextRange > xRet;
SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr();
if( pUnoCrsr)
{
SwPaM aPam(*pUnoCrsr->Start());
uno::Reference< XText > xParent = getText();
xRet = new SwXTextRange(aPam, xParent);
}
else
throw uno::RuntimeException();
return xRet;
}
/*-- 09.12.98 14:18:51---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Reference< XTextRange > xRet;
SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr();
if( pUnoCrsr)
{
SwPaM aPam(*pUnoCrsr->End());
uno::Reference< XText > xParent = getText();
xRet = new SwXTextRange(aPam, xParent);
}
else
throw uno::RuntimeException();
return xRet;
}
/*-- 09.12.98 14:18:51---------------------------------------------------
-----------------------------------------------------------------------*/
OUString SwXTextCursor::getString(void) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
OUString aTxt;
SwUnoCrsr* pUnoCrsr = ((SwXTextCursor*)this)->GetCrsr();
if( pUnoCrsr)
{
/* if( pUnoCrsr->GetPoint()->nNode.GetIndex() ==
pUnoCrsr->GetMark()->nNode.GetIndex() )
{
SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode();
if( pTxtNd )
{
sal_uInt16 nStt = pUnoCrsr->Start()->nContent.GetIndex();
aTxt = pTxtNd->GetExpandTxt( nStt,
pUnoCrsr->End()->nContent.GetIndex() - nStt );
}
}
else
*/ {
//Text ueber mehrere Absaetze
SwXTextCursor::getTextFromPam(*pUnoCrsr, aTxt);
}
}
else
throw uno::RuntimeException();
return aTxt;
}
/*-- 09.12.98 14:18:52---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(!pUnoCrsr)
throw uno::RuntimeException();
DeleteAndInsert(aString);
}
/* -----------------------------03.05.00 12:56--------------------------------
---------------------------------------------------------------------------*/
Any SwXTextCursor::GetPropertyValue(
2001-04-03 06:28:56 +00:00
SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
const OUString& rPropertyName)
2000-09-18 23:08:29 +00:00
throw( UnknownPropertyException, WrappedTargetException, RuntimeException)
{
Any aAny;
const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
rPropSet.getPropertyMap(), rPropertyName);
if(pMap)
{
PropertyState eTemp;
2001-06-13 11:40:53 +00:00
BOOL bDone = SwUnoCursorHelper::getCrsrPropertyValue( pMap, rPaM, &aAny, eTemp );
2000-09-18 23:08:29 +00:00
if(!bDone)
2001-06-07 07:01:20 +00:00
{
SfxItemSet aSet(rPaM.GetDoc()->GetAttrPool(),
RES_CHRATR_BEGIN, RES_FRMATR_END -1,
2001-06-07 07:01:20 +00:00
RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
2001-06-07 07:01:20 +00:00
0L);
SwXTextCursor::GetCrsrAttr(rPaM, aSet);
aAny = rPropSet.getPropertyValue(*pMap, aSet);
2001-06-07 07:01:20 +00:00
}
2000-09-18 23:08:29 +00:00
}
else
throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) );
2000-09-18 23:08:29 +00:00
return aAny;
}
/* -----------------------------03.05.00 12:57--------------------------------
---------------------------------------------------------------------------*/
void SwXTextCursor::SetPropertyValue(
2001-04-03 06:28:56 +00:00
SwPaM& rPaM, const SfxItemPropertySet& rPropSet, const OUString& rPropertyName,
const Any& aValue, const SfxItemPropertyMap* _pMap, USHORT nAttrMode)
2000-09-18 23:08:29 +00:00
throw (UnknownPropertyException, PropertyVetoException,
IllegalArgumentException, WrappedTargetException, RuntimeException)
{
SwDoc* pDoc = rPaM.GetDoc();
2001-04-03 06:28:56 +00:00
const SfxItemPropertyMap* pMap = _pMap ? _pMap : SfxItemPropertyMap::GetByName(
rPropSet.getPropertyMap(), rPropertyName);
2000-09-18 23:08:29 +00:00
if(pMap)
{
if ( pMap->nFlags & PropertyAttribute::READONLY)
throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) );
SfxItemSet aItemSet( pDoc->GetAttrPool(), pMap->nWID, pMap->nWID );
SwXTextCursor::GetCrsrAttr( rPaM, aItemSet );
if(!lcl_setCrsrPropertyValue( pMap, rPaM, aItemSet, aValue ))
rPropSet.setPropertyValue(*pMap, aValue, aItemSet );
SwXTextCursor::SetCrsrAttr(rPaM, aItemSet, nAttrMode );
2000-09-18 23:08:29 +00:00
}
else
throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) );
2000-09-18 23:08:29 +00:00
}
/* -----------------------------03.05.00 13:16--------------------------------
---------------------------------------------------------------------------*/
Sequence< PropertyState > SwXTextCursor::GetPropertyStates(
SwPaM& rPaM, SfxItemPropertySet& rPropSet,
const Sequence< OUString >& PropertyNames,
SwGetPropertyStatesCaller eCaller )
2000-09-18 23:08:29 +00:00
throw(UnknownPropertyException, RuntimeException)
{
const OUString* pNames = PropertyNames.getConstArray();
Sequence< PropertyState > aRet ( PropertyNames.getLength() );
2000-09-18 23:08:29 +00:00
PropertyState* pStates = aRet.getArray();
2000-10-13 07:30:53 +00:00
SfxItemSet *pSet = 0, *pSetParent = 0;
const SfxItemPropertyMap* pSaveMap, *pMap = rPropSet.getPropertyMap();
2000-10-13 07:30:53 +00:00
for( INT32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd; i++ )
2001-03-29 13:40:38 +00:00
{
pSaveMap = pMap;
2001-03-29 13:40:38 +00:00
pMap = SfxItemPropertyMap::GetByName( pMap, pNames[i] );
if(!pMap)
{
if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
{
pStates[i] = beans::PropertyState_DEFAULT_VALUE;
pMap = pSaveMap;
continue;
}
else
throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) );
2001-03-29 13:40:38 +00:00
}
if (eCaller == SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION &&
pMap->nWID < FN_UNO_RANGE_BEGIN &&
pMap->nWID > FN_UNO_RANGE_END &&
pMap->nWID < RES_CHRATR_BEGIN &&
pMap->nWID > RES_TXTATR_END )
pStates[i] = beans::PropertyState_DEFAULT_VALUE;
else
{
if ( pMap->nWID >= FN_UNO_RANGE_BEGIN &&
pMap->nWID <= FN_UNO_RANGE_END )
SwUnoCursorHelper::getCrsrPropertyValue(pMap, rPaM, 0, pStates[i] );
else
{
if( !pSet )
{
switch ( eCaller )
{
case SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION:
pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
RES_CHRATR_BEGIN, RES_TXTATR_END );
break;
case SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY:
pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
pMap->nWID, pMap->nWID );
break;
default:
pSet = new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
RES_CHRATR_BEGIN, RES_FRMATR_END - 1,
RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER,
RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
0L );
}
// --> OD 2006-07-12 #i63870#
SwXTextCursor::GetCrsrAttr( rPaM, *pSet );
// <--
}
if( pSet->Count() )
pStates[i] = rPropSet.getPropertyState( *pMap,*pSet );
else
pStates[i] = PropertyState_DEFAULT_VALUE;
//try again to find out if a value has been inherited
if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
{
if( !pSetParent )
{
pSetParent = pSet->Clone( FALSE );
// --> OD 2006-07-12 #i63870#
SwXTextCursor::GetCrsrAttr( rPaM, *pSetParent, TRUE, FALSE );
// <--
}
if( (pSetParent)->Count() )
pStates[i] = rPropSet.getPropertyState( *pMap, *pSetParent );
else
pStates[i] = PropertyState_DEFAULT_VALUE;
}
}
}
2001-04-05 12:34:45 +00:00
pMap++;
2001-03-29 13:40:38 +00:00
}
2000-10-13 07:30:53 +00:00
delete pSet;
delete pSetParent;
2000-09-18 23:08:29 +00:00
return aRet;
}
/* -----------------------------03.05.00 13:17--------------------------------
---------------------------------------------------------------------------*/
PropertyState SwXTextCursor::GetPropertyState(
SwPaM& rPaM, SfxItemPropertySet& rPropSet, const OUString& rPropertyName)
throw(UnknownPropertyException, RuntimeException)
{
Sequence < OUString > aStrings ( 1 );
aStrings[0] = rPropertyName;
Sequence < PropertyState > aSeq = GetPropertyStates( rPaM, rPropSet, aStrings, SW_PROPERTY_STATE_CALLER_SINGLE_VALUE_ONLY );
return aSeq[0];
2000-09-18 23:08:29 +00:00
}
/* -----------------------------03.05.00 13:20--------------------------------
---------------------------------------------------------------------------*/
void lcl_SelectParaAndReset ( SwPaM &rPaM, SwDoc* pDoc, const SvUShortsSort* pWhichIds = 0 )
{
// if we are reseting paragraph attributes, we need to select the full paragraph first
SwPosition aStart = *rPaM.Start();
SwPosition aEnd = *rPaM.End();
auto_ptr < SwUnoCrsr > pTemp ( pDoc->CreateUnoCrsr(aStart, FALSE) );
if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
pTemp->MovePara(fnParaCurr, fnParaStart);
pTemp->SetMark();
*pTemp->GetPoint() = aEnd;
SwXTextCursor::SelectPam(*pTemp, sal_True);
if(!SwUnoCursorHelper::IsEndOfPara(*pTemp))
pTemp->MovePara(fnParaCurr, fnParaEnd);
pDoc->ResetAttrs(*pTemp, sal_True, pWhichIds);
}
2000-09-18 23:08:29 +00:00
void SwXTextCursor::SetPropertyToDefault(
SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
const OUString& rPropertyName)
throw(UnknownPropertyException, RuntimeException)
{
NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex());
SwDoc* pDoc = rPaM.GetDoc();
const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
rPropSet.getPropertyMap(), rPropertyName);
if(pMap)
{
if ( pMap->nFlags & PropertyAttribute::READONLY)
throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, 0 );
2000-09-18 23:08:29 +00:00
if(pMap->nWID < RES_FRMATR_END)
{
SvUShortsSort aWhichIds;
aWhichIds.Insert(pMap->nWID);
if(pMap->nWID < RES_PARATR_BEGIN)
pDoc->ResetAttrs(rPaM, sal_True, &aWhichIds);
2000-09-18 23:08:29 +00:00
else
lcl_SelectParaAndReset ( rPaM, pDoc, &aWhichIds );
2000-09-18 23:08:29 +00:00
}
else
SwUnoCursorHelper::resetCrsrPropertyValue(pMap, rPaM);
2000-09-18 23:08:29 +00:00
}
else
throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) );
2000-09-18 23:08:29 +00:00
}
/* -----------------------------03.05.00 13:19--------------------------------
---------------------------------------------------------------------------*/
Any SwXTextCursor::GetPropertyDefault(
SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
const OUString& rPropertyName)
throw( UnknownPropertyException, WrappedTargetException, RuntimeException)
{
Any aRet;
SwDoc* pDoc = rPaM.GetDoc();
const SfxItemPropertyMap* pMap = SfxItemPropertyMap::GetByName(
rPropSet.getPropertyMap(), rPropertyName);
if(pMap)
{
if(pMap->nWID < RES_FRMATR_END)
{
const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pMap->nWID);
2000-09-18 23:08:29 +00:00
rDefItem.QueryValue(aRet, pMap->nMemberId);
}
}
else
throw UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( 0 ) );
2000-09-18 23:08:29 +00:00
return aRet;
}
/*-- 09.12.98 14:18:54---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Reference< beans::XPropertySetInfo > SwXTextCursor::getPropertySetInfo(void) throw( uno::RuntimeException )
{
static uno::Reference< beans::XPropertySetInfo > xRef;
if(!xRef.is())
{
static SfxItemPropertyMap aCrsrExtMap_Impl[] =
{
{ SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT), FN_SKIP_HIDDEN_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0},
{ SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT), FN_SKIP_PROTECTED_TEXT, &::getBooleanCppuType(), PROPERTY_NONE, 0},
{0,0,0,0,0,0}
};
uno::Reference< beans::XPropertySetInfo > xInfo = aPropSet.getPropertySetInfo();
// PropertySetInfo verlaengern!
const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
xRef = new SfxExtItemPropertySetInfo(
aCrsrExtMap_Impl,
aPropSeq );
}
2000-09-18 23:08:29 +00:00
return xRef;
}
/*-- 09.12.98 14:18:54---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
throw( beans::UnknownPropertyException, beans::PropertyVetoException,
lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
2001-06-13 11:40:53 +00:00
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)))
{
sal_Bool bSet = *(sal_Bool*)aValue.getValue();
pUnoCrsr->SetSkipOverHiddenSections(bSet);
}
2001-06-13 11:40:53 +00:00
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
{
sal_Bool bSet = *(sal_Bool*)aValue.getValue();
pUnoCrsr->SetSkipOverProtectSections(bSet);
}
else
SetPropertyValue(*pUnoCrsr, aPropSet, rPropertyName, aValue);
2000-09-18 23:08:29 +00:00
}
else
throw uno::RuntimeException();
}
/*-- 09.12.98 14:18:55---------------------------------------------------
-----------------------------------------------------------------------*/
Any SwXTextCursor::getPropertyValue(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
uno::Any aAny;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
2001-06-13 11:40:53 +00:00
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)))
{
BOOL bSet = pUnoCrsr->IsSkipOverHiddenSections();
aAny.setValue(&bSet, ::getBooleanCppuType());
}
2001-06-13 11:40:53 +00:00
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
{
BOOL bSet = pUnoCrsr->IsSkipOverProtectSections();
aAny.setValue(&bSet, ::getBooleanCppuType());
}
else
aAny = GetPropertyValue(*pUnoCrsr, aPropSet, rPropertyName);
2000-09-18 23:08:29 +00:00
}
else
throw uno::RuntimeException();
return aAny;
}
/*-- 09.12.98 14:18:55---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2000-09-18 23:08:29 +00:00
{
DBG_WARNING("not implemented")
}
/*-- 09.12.98 14:18:57---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2000-09-18 23:08:29 +00:00
{
DBG_WARNING("not implemented")
}
/*-- 09.12.98 14:18:57---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2000-09-18 23:08:29 +00:00
{
DBG_WARNING("not implemented")
}
/*-- 09.12.98 14:18:58---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2000-09-18 23:08:29 +00:00
{
DBG_WARNING("not implemented")
}
/*-- 05.03.99 11:36:11---------------------------------------------------
-----------------------------------------------------------------------*/
beans::PropertyState SwXTextCursor::getPropertyState(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
eRet = GetPropertyState(*pUnoCrsr, aPropSet, rPropertyName);
}
else
throw RuntimeException();
return eRet;
}
/*-- 05.03.99 11:36:11---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Sequence< beans::PropertyState > SwXTextCursor::getPropertyStates(
const uno::Sequence< OUString >& PropertyNames)
throw( beans::UnknownPropertyException, uno::RuntimeException )
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(!pUnoCrsr)
throw RuntimeException();
return GetPropertyStates(*pUnoCrsr, aPropSet, PropertyNames);
}
/*-- 05.03.99 11:36:12---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, uno::RuntimeException )
{
Sequence < OUString > aSequence ( &rPropertyName, 1 );
setPropertiesToDefault ( aSequence );
2000-09-18 23:08:29 +00:00
}
/*-- 05.03.99 11:36:12---------------------------------------------------
-----------------------------------------------------------------------*/
uno::Any SwXTextCursor::getPropertyDefault(const OUString& rPropertyName)
throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
{
const Sequence < OUString > aSequence ( &rPropertyName, 1 );
return getPropertyDefaults ( aSequence ).getConstArray()[0];
}
void SAL_CALL SwXTextCursor::setAllPropertiesToDefault()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
2000-09-18 23:08:29 +00:00
SwUnoCrsr* pUnoCrsr = GetCrsr();
if (pUnoCrsr)
{
// para specific attribut ranges
USHORT aParaResetableSetRange[] = {
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1,
// --> OD 2008-02-25 #refactorlists#
RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
// <--
RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
0
};
// selection specific attribut ranges
USHORT aResetableSetRange[] = {
RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
RES_TXTATR_CJK_RUBY, RES_TXTATR_UNKNOWN_CONTAINER,
0
};
SvUShortsSort aParaWhichIds;
SvUShortsSort aWhichIds;
for (USHORT k = 0; k < 2; ++k)
{
SvUShortsSort &rWhichIds = k == 0? aParaWhichIds : aWhichIds;
USHORT *pResetableSetRange = k == 0? aParaResetableSetRange : aResetableSetRange;
while (*pResetableSetRange)
{
USHORT nStart = sal::static_int_cast< USHORT >(*pResetableSetRange++);
USHORT nEnd = sal::static_int_cast< USHORT >(*pResetableSetRange++);
for (USHORT nId = nStart + 1; nId <= nEnd; ++nId)
rWhichIds.Insert( nId );
}
}
if (aParaWhichIds.Count())
lcl_SelectParaAndReset( *pUnoCrsr, pUnoCrsr->GetDoc(), &aParaWhichIds );
if (aWhichIds.Count() )
pUnoCrsr->GetDoc()->ResetAttrs( *pUnoCrsr, sal_True, &aWhichIds );
}
2000-09-18 23:08:29 +00:00
else
throw uno::RuntimeException();
}
void SAL_CALL SwXTextCursor::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames )
throw (UnknownPropertyException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Int32 nCount = aPropertyNames.getLength();
if ( nCount )
{
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
{
SwDoc* pDoc = pUnoCrsr->GetDoc();
const SfxItemPropertyMap* pMap = aPropSet.getPropertyMap(), *pSaveMap;
const OUString * pNames = aPropertyNames.getConstArray();
SvUShortsSort aWhichIds, aParaWhichIds;
for ( sal_Int32 i = 0; i < nCount; i++ )
{
pSaveMap = pMap;
pMap = SfxItemPropertyMap::GetByName( pMap, pNames[i]);
if(!pMap)
{
if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
{
pMap = pSaveMap;
continue;
}
else
throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) );
}
if ( pMap->nFlags & PropertyAttribute::READONLY)
throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
if( pMap->nWID < RES_FRMATR_END)
{
if(pMap->nWID < RES_PARATR_BEGIN)
aWhichIds.Insert(pMap->nWID);
else
aParaWhichIds.Insert (pMap->nWID);
}
else if ( pMap->nWID == FN_UNO_NUM_START_VALUE )
SwUnoCursorHelper::resetCrsrPropertyValue(pMap, *pUnoCrsr);
}
2000-09-18 23:08:29 +00:00
if ( aParaWhichIds.Count() )
lcl_SelectParaAndReset ( *pUnoCrsr, pDoc, &aParaWhichIds );
if (aWhichIds.Count() )
pDoc->ResetAttrs(*pUnoCrsr, sal_True, &aWhichIds);
}
else
throw uno::RuntimeException();
}
}
Sequence< Any > SAL_CALL SwXTextCursor::getPropertyDefaults( const Sequence< OUString >& aPropertyNames )
throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
sal_Int32 nCount = aPropertyNames.getLength();
Sequence < Any > aRet ( nCount );
if ( nCount )
{
SwUnoCrsr* pUnoCrsr = GetCrsr();
if (pUnoCrsr)
{
SwDoc* pDoc = pUnoCrsr->GetDoc();
const SfxItemPropertyMap *pSaveMap, *pMap = aPropSet.getPropertyMap();
const OUString *pNames = aPropertyNames.getConstArray();
Any *pAny = aRet.getArray();
for ( sal_Int32 i = 0; i < nCount; i++)
{
pSaveMap = pMap;
pMap = SfxItemPropertyMap::GetByName( pMap, pNames[i]);
if(!pMap)
{
if(pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) ||
pNames[i].equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)))
{
pMap = pSaveMap;
continue;
}
else
throw UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( 0 ) );
}
if(pMap->nWID < RES_FRMATR_END)
{
const SfxPoolItem& rDefItem = pDoc->GetAttrPool().GetDefaultItem(pMap->nWID);
rDefItem.QueryValue(pAny[i], pMap->nMemberId);
}
}
}
else
throw UnknownPropertyException();
}
return aRet;
}
/*-- 10.03.2008 09:58:47---------------------------------------------------
-----------------------------------------------------------------------*/
void SwXTextCursor::makeRedline(
const ::rtl::OUString& rRedlineType,
const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
throw (lang::IllegalArgumentException, uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
SwUnoCrsr* pUnoCrsr = GetCrsr();
if(pUnoCrsr)
SwUnoCursorHelper::makeRedline( *pUnoCrsr, rRedlineType, rRedlineProperties );
else
throw uno::RuntimeException();
}