2000-12-15 11:23:15 +00:00
/*************************************************************************
*
2008-04-10 15:20:24 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +00:00
* Copyright 2008 by Sun Microsystems , Inc .
2000-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +00:00
* $ RCSfile : unoparagraph . cxx , v $
* $ Revision : 1.41 $
2000-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +00:00
* This file is part of OpenOffice . org .
2000-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +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-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +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-12-15 11:23:15 +00:00
*
2008-04-10 15:20:24 +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-12-15 11:23:15 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-16 20:58:49 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_sw.hxx"
2000-12-15 11:23:15 +00:00
# include <cmdid.h>
2001-03-29 13:40:38 +00:00
# ifndef _UNOMID_H
# include <unomid.h>
# endif
2000-12-15 11:23:15 +00:00
# include <unoobj.hxx>
# include <unomap.hxx>
# include <unocrsr.hxx>
# include <unoprnms.hxx>
# include <unocrsrhelper.hxx>
# include <doc.hxx>
# include <ndtxt.hxx>
# include <vos/mutex.hxx>
# include <vcl/svapp.hxx>
2004-03-17 08:36:36 +00:00
2000-12-15 11:23:15 +00:00
# define _SVSTDARR_USHORTS
# define _SVSTDARR_USHORTSSORT
# include <svtools/svstdarr.hxx>
2005-04-18 10:30:13 +00:00
//#ifndef _COM_SUN_STAR_BEANS_SETPROPERTYTOLERANTFAILED_HPP_
//#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
//#endif
//#ifndef _COM_SUN_STAR_BEANS_GETPROPERTYTOLERANTRESULT_HPP_
//#include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
//#endif
//#ifndef _COM_SUN_STAR_BEANS_TOLERANTPROPERTYSETRESULTTYPE_HPP_
//#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
//#endif
2001-04-03 06:28:56 +00:00
# ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_
# include <com/sun/star/beans/PropertyAttribute.hpp>
# endif
2000-12-15 11:23:15 +00:00
# include <com/sun/star/text/WrapTextMode.hpp>
# include <com/sun/star/text/TextContentAnchorType.hpp>
using namespace : : com : : sun : : star ;
2008-03-12 11:32:02 +00:00
using : : rtl : : OUString ;
2000-12-15 11:23:15 +00:00
2004-03-17 08:36:36 +00:00
/******************************************************************
* forward declarations
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
beans : : PropertyState lcl_SwXParagraph_getPropertyState (
SwUnoCrsr & rUnoCrsr ,
const SwAttrSet * * ppSet ,
const SfxItemPropertyMap & rMap ,
sal_Bool & rAttrSetFetched )
throw ( beans : : UnknownPropertyException ) ;
2000-12-15 11:23:15 +00:00
/******************************************************************
* SwXParagraph
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* -----------------------------11.07.00 12:10--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
SwXParagraph * SwXParagraph : : GetImplementation ( uno : : Reference < XInterface > xRef )
2000-12-15 11:23:15 +00:00
{
uno : : Reference < lang : : XUnoTunnel > xParaTunnel ( xRef , uno : : UNO_QUERY ) ;
if ( xParaTunnel . is ( ) )
2007-09-27 08:38:20 +00:00
return reinterpret_cast < SwXParagraph * > (
sal : : static_int_cast < sal_IntPtr > ( xParaTunnel - > getSomething ( SwXParagraph : : getUnoTunnelId ( ) ) ) ) ;
2000-12-15 11:23:15 +00:00
return 0 ;
}
/* -----------------------------13.03.00 12:15--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
const uno : : Sequence < sal_Int8 > & SwXParagraph : : getUnoTunnelId ( )
{
static uno : : Sequence < sal_Int8 > aSeq = : : CreateUnoTunnelId ( ) ;
return aSeq ;
}
/* -----------------------------10.03.00 18:04--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
sal_Int64 SAL_CALL SwXParagraph : : getSomething ( const uno : : Sequence < sal_Int8 > & rId )
throw ( uno : : RuntimeException )
{
if ( rId . getLength ( ) = = 16
& & 0 = = rtl_compareMemory ( getUnoTunnelId ( ) . getConstArray ( ) ,
rId . getConstArray ( ) , 16 ) )
{
2007-09-27 08:38:20 +00:00
return sal : : static_int_cast < sal_Int64 > ( reinterpret_cast < sal_IntPtr > ( this ) ) ;
2000-12-15 11:23:15 +00:00
}
return 0 ;
}
/* -----------------------------06.04.00 16:37--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
OUString SwXParagraph : : getImplementationName ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
return C2U ( " SwXParagraph " ) ;
}
/* -----------------------------06.04.00 16:37--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
BOOL SwXParagraph : : supportsService ( const OUString & rServiceName ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
String sServiceName ( rServiceName ) ;
return sServiceName . EqualsAscii ( " com.sun.star.text.TextContent " ) | |
sServiceName . EqualsAscii ( " com.sun.star.text.Paragraph " ) | |
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 " ) | |
sServiceName . EqualsAscii ( " com.sun.star.style.ParagraphPropertiesComplex " ) ;
2000-12-15 11:23:15 +00:00
}
/* -----------------------------06.04.00 16:37--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Sequence < OUString > SwXParagraph : : getSupportedServiceNames ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
2007-06-05 16:34:38 +00:00
uno : : Sequence < OUString > aRet ( 8 ) ;
2000-12-15 11:23:15 +00:00
OUString * pArray = aRet . getArray ( ) ;
pArray [ 0 ] = C2U ( " com.sun.star.text.Paragraph " ) ;
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 " ) ;
pArray [ 7 ] = C2U ( " com.sun.star.text.TextContent " ) ;
2000-12-15 11:23:15 +00:00
return aRet ;
}
/*-- 11.12.98 08:12:47---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SwXParagraph : : SwXParagraph ( ) :
xParentText ( 0 ) ,
2007-09-27 08:38:20 +00:00
aLstnrCntnr ( ( text : : XTextRange * ) this ) ,
2000-12-15 11:23:15 +00:00
aPropSet ( aSwMapProvider . GetPropertyMap ( PROPERTY_MAP_PARAGRAPH ) ) ,
2001-05-23 08:10:48 +00:00
nSelectionStartPos ( - 1 ) ,
2007-09-27 08:38:20 +00:00
nSelectionEndPos ( - 1 ) ,
m_bIsDescriptor ( TRUE )
2000-12-15 11:23:15 +00:00
{
}
/*-- 11.12.98 08:12:47---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2001-05-23 08:10:48 +00:00
SwXParagraph : : SwXParagraph ( SwXText * pParent , SwUnoCrsr * pCrsr , sal_Int32 nSelStart , sal_Int32 nSelEnd ) :
2000-12-15 11:23:15 +00:00
SwClient ( pCrsr ) ,
xParentText ( pParent ) ,
2007-06-05 16:34:38 +00:00
aLstnrCntnr ( ( text : : XTextRange * ) this ) ,
2000-12-15 11:23:15 +00:00
aPropSet ( aSwMapProvider . GetPropertyMap ( PROPERTY_MAP_PARAGRAPH ) ) ,
2001-05-23 08:10:48 +00:00
nSelectionStartPos ( nSelStart ) ,
2007-09-27 08:38:20 +00:00
nSelectionEndPos ( nSelEnd ) ,
m_bIsDescriptor ( FALSE )
2000-12-15 11:23:15 +00:00
{
}
/*-- 11.12.98 08:12:48---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
SwXParagraph : : ~ SwXParagraph ( )
{
2005-07-12 10:20:13 +00:00
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2000-12-15 11:23:15 +00:00
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
delete pUnoCrsr ;
}
/* -----------------------------11.07.00 14:48--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : attachToText ( SwXText * pParent , SwUnoCrsr * pCrsr )
{
2008-11-10 15:06:12 +00:00
DBG_ASSERT ( m_bIsDescriptor , " Paragraph is not a descriptor " ) ;
2000-12-15 11:23:15 +00:00
if ( m_bIsDescriptor )
{
m_bIsDescriptor = FALSE ;
pCrsr - > Add ( this ) ;
xParentText = pParent ;
if ( m_sText . getLength ( ) )
{
try { setString ( m_sText ) ; }
catch ( . . . ) { }
m_sText = OUString ( ) ;
}
}
}
/*-- 11.12.98 08:12:49---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Reference < beans : : XPropertySetInfo > SwXParagraph : : getPropertySetInfo ( void )
throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
2007-06-05 16:34:38 +00:00
static uno : : Reference < beans : : XPropertySetInfo > xRef = aPropSet . getPropertySetInfo ( ) ;
2000-12-15 11:23:15 +00:00
return xRef ;
}
/*-- 11.12.98 08:12:49---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
void SwXParagraph : : setPropertyValue ( const OUString & rPropertyName , const uno : : Any & aValue )
throw ( beans : : UnknownPropertyException , beans : : PropertyVetoException , lang : : IllegalArgumentException ,
lang : : WrappedTargetException , uno : : RuntimeException )
2001-04-03 06:28:56 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Sequence < OUString > aPropertyNames ( 1 ) ;
2001-04-03 06:28:56 +00:00
aPropertyNames . getArray ( ) [ 0 ] = rPropertyName ;
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > aValues ( 1 ) ;
2001-04-03 06:28:56 +00:00
aValues . getArray ( ) [ 0 ] = aValue ;
2003-11-07 14:13:02 +00:00
SetPropertyValues_Impl ( aPropertyNames , aValues ) ;
2001-04-03 06:28:56 +00:00
}
/*-- 11.12.98 08:12:49---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Any SwXParagraph : : getPropertyValue ( const OUString & rPropertyName )
2007-06-05 16:34:38 +00:00
throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
2001-04-03 06:28:56 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Sequence < OUString > aPropertyNames ( 1 ) ;
2001-04-03 06:28:56 +00:00
aPropertyNames . getArray ( ) [ 0 ] = rPropertyName ;
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > aRet = GetPropertyValues_Impl ( aPropertyNames ) ;
2001-04-03 06:28:56 +00:00
return aRet . getConstArray ( ) [ 0 ] ;
}
/* -----------------------------02.04.01 11:43--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2003-11-07 14:13:02 +00:00
void SAL_CALL SwXParagraph : : SetPropertyValues_Impl (
const uno : : Sequence < OUString > & rPropertyNames ,
2007-06-05 16:34:38 +00:00
const uno : : Sequence < uno : : Any > & rValues )
throw ( beans : : UnknownPropertyException , beans : : PropertyVetoException , lang : : IllegalArgumentException ,
lang : : WrappedTargetException , uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
{
2001-04-03 06:28:56 +00:00
const OUString * pPropertyNames = rPropertyNames . getConstArray ( ) ;
2007-06-05 16:34:38 +00:00
const uno : : Any * pValues = rValues . getConstArray ( ) ;
2001-04-03 06:28:56 +00:00
const SfxItemPropertyMap * pMap = aPropSet . getPropertyMap ( ) ;
OUString sTmp ;
SwParaSelection aParaSel ( pUnoCrsr ) ;
for ( sal_Int32 nProp = 0 ; nProp < rPropertyNames . getLength ( ) ; nProp + + )
2000-12-15 11:23:15 +00:00
{
2001-04-03 06:28:56 +00:00
pMap = SfxItemPropertyMap : : GetByName ( pMap , pPropertyNames [ nProp ] ) ;
2003-11-07 14:13:02 +00:00
if ( ! pMap )
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + pPropertyNames [ nProp ] , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2003-11-07 14:13:02 +00:00
else
2001-04-03 06:28:56 +00:00
{
2007-06-05 16:34:38 +00:00
if ( pMap - > nFlags & beans : : PropertyAttribute : : READONLY )
throw beans : : PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Property is read-only: " ) ) + pPropertyNames [ nProp ] , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2001-11-28 19:22:09 +00:00
2001-04-03 06:28:56 +00:00
SwXTextCursor : : SetPropertyValue ( * pUnoCrsr , aPropSet ,
sTmp , pValues [ nProp ] , pMap ) ;
2001-06-07 07:01:20 +00:00
pMap + + ;
2001-04-03 06:28:56 +00:00
}
2000-12-15 11:23:15 +00:00
}
}
else
throw uno : : RuntimeException ( ) ;
}
2003-11-07 14:13:02 +00:00
void SwXParagraph : : setPropertyValues (
2007-06-05 16:34:38 +00:00
const uno : : Sequence < OUString > & rPropertyNames ,
const uno : : Sequence < uno : : Any > & rValues )
throw ( beans : : PropertyVetoException , lang : : IllegalArgumentException ,
lang : : WrappedTargetException , uno : : RuntimeException )
2003-11-07 14:13:02 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
// workaround for bad designed API
try
{
SetPropertyValues_Impl ( rPropertyNames , rValues ) ;
}
2007-06-05 16:34:38 +00:00
catch ( beans : : UnknownPropertyException & rException )
2003-11-07 14:13:02 +00:00
{
// wrap the original (here not allowed) exception in
2007-06-05 16:34:38 +00:00
// a lang::WrappedTargetException that gets thrown instead.
lang : : WrappedTargetException aWExc ;
2003-11-07 14:13:02 +00:00
aWExc . TargetException < < = rException ;
throw aWExc ;
}
}
2001-04-03 06:28:56 +00:00
/* -----------------------------02.04.01 11:43--------------------------------
2000-12-15 11:23:15 +00:00
2001-04-03 06:28:56 +00:00
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > SAL_CALL SwXParagraph : : GetPropertyValues_Impl (
2003-11-07 14:13:02 +00:00
const uno : : Sequence < OUString > & rPropertyNames )
2007-06-05 16:34:38 +00:00
throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > aValues ( rPropertyNames . getLength ( ) ) ;
2000-12-15 11:23:15 +00:00
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( pUnoCrsr )
{
2007-06-05 16:34:38 +00:00
uno : : Any * pValues = aValues . getArray ( ) ;
2001-04-03 06:28:56 +00:00
const OUString * pPropertyNames = rPropertyNames . getConstArray ( ) ;
const SfxItemPropertyMap * pMap = aPropSet . getPropertyMap ( ) ;
2001-05-09 08:28:33 +00:00
SwNode & rTxtNode = pUnoCrsr - > GetPoint ( ) - > nNode . GetNode ( ) ;
2006-12-01 14:52:12 +00:00
const SwAttrSet & rAttrSet = ( ( SwTxtNode & ) rTxtNode ) . GetSwAttrSet ( ) ;
2001-04-03 06:28:56 +00:00
for ( sal_Int32 nProp = 0 ; nProp < rPropertyNames . getLength ( ) ; nProp + + )
2000-12-15 11:23:15 +00:00
{
2001-04-03 06:28:56 +00:00
pMap = SfxItemPropertyMap : : GetByName ( pMap , pPropertyNames [ nProp ] ) ;
2000-12-15 11:23:15 +00:00
if ( pMap )
{
2001-04-03 06:28:56 +00:00
if ( ! SwXParagraph : : getDefaultTextContentValue (
pValues [ nProp ] , pPropertyNames [ nProp ] , pMap - > nWID ) )
{
BOOL bDone = FALSE ;
2007-06-05 16:34:38 +00:00
beans : : PropertyState eTemp ;
2001-04-03 06:28:56 +00:00
bDone = SwUnoCursorHelper : : getCrsrPropertyValue (
2001-06-07 07:01:20 +00:00
pMap , * pUnoCrsr , & ( pValues [ nProp ] ) , eTemp , rTxtNode . GetTxtNode ( ) ) ;
2001-04-03 06:28:56 +00:00
if ( ! bDone )
pValues [ nProp ] = aPropSet . getPropertyValue ( * pMap , rAttrSet ) ;
}
2001-04-05 12:22:59 +00:00
+ + pMap ;
2000-12-15 11:23:15 +00:00
}
else
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + pPropertyNames [ nProp ] , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2000-12-15 11:23:15 +00:00
}
}
else
2007-06-05 16:34:38 +00:00
throw uno : : RuntimeException ( ) ;
2001-04-03 06:28:56 +00:00
return aValues ;
2000-12-15 11:23:15 +00:00
}
2003-11-07 14:13:02 +00:00
/* -----------------------------04.11.03 11:43--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > SwXParagraph : : getPropertyValues (
const uno : : Sequence < OUString > & rPropertyNames )
throw ( uno : : RuntimeException )
2003-11-07 14:13:02 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Sequence < uno : : Any > aValues ;
2003-11-07 14:13:02 +00:00
// workaround for bad designed API
try
{
aValues = GetPropertyValues_Impl ( rPropertyNames ) ;
}
2007-06-05 16:34:38 +00:00
catch ( beans : : UnknownPropertyException & )
2003-11-07 14:13:02 +00:00
{
2007-06-05 16:34:38 +00:00
throw uno : : RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property exception caught " ) ) , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2003-11-07 14:13:02 +00:00
}
2007-06-05 16:34:38 +00:00
catch ( lang : : WrappedTargetException & )
2003-11-07 14:13:02 +00:00
{
2007-06-05 16:34:38 +00:00
throw uno : : RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " WrappedTargetException caught " ) ) , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2003-11-07 14:13:02 +00:00
}
return aValues ;
}
2001-04-03 06:28:56 +00:00
/* -----------------------------02.04.01 11:43--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : addPropertiesChangeListener (
2007-09-27 08:38:20 +00:00
const uno : : Sequence < OUString > & /*aPropertyNames*/ ,
const uno : : Reference < beans : : XPropertiesChangeListener > & /*xListener*/ )
2007-06-05 16:34:38 +00:00
throw ( uno : : RuntimeException )
2001-04-03 06:28:56 +00:00
{ }
/* -----------------------------02.04.01 11:43--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : removePropertiesChangeListener (
2007-09-27 08:38:20 +00:00
const uno : : Reference < beans : : XPropertiesChangeListener > & /*xListener*/ )
2007-06-05 16:34:38 +00:00
throw ( uno : : RuntimeException )
2001-04-03 06:28:56 +00:00
{ }
/* -----------------------------02.04.01 11:43--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : firePropertiesChangeEvent (
2007-09-27 08:38:20 +00:00
const uno : : Sequence < OUString > & /*aPropertyNames*/ ,
const uno : : Reference < beans : : XPropertiesChangeListener > & /*xListener*/ )
2007-06-05 16:34:38 +00:00
throw ( uno : : RuntimeException )
2001-04-03 06:28:56 +00:00
{ }
2004-03-17 08:36:36 +00:00
/* -----------------------------25.09.03 11:09--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2005-04-18 10:30:13 +00:00
/* disabled for #i46921#
2004-03-17 08:36:36 +00:00
uno : : Sequence < SetPropertyTolerantFailed > SAL_CALL SwXParagraph : : setPropertyValuesTolerant (
const uno : : Sequence < OUString > & rPropertyNames ,
2007-06-05 16:34:38 +00:00
const uno : : Sequence < uno : : Any > & rValues )
2004-03-17 08:36:36 +00:00
throw ( lang : : IllegalArgumentException , uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
if ( rPropertyNames . getLength ( ) ! = rValues . getLength ( ) )
2007-06-05 16:34:38 +00:00
throw lang : : IllegalArgumentException ( ) ;
2004-03-17 08:36:36 +00:00
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( ! pUnoCrsr )
2007-06-05 16:34:38 +00:00
throw uno : : RuntimeException ( ) ;
2004-03-17 08:36:36 +00:00
SwNode & rTxtNode = pUnoCrsr - > GetPoint ( ) - > nNode . GetNode ( ) ;
SwAttrSet & rAttrSet = ( ( SwTxtNode & ) rTxtNode ) . GetSwAttrSet ( ) ;
USHORT nAttrCount = rAttrSet . Count ( ) ;
sal_Int32 nProps = rPropertyNames . getLength ( ) ;
const OUString * pProp = rPropertyNames . getConstArray ( ) ;
sal_Int32 nVals = rValues . getLength ( ) ;
2007-06-05 16:34:38 +00:00
const uno : : Any * pValue = rValues . getConstArray ( ) ;
2004-03-17 08:36:36 +00:00
sal_Int32 nFailed = 0 ;
uno : : Sequence < SetPropertyTolerantFailed > aFailed ( nProps ) ;
SetPropertyTolerantFailed * pFailed = aFailed . getArray ( ) ;
// get entry to start with
const SfxItemPropertyMap * pStartEntry = aPropSet . getPropertyMap ( ) ;
OUString sTmp ;
SwParaSelection aParaSel ( pUnoCrsr ) ;
for ( sal_Int32 i = 0 ; i < nProps ; + + i )
{
try
{
pFailed [ nFailed ] . Name = pProp [ i ] ;
const SfxItemPropertyMap * pEntry =
SfxItemPropertyMap : : GetByName ( pStartEntry , pProp [ i ] ) ;
if ( ! pEntry )
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : UNKNOWN_PROPERTY ;
else
{
// set property value
// (compare to SwXParagraph::setPropertyValues)
2007-06-05 16:34:38 +00:00
if ( pEntry - > nFlags & beans : : PropertyAttribute : : READONLY )
2004-03-17 08:36:36 +00:00
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : PROPERTY_VETO ;
else
{
SwXTextCursor : : SetPropertyValue (
* pUnoCrsr , aPropSet , sTmp , pValue [ i ] , pEntry ) ;
}
// continue with search for next property after current entry
// (property map and sequence of property names are sorted!)
pStartEntry = + + pEntry ;
}
}
2007-06-05 16:34:38 +00:00
catch ( beans : : UnknownPropertyException & )
2004-03-17 08:36:36 +00:00
{
// should not occur because property was searched for before
DBG_ERROR ( " unexpected exception catched " ) ;
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : UNKNOWN_PROPERTY ;
}
2007-06-05 16:34:38 +00:00
catch ( lang : : IllegalArgumentException & )
2004-03-17 08:36:36 +00:00
{
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : ILLEGAL_ARGUMENT ;
}
2007-06-05 16:34:38 +00:00
catch ( beans : : PropertyVetoException & )
2004-03-17 08:36:36 +00:00
{
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : PROPERTY_VETO ;
}
2007-06-05 16:34:38 +00:00
catch ( lang : : WrappedTargetException & )
2004-03-17 08:36:36 +00:00
{
pFailed [ nFailed + + ] . Result = TolerantPropertySetResultType : : WRAPPED_TARGET ;
}
}
aFailed . realloc ( nFailed ) ;
return aFailed ;
}
uno : : Sequence < GetPropertyTolerantResult > SAL_CALL SwXParagraph : : getPropertyValuesTolerant (
const uno : : Sequence < OUString > & rPropertyNames )
throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
uno : : Sequence < GetDirectPropertyTolerantResult > aTmpRes (
GetPropertyValuesTolerant_Impl ( rPropertyNames , sal_False ) ) ;
const GetDirectPropertyTolerantResult * pTmpRes = aTmpRes . getConstArray ( ) ;
// copy temporary result to final result type
sal_Int32 nLen = aTmpRes . getLength ( ) ;
uno : : Sequence < GetPropertyTolerantResult > aRes ( nLen ) ;
GetPropertyTolerantResult * pRes = aRes . getArray ( ) ;
for ( sal_Int32 i = 0 ; i < nLen ; i + + )
* pRes + + = * pTmpRes + + ;
return aRes ;
}
uno : : Sequence < GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph : : getDirectPropertyValuesTolerant (
const uno : : Sequence < OUString > & rPropertyNames )
throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
return GetPropertyValuesTolerant_Impl ( rPropertyNames , sal_True ) ;
}
uno : : Sequence < GetDirectPropertyTolerantResult > SAL_CALL SwXParagraph : : GetPropertyValuesTolerant_Impl (
const uno : : Sequence < OUString > & rPropertyNames ,
sal_Bool bDirectValuesOnly )
throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( ! pUnoCrsr )
throw RuntimeException ( ) ;
2005-04-18 14:12:11 +00:00
SwTxtNode * pTxtNode = pUnoCrsr - > GetPoint ( ) - > nNode . GetNode ( ) . GetTxtNode ( ) ;
DBG_ASSERT ( pTxtNode ! = NULL , " need text node " ) ;
// #i46786# Use SwAttrSet pointer for determining the state.
// Use the value SwAttrSet (from the paragraph OR the style)
// for determining the actual value(s).
const SwAttrSet * pAttrSet = pTxtNode - > GetpSwAttrSet ( ) ;
const SwAttrSet & rValueAttrSet = pTxtNode - > GetSwAttrSet ( ) ;
2004-03-17 08:36:36 +00:00
sal_Int32 nProps = rPropertyNames . getLength ( ) ;
const OUString * pProp = rPropertyNames . getConstArray ( ) ;
uno : : Sequence < GetDirectPropertyTolerantResult > aResult ( nProps ) ;
GetDirectPropertyTolerantResult * pResult = aResult . getArray ( ) ;
sal_Int32 nIdx = 0 ;
// get entry to start with
const SfxItemPropertyMap * pStartEntry = aPropSet . getPropertyMap ( ) ;
for ( sal_Int32 i = 0 ; i < nProps ; + + i )
{
DBG_ASSERT ( nIdx < nProps , " index out ouf bounds " ) ;
GetDirectPropertyTolerantResult & rResult = pResult [ nIdx ] ;
try
{
rResult . Name = pProp [ i ] ;
const SfxItemPropertyMap * pEntry =
SfxItemPropertyMap : : GetByName ( pStartEntry , pProp [ i ] ) ;
if ( ! pEntry ) // property available?
rResult . Result = TolerantPropertySetResultType : : UNKNOWN_PROPERTY ;
else
{
// get property state
// (compare to SwXParagraph::getPropertyState)
sal_Bool bAttrSetFetched = sal_True ;
PropertyState eState = lcl_SwXParagraph_getPropertyState (
* pUnoCrsr , & pAttrSet , * pEntry , bAttrSetFetched ) ;
rResult . State = eState ;
// if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState)
// rResult.Result = TolerantPropertySetResultType::NO_DIRECT_VALUE;
// else
rResult . Result = TolerantPropertySetResultType : : UNKNOWN_FAILURE ;
if ( ! bDirectValuesOnly | | PropertyState_DIRECT_VALUE = = eState )
{
// get property value
// (compare to SwXParagraph::getPropertyValue(s))
2007-06-05 16:34:38 +00:00
uno : : Any aValue ;
2004-03-17 08:36:36 +00:00
if ( ! SwXParagraph : : getDefaultTextContentValue (
aValue , pProp [ i ] , pEntry - > nWID ) )
{
// handle properties that are not part of the attribute
// and thus only pretendend to be paragraph attributes
BOOL bDone = FALSE ;
PropertyState eTemp ;
bDone = SwUnoCursorHelper : : getCrsrPropertyValue (
2005-04-18 14:12:11 +00:00
pEntry , * pUnoCrsr , & aValue , eTemp , pTxtNode ) ;
2004-03-17 08:36:36 +00:00
// if not found try the real paragraph attributes...
if ( ! bDone )
2005-04-18 14:12:11 +00:00
aValue = aPropSet . getPropertyValue ( * pEntry , rValueAttrSet ) ;
2004-03-17 08:36:36 +00:00
}
rResult . Value = aValue ;
rResult . Result = TolerantPropertySetResultType : : SUCCESS ;
nIdx + + ;
}
// this assertion should never occur!
DBG_ASSERT ( nIdx < 1 | | pResult [ nIdx - 1 ] . Result ! = TolerantPropertySetResultType : : UNKNOWN_FAILURE ,
" unknown failure while retrieving property " ) ;
// continue with search for next property after current entry
// (property map and sequence of property names are sorted!)
pStartEntry = + + pEntry ;
}
}
2007-06-05 16:34:38 +00:00
catch ( beans : : UnknownPropertyException & )
2004-03-17 08:36:36 +00:00
{
// should not occur because property was searched for before
DBG_ERROR ( " unexpected exception catched " ) ;
rResult . Result = TolerantPropertySetResultType : : UNKNOWN_PROPERTY ;
}
2007-06-05 16:34:38 +00:00
catch ( lang : : IllegalArgumentException & )
2004-03-17 08:36:36 +00:00
{
rResult . Result = TolerantPropertySetResultType : : ILLEGAL_ARGUMENT ;
}
2007-06-05 16:34:38 +00:00
catch ( beans : : PropertyVetoException & )
2004-03-17 08:36:36 +00:00
{
rResult . Result = TolerantPropertySetResultType : : PROPERTY_VETO ;
}
2007-06-05 16:34:38 +00:00
catch ( lang : : WrappedTargetException & )
2004-03-17 08:36:36 +00:00
{
rResult . Result = TolerantPropertySetResultType : : WRAPPED_TARGET ;
}
}
// resize to actually used size
aResult . realloc ( nIdx ) ;
return aResult ;
}
2005-04-18 10:30:13 +00:00
*/
2000-12-15 11:23:15 +00:00
/* -----------------------------12.09.00 11:09--------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
BOOL SwXParagraph : : getDefaultTextContentValue ( uno : : Any & rAny , const OUString & rPropertyName , USHORT nWID )
2000-12-15 11:23:15 +00:00
{
if ( ! nWID )
{
2001-06-13 11:40:53 +00:00
if ( rPropertyName . equalsAsciiL ( SW_PROP_NAME ( UNO_NAME_ANCHOR_TYPE ) ) )
2000-12-15 11:23:15 +00:00
nWID = FN_UNO_ANCHOR_TYPE ;
2001-06-13 11:40:53 +00:00
else if ( rPropertyName . equalsAsciiL ( SW_PROP_NAME ( UNO_NAME_ANCHOR_TYPES ) ) )
2000-12-15 11:23:15 +00:00
nWID = FN_UNO_ANCHOR_TYPES ;
2001-06-13 11:40:53 +00:00
else if ( rPropertyName . equalsAsciiL ( SW_PROP_NAME ( UNO_NAME_TEXT_WRAP ) ) )
2000-12-15 11:23:15 +00:00
nWID = FN_UNO_TEXT_WRAP ;
else
return FALSE ;
}
switch ( nWID )
{
2007-06-05 16:34:38 +00:00
case FN_UNO_TEXT_WRAP : rAny < < = text : : WrapTextMode_NONE ; break ;
case FN_UNO_ANCHOR_TYPE : rAny < < = text : : TextContentAnchorType_AT_PARAGRAPH ; break ;
2000-12-15 11:23:15 +00:00
case FN_UNO_ANCHOR_TYPES :
2007-06-05 16:34:38 +00:00
{ uno : : Sequence < text : : TextContentAnchorType > aTypes ( 1 ) ;
text : : TextContentAnchorType * pArray = aTypes . getArray ( ) ;
pArray [ 0 ] = text : : TextContentAnchorType_AT_PARAGRAPH ;
rAny . setValue ( & aTypes , : : getCppuType ( ( uno : : Sequence < text : : TextContentAnchorType > * ) 0 ) ) ;
2000-12-15 11:23:15 +00:00
}
break ;
default :
return FALSE ;
}
return TRUE ;
}
/*-- 11.12.98 08:12:50---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : addPropertyChangeListener (
2007-09-27 08:38:20 +00:00
const OUString & /*PropertyName*/ ,
const uno : : Reference < beans : : XPropertyChangeListener > & /*aListener*/ )
2000-12-15 11:23:15 +00:00
throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
{
2008-11-10 15:06:12 +00:00
DBG_WARNING ( " not implemented " ) ;
2000-12-15 11:23:15 +00:00
}
/*-- 11.12.98 08:12:50---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-09-27 08:38:20 +00:00
void SwXParagraph : : removePropertyChangeListener ( const OUString & /*PropertyName*/ , const uno : : Reference < beans : : XPropertyChangeListener > & /*aListener*/ ) throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
2008-11-10 15:06:12 +00:00
DBG_WARNING ( " not implemented " ) ;
2000-12-15 11:23:15 +00:00
}
/*-- 11.12.98 08:12:50---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-09-27 08:38:20 +00:00
void SwXParagraph : : addVetoableChangeListener ( const OUString & /*PropertyName*/ , const uno : : Reference < beans : : XVetoableChangeListener > & /*aListener*/ ) throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
2008-11-10 15:06:12 +00:00
DBG_WARNING ( " not implemented " ) ;
2000-12-15 11:23:15 +00:00
}
/*-- 11.12.98 08:12:51---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-09-27 08:38:20 +00:00
void SwXParagraph : : removeVetoableChangeListener ( const OUString & /*PropertyName*/ , const uno : : Reference < beans : : XVetoableChangeListener > & /*aListener*/ )
2000-12-15 11:23:15 +00:00
throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
{
2008-11-10 15:06:12 +00:00
DBG_WARNING ( " not implemented " ) ;
2000-12-15 11:23:15 +00:00
}
//-----------------------------------------------------------------------------
beans : : PropertyState lcl_SwXParagraph_getPropertyState (
SwUnoCrsr & rUnoCrsr ,
const SwAttrSet * * ppSet ,
2001-06-07 07:01:20 +00:00
const SfxItemPropertyMap & rMap ,
sal_Bool & rAttrSetFetched )
2000-12-15 11:23:15 +00:00
throw ( beans : : UnknownPropertyException )
{
beans : : PropertyState eRet = beans : : PropertyState_DEFAULT_VALUE ;
2001-06-07 07:01:20 +00:00
if ( ! ( * ppSet ) & & ! rAttrSetFetched )
2000-12-15 11:23:15 +00:00
{
SwNode & rTxtNode = rUnoCrsr . GetPoint ( ) - > nNode . GetNode ( ) ;
( * ppSet ) = ( ( SwTxtNode & ) rTxtNode ) . GetpSwAttrSet ( ) ;
2001-06-07 07:01:20 +00:00
rAttrSetFetched = sal_True ;
2000-12-15 11:23:15 +00:00
}
2001-06-07 07:01:20 +00:00
switch ( rMap . nWID )
2000-12-15 11:23:15 +00:00
{
2001-06-07 07:01:20 +00:00
case FN_UNO_NUM_RULES :
2000-12-15 11:23:15 +00:00
//wenn eine Numerierung gesetzt ist, dann hier herausreichen, sonst nichts tun
2001-10-09 13:57:38 +00:00
SwUnoCursorHelper : : getNumberingProperty ( rUnoCrsr , eRet , NULL ) ;
2001-06-07 07:01:20 +00:00
break ;
2001-07-19 15:34:00 +00:00
case FN_UNO_ANCHOR_TYPES :
break ;
case RES_ANCHOR :
if ( MID_SURROUND_SURROUNDTYPE ! = rMap . nMemberId )
goto lcl_SwXParagraph_getPropertyStateDEFAULT ;
break ;
case RES_SURROUND :
if ( MID_ANCHOR_ANCHORTYPE ! = rMap . nMemberId )
goto lcl_SwXParagraph_getPropertyStateDEFAULT ;
break ;
2001-06-07 07:01:20 +00:00
case FN_UNO_PARA_STYLE :
case FN_UNO_PARA_CONDITIONAL_STYLE_NAME :
{
SwFmtColl * pFmt = SwXTextCursor : : GetCurTxtFmtColl (
rUnoCrsr , rMap . nWID = = FN_UNO_PARA_CONDITIONAL_STYLE_NAME ) ;
2001-11-01 12:52:20 +00:00
eRet = pFmt ? beans : : PropertyState_DIRECT_VALUE
: beans : : PropertyState_AMBIGUOUS_VALUE ;
2001-06-07 07:01:20 +00:00
}
break ;
case FN_UNO_PAGE_STYLE :
{
2001-10-09 13:57:38 +00:00
String sVal ;
SwUnoCursorHelper : : GetCurPageStyle ( rUnoCrsr , sVal ) ;
2001-11-01 12:52:20 +00:00
eRet = sVal . Len ( ) ? beans : : PropertyState_DIRECT_VALUE
: beans : : PropertyState_AMBIGUOUS_VALUE ;
2001-06-07 07:01:20 +00:00
}
break ;
2001-07-19 15:34:00 +00:00
lcl_SwXParagraph_getPropertyStateDEFAULT :
2001-06-07 07:01:20 +00:00
default :
if ( ( * ppSet ) & & SFX_ITEM_SET = = ( * ppSet ) - > GetItemState ( rMap . nWID , FALSE ) )
eRet = beans : : PropertyState_DIRECT_VALUE ;
break ;
2000-12-15 11:23:15 +00:00
}
return eRet ;
}
/*-- 05.03.99 11:37:30---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
beans : : PropertyState SwXParagraph : : getPropertyState ( const OUString & rPropertyName )
throw ( beans : : UnknownPropertyException , uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
beans : : PropertyState eRet = beans : : PropertyState_DEFAULT_VALUE ;
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( pUnoCrsr )
{
const SwAttrSet * pSet = 0 ;
2001-03-29 13:40:38 +00:00
const SfxItemPropertyMap * pMap = SfxItemPropertyMap : : GetByName (
aPropSet . getPropertyMap ( ) , rPropertyName ) ;
if ( ! pMap )
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + rPropertyName , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2001-06-07 07:01:20 +00:00
sal_Bool bDummy = sal_False ;
eRet = lcl_SwXParagraph_getPropertyState ( * pUnoCrsr , & pSet , * pMap ,
bDummy ) ;
2000-12-15 11:23:15 +00:00
}
else
throw uno : : RuntimeException ( ) ;
return eRet ;
}
/*-- 05.03.99 11:37:32---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Sequence < beans : : PropertyState > SwXParagraph : : getPropertyStates (
const uno : : Sequence < OUString > & PropertyNames )
throw ( beans : : UnknownPropertyException , uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
const OUString * pNames = PropertyNames . getConstArray ( ) ;
uno : : Sequence < beans : : PropertyState > aRet ( PropertyNames . getLength ( ) ) ;
beans : : PropertyState * pStates = aRet . getArray ( ) ;
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
2001-03-29 13:40:38 +00:00
const SfxItemPropertyMap * pMap = aPropSet . getPropertyMap ( ) ;
2000-12-15 11:23:15 +00:00
if ( pUnoCrsr )
{
const SwAttrSet * pSet = 0 ;
2001-06-07 07:01:20 +00:00
sal_Bool bAttrSetFetched = sal_False ;
2001-07-19 15:34:00 +00:00
for ( sal_Int32 i = 0 , nEnd = PropertyNames . getLength ( ) ; i < nEnd ; i + + , + + pStates , + + pMap , + + pNames )
2001-03-29 13:40:38 +00:00
{
2001-07-19 15:34:00 +00:00
pMap = SfxItemPropertyMap : : GetByName ( pMap , * pNames ) ;
2001-03-29 13:40:38 +00:00
if ( ! pMap )
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + * pNames , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2001-11-01 12:52:20 +00:00
if ( bAttrSetFetched & & ! pSet & &
pMap - > nWID > = RES_CHRATR_BEGIN & &
pMap - > nWID < = RES_UNKNOWNATR_END )
2001-07-19 15:34:00 +00:00
* pStates = beans : : PropertyState_DEFAULT_VALUE ;
else
* pStates = lcl_SwXParagraph_getPropertyState ( * pUnoCrsr , & pSet , * pMap , bAttrSetFetched ) ;
2001-03-29 13:40:38 +00:00
}
2000-12-15 11:23:15 +00:00
}
else
throw uno : : RuntimeException ( ) ;
return aRet ;
}
/*-- 05.03.99 11:37:33---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : setPropertyToDefault ( const OUString & rPropertyName )
throw ( beans : : UnknownPropertyException , 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_ANCHOR_TYPE ) ) | |
rPropertyName . equalsAsciiL ( SW_PROP_NAME ( UNO_NAME_ANCHOR_TYPES ) ) | |
rPropertyName . equalsAsciiL ( SW_PROP_NAME ( UNO_NAME_TEXT_WRAP ) ) )
return ;
2000-12-15 11:23:15 +00:00
// Absatz selektieren
SwParaSelection aParaSel ( pUnoCrsr ) ;
const SfxItemPropertyMap * pMap = SfxItemPropertyMap : : GetByName (
aPropSet . getPropertyMap ( ) , rPropertyName ) ;
if ( pMap )
{
2007-06-05 16:34:38 +00:00
if ( pMap - > nFlags & beans : : PropertyAttribute : : READONLY )
throw uno : : RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Property is read-only: " ) ) + rPropertyName , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2001-10-16 10:58:14 +00:00
2000-12-15 11:23:15 +00:00
if ( pMap - > nWID < RES_FRMATR_END )
{
SvUShortsSort aWhichIds ;
aWhichIds . Insert ( pMap - > nWID ) ;
if ( pMap - > nWID < RES_PARATR_BEGIN )
2008-03-05 16:12:49 +00:00
pUnoCrsr - > GetDoc ( ) - > ResetAttrs ( * pUnoCrsr , sal_True , & aWhichIds ) ;
2000-12-15 11:23:15 +00:00
else
{
//fuer Absatzattribute muss die Selektion jeweils auf
//Absatzgrenzen erweitert werden
SwPosition aStart = * pUnoCrsr - > Start ( ) ;
SwPosition aEnd = * pUnoCrsr - > End ( ) ;
SwUnoCrsr * pTemp = pUnoCrsr - > GetDoc ( ) - > CreateUnoCrsr ( aStart , sal_False ) ;
if ( ! SwUnoCursorHelper : : IsStartOfPara ( * pTemp ) )
{
pTemp - > MovePara ( fnParaCurr , fnParaStart ) ;
}
pTemp - > SetMark ( ) ;
* pTemp - > GetPoint ( ) = aEnd ;
//pTemp->Exchange();
SwXTextCursor : : SelectPam ( * pTemp , sal_True ) ;
if ( ! SwUnoCursorHelper : : IsEndOfPara ( * pTemp ) )
{
pTemp - > MovePara ( fnParaCurr , fnParaEnd ) ;
}
2008-03-05 16:12:49 +00:00
pTemp - > GetDoc ( ) - > ResetAttrs ( * pTemp , sal_True , & aWhichIds ) ;
2000-12-15 11:23:15 +00:00
delete pTemp ;
}
}
else
SwUnoCursorHelper : : resetCrsrPropertyValue ( pMap , * pUnoCrsr ) ;
}
else
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + rPropertyName , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2000-12-15 11:23:15 +00:00
}
else
throw uno : : RuntimeException ( ) ;
}
/*-- 05.03.99 11:37:33---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Any SwXParagraph : : getPropertyDefault ( const OUString & rPropertyName )
throw ( beans : : UnknownPropertyException , lang : : WrappedTargetException , uno : : RuntimeException )
{
uno : : Any aRet ;
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( pUnoCrsr )
{
if ( SwXParagraph : : getDefaultTextContentValue ( aRet , rPropertyName ) )
return aRet ;
const SfxItemPropertyMap * pMap = SfxItemPropertyMap : : GetByName (
aPropSet . getPropertyMap ( ) , rPropertyName ) ;
if ( pMap )
{
if ( pMap - > nWID < RES_FRMATR_END )
{
const SfxPoolItem & rDefItem =
pUnoCrsr - > GetDoc ( ) - > GetAttrPool ( ) . GetDefaultItem ( pMap - > nWID ) ;
rDefItem . QueryValue ( aRet , pMap - > nMemberId ) ;
}
}
else
2007-06-05 16:34:38 +00:00
throw beans : : UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown property: " ) ) + rPropertyName , static_cast < cppu : : OWeakObject * > ( this ) ) ;
2000-12-15 11:23:15 +00:00
}
else
throw uno : : RuntimeException ( ) ;
return aRet ;
}
/*-- 11.12.98 08:12:51---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-09-27 08:38:20 +00:00
void SwXParagraph : : attach ( const uno : : Reference < text : : XTextRange > & /*xTextRange*/ )
2000-12-15 11:23:15 +00:00
throw ( lang : : IllegalArgumentException , uno : : RuntimeException )
{
2002-09-12 12:12:13 +00:00
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
// SwXParagraph will only created in order to be inserteb by
// 'insertTextContentBefore' or 'insertTextContentAfter' therefore
// they cannot be attached
throw uno : : RuntimeException ( ) ;
2000-12-15 11:23:15 +00:00
}
/*-- 11.12.98 08:12:51---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > SwXParagraph : : getAnchor ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > aRet ;
2000-12-15 11:23:15 +00:00
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( pUnoCrsr )
{
// Absatz selektieren
SwParaSelection aSelection ( pUnoCrsr ) ;
aRet = new SwXTextRange ( * pUnoCrsr , xParentText ) ;
}
else
throw uno : : RuntimeException ( ) ;
return aRet ;
}
/*-- 11.12.98 08:12:52---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : dispose ( void ) throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
SwUnoCrsr * pUnoCrsr = ( ( SwXParagraph * ) this ) - > GetCrsr ( ) ;
if ( pUnoCrsr )
{
// Absatz selektieren
2001-06-13 10:27:35 +00:00
{
SwParaSelection aSelection ( pUnoCrsr ) ;
pUnoCrsr - > GetDoc ( ) - > DelFullPara ( * pUnoCrsr ) ;
}
2000-12-21 13:52:16 +00:00
aLstnrCntnr . Disposing ( ) ;
2001-05-30 10:28:11 +00:00
delete pUnoCrsr ;
2000-12-15 11:23:15 +00:00
}
else
throw uno : : RuntimeException ( ) ;
}
/*-- 11.12.98 08:12:52---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : addEventListener ( const uno : : Reference < lang : : XEventListener > & aListener ) throw ( uno : : RuntimeException )
{
if ( ! GetRegisteredIn ( ) )
throw uno : : RuntimeException ( ) ;
aLstnrCntnr . AddListener ( aListener ) ;
}
/*-- 11.12.98 08:12:53---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : removeEventListener ( const uno : : Reference < lang : : XEventListener > & aListener ) throw ( uno : : RuntimeException )
{
if ( ! GetRegisteredIn ( ) | | ! aLstnrCntnr . RemoveListener ( aListener ) )
throw uno : : RuntimeException ( ) ;
}
/*-- 11.12.98 08:12:53---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Reference < container : : XEnumeration > SwXParagraph : : createEnumeration ( void ) throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
uno : : Reference < container : : XEnumeration > aRef ;
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
2001-05-23 08:10:48 +00:00
aRef = new SwXTextPortionEnumeration ( * pUnoCrsr , xParentText , nSelectionStartPos , nSelectionEndPos ) ;
2000-12-15 11:23:15 +00:00
else
throw uno : : RuntimeException ( ) ;
return aRef ;
}
/*-- 11.12.98 08:12:54---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Type SwXParagraph : : getElementType ( void ) throw ( uno : : RuntimeException )
{
2007-06-05 16:34:38 +00:00
return : : getCppuType ( ( uno : : Reference < text : : XTextRange > * ) 0 ) ;
2000-12-15 11:23:15 +00:00
}
/*-- 11.12.98 08:12:54---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
sal_Bool SwXParagraph : : hasElements ( void ) throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
if ( ( ( SwXParagraph * ) this ) - > GetCrsr ( ) )
return sal_True ;
else
return sal_False ;
}
/*-- 11.12.98 08:12:55---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XText > SwXParagraph : : getText ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
return xParentText ;
}
/*-- 11.12.98 08:12:55---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > SwXParagraph : : getStart ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > xRet ;
2000-12-15 11:23:15 +00:00
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
{
2003-11-07 14:13:02 +00:00
SwParaSelection aSelection ( pUnoCrsr ) ;
2000-12-15 11:23:15 +00:00
SwPaM aPam ( * pUnoCrsr - > Start ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XText > xParent = getText ( ) ;
2000-12-15 11:23:15 +00:00
xRet = new SwXTextRange ( aPam , xParent ) ;
}
else
throw uno : : RuntimeException ( ) ;
return xRet ;
}
/*-- 11.12.98 08:12:56---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > SwXParagraph : : getEnd ( void ) throw ( uno : : RuntimeException )
2000-12-15 11:23:15 +00:00
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XTextRange > xRet ;
2000-12-15 11:23:15 +00:00
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
{
2003-11-07 14:13:02 +00:00
SwParaSelection aSelection ( pUnoCrsr ) ;
2000-12-15 11:23:15 +00:00
SwPaM aPam ( * pUnoCrsr - > End ( ) ) ;
2007-06-05 16:34:38 +00:00
uno : : Reference < text : : XText > xParent = getText ( ) ;
2000-12-15 11:23:15 +00:00
xRet = new SwXTextRange ( aPam , xParent ) ;
}
else
throw uno : : RuntimeException ( ) ;
return xRet ;
}
/*-- 11.12.98 08:12:56---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
OUString SwXParagraph : : getString ( void ) throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
OUString aRet ;
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
2001-03-08 09:13:14 +00:00
{
SwParaSelection aSelection ( pUnoCrsr ) ;
SwXTextCursor : : getTextFromPam ( * pUnoCrsr , aRet ) ;
}
2000-12-15 11:23:15 +00:00
else if ( IsDescriptor ( ) )
aRet = m_sText ;
else
throw uno : : RuntimeException ( ) ;
return aRet ;
}
2000-12-21 13:52:16 +00:00
/*-- 11.12.98 08:12:57---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : setString ( const OUString & aString ) throw ( uno : : RuntimeException )
{
vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( pUnoCrsr )
{
if ( ! SwUnoCursorHelper : : IsStartOfPara ( * pUnoCrsr ) )
pUnoCrsr - > MovePara ( fnParaCurr , fnParaStart ) ;
SwXTextCursor : : SelectPam ( * pUnoCrsr , sal_True ) ;
if ( pUnoCrsr - > GetNode ( ) - > GetTxtNode ( ) - > GetTxt ( ) . Len ( ) )
pUnoCrsr - > MovePara ( fnParaCurr , fnParaEnd ) ;
SwXTextCursor : : SetString ( * pUnoCrsr , aString ) ;
SwXTextCursor : : SelectPam ( * pUnoCrsr , sal_False ) ;
}
else if ( IsDescriptor ( ) )
m_sText = aString ;
else
throw uno : : RuntimeException ( ) ;
}
/* -----------------23.03.99 12:49-------------------
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Reference < container : : XEnumeration > SwXParagraph : : createContentEnumeration ( const OUString & rServiceName )
throw ( uno : : RuntimeException )
{
SwUnoCrsr * pUnoCrsr = GetCrsr ( ) ;
if ( ! pUnoCrsr | | COMPARE_EQUAL ! = rServiceName . compareToAscii ( " com.sun.star.text.TextContent " ) )
throw uno : : RuntimeException ( ) ;
uno : : Reference < container : : XEnumeration > xRet = new SwXParaFrameEnumeration ( * pUnoCrsr , PARAFRAME_PORTION_PARAGRAPH ) ;
return xRet ;
}
/* -----------------23.03.99 12:49-------------------
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
uno : : Sequence < OUString > SwXParagraph : : getAvailableServiceNames ( void ) throw ( uno : : RuntimeException )
{
uno : : Sequence < OUString > aRet ( 1 ) ;
OUString * pArray = aRet . getArray ( ) ;
pArray [ 0 ] = C2U ( " com.sun.star.text.TextContent " ) ;
return aRet ;
}
/*-- 11.12.98 08:12:58---------------------------------------------------
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
void SwXParagraph : : Modify ( SfxPoolItem * pOld , SfxPoolItem * pNew )
{
ClientModify ( this , pOld , pNew ) ;
if ( ! GetRegisteredIn ( ) )
aLstnrCntnr . Disposing ( ) ;
}
2000-12-15 11:23:15 +00:00