1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoport.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svtools/itemprop.hxx>
39 #include <unocrsrhelper.hxx>
40 #include <unoport.hxx>
43 #include <unoprnms.hxx>
49 #include <fmtflcnt.hxx>
52 #include <com/sun/star/beans/PropertyAttribute.hpp>
53 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
54 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
55 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
58 using namespace ::com::sun::star
;
59 using ::rtl::OUString
;
62 /******************************************************************
64 ******************************************************************/
66 static void init(SwXTextPortion
& rPortion
, const SwUnoCrsr
* pPortionCursor
)
68 SwUnoCrsr
* pUnoCursor
=
69 pPortionCursor
->GetDoc()->CreateUnoCrsr(*pPortionCursor
->GetPoint());
70 if (pPortionCursor
->HasMark())
72 pUnoCursor
->SetMark();
73 *pUnoCursor
->GetMark() = *pPortionCursor
->GetMark();
75 pUnoCursor
->Add(& rPortion
);
78 /*-- 11.12.98 09:56:55---------------------------------------------------
80 -----------------------------------------------------------------------*/
81 SwXTextPortion::SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
82 uno::Reference
< text::XText
> const& rParent
,
83 SwTextPortionType eType
)
84 : m_ListenerContainer( static_cast<text::XTextRange
*>(this) )
85 , m_pPropSet(aSwMapProvider
.GetPropertySet(
86 (PORTION_REDLINE_START
== eType
||
87 PORTION_REDLINE_END
== eType
)
88 ? PROPERTY_MAP_REDLINE_PORTION
89 : PROPERTY_MAP_TEXTPORTION_EXTENSIONS
))
90 , m_xParentText(rParent
)
95 , m_FrameDepend(this, 0)
97 , m_ePortionType(eType
)
98 , m_bIsCollapsed(false)
100 init(*this, pPortionCrsr
);
103 /* -----------------24.03.99 16:30-------------------
105 * --------------------------------------------------*/
106 SwXTextPortion::SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
107 uno::Reference
< text::XText
> const& rParent
,
109 : m_ListenerContainer( static_cast<text::XTextRange
*>(this) )
110 , m_pPropSet(aSwMapProvider
.GetPropertySet(
111 PROPERTY_MAP_TEXTPORTION_EXTENSIONS
))
112 , m_xParentText(rParent
)
117 , m_FrameDepend(this, &rFmt
)
119 , m_ePortionType(PORTION_FRAME
)
120 , m_bIsCollapsed(false)
122 init(*this, pPortionCrsr
);
125 /* -----------------------------19.02.01 10:52--------------------------------
127 ---------------------------------------------------------------------------*/
128 SwXTextPortion::SwXTextPortion(const SwUnoCrsr
* pPortionCrsr
,
129 SwTxtRuby
const& rAttr
,
130 uno::Reference
< text::XText
> const& xParent
,
132 : m_ListenerContainer( static_cast<text::XTextRange
*>(this) )
133 , m_pPropSet(aSwMapProvider
.GetPropertySet(
134 PROPERTY_MAP_TEXTPORTION_EXTENSIONS
))
135 , m_xParentText(xParent
)
136 , m_pRubyText ( bIsEnd
? 0 : new uno::Any
)
137 , m_pRubyStyle ( bIsEnd
? 0 : new uno::Any
)
138 , m_pRubyAdjust ( bIsEnd
? 0 : new uno::Any
)
139 , m_pRubyIsAbove( bIsEnd
? 0 : new uno::Any
)
140 , m_FrameDepend(this, 0)
142 , m_ePortionType( bIsEnd
? PORTION_RUBY_END
: PORTION_RUBY_START
)
143 , m_bIsCollapsed(false)
145 init(*this, pPortionCrsr
);
149 const SfxPoolItem
& rItem
= rAttr
.GetAttr();
150 rItem
.QueryValue(*m_pRubyText
, MID_RUBY_TEXT
);
151 rItem
.QueryValue(*m_pRubyStyle
, MID_RUBY_CHARSTYLE
);
152 rItem
.QueryValue(*m_pRubyAdjust
, MID_RUBY_ADJUST
);
153 rItem
.QueryValue(*m_pRubyIsAbove
, MID_RUBY_ABOVE
);
157 /*-- 11.12.98 09:56:55---------------------------------------------------
159 -----------------------------------------------------------------------*/
160 SwXTextPortion::~SwXTextPortion()
162 vos::OGuard
aGuard(Application::GetSolarMutex());
163 SwUnoCrsr
* pUnoCrsr
= GetCursor();
166 /*-- 11.12.98 09:56:56---------------------------------------------------
168 -----------------------------------------------------------------------*/
169 uno::Reference
< text::XText
> SwXTextPortion::getText()
170 throw( uno::RuntimeException
)
172 return m_xParentText
;
174 /*-- 11.12.98 09:56:56---------------------------------------------------
176 -----------------------------------------------------------------------*/
177 uno::Reference
< text::XTextRange
> SwXTextPortion::getStart()
178 throw( uno::RuntimeException
)
180 vos::OGuard
aGuard(Application::GetSolarMutex());
181 uno::Reference
< text::XTextRange
> xRet
;
182 SwUnoCrsr
* pUnoCrsr
= GetCursor();
184 throw uno::RuntimeException();
186 SwPaM
aPam(*pUnoCrsr
->Start());
187 uno::Reference
< text::XText
> xParent
= getText();
188 xRet
= new SwXTextRange(aPam
, xParent
);
191 /*-- 11.12.98 09:56:57---------------------------------------------------
193 -----------------------------------------------------------------------*/
194 uno::Reference
< text::XTextRange
> SwXTextPortion::getEnd()
195 throw( uno::RuntimeException
)
197 vos::OGuard
aGuard(Application::GetSolarMutex());
198 uno::Reference
< text::XTextRange
> xRet
;
199 SwUnoCrsr
* pUnoCrsr
= GetCursor();
201 throw uno::RuntimeException();
203 SwPaM
aPam(*pUnoCrsr
->End());
204 uno::Reference
< text::XText
> xParent
= getText();
205 xRet
= new SwXTextRange(aPam
, xParent
);
208 /*-- 11.12.98 09:56:57---------------------------------------------------
210 -----------------------------------------------------------------------*/
211 OUString
SwXTextPortion::getString()
212 throw( uno::RuntimeException
)
214 vos::OGuard
aGuard(Application::GetSolarMutex());
216 SwUnoCrsr
* pUnoCrsr
= GetCursor();
218 throw uno::RuntimeException();
220 // TextPortions are always within a paragraph
221 SwTxtNode
* pTxtNd
= pUnoCrsr
->GetNode()->GetTxtNode();
224 xub_StrLen nStt
= pUnoCrsr
->Start()->nContent
.GetIndex();
225 aTxt
= pTxtNd
->GetExpandTxt( nStt
,
226 pUnoCrsr
->End()->nContent
.GetIndex() - nStt
);
230 /*-- 11.12.98 09:56:57---------------------------------------------------
232 -----------------------------------------------------------------------*/
233 void SwXTextPortion::setString(const OUString
& aString
) throw( uno::RuntimeException
)
235 vos::OGuard
aGuard(Application::GetSolarMutex());
236 SwUnoCrsr
* pUnoCrsr
= GetCursor();
238 throw uno::RuntimeException();
240 SwXTextCursor::SetString(*pUnoCrsr
, aString
);
242 /*-- 11.12.98 09:56:57---------------------------------------------------
244 -----------------------------------------------------------------------*/
245 uno::Reference
< beans::XPropertySetInfo
> SwXTextPortion::getPropertySetInfo()
246 throw( uno::RuntimeException
)
248 vos::OGuard
aGuard(Application::GetSolarMutex());
249 //! PropertySetInfo for text portion extensions
250 static uno::Reference
< beans::XPropertySetInfo
>
251 xTxtPorExtRef
= aSwMapProvider
.GetPropertySet(
252 PROPERTY_MAP_TEXTPORTION_EXTENSIONS
)->getPropertySetInfo();
253 //! PropertySetInfo for redline portions
254 static uno::Reference
< beans::XPropertySetInfo
>
255 xRedlPorRef
= aSwMapProvider
.GetPropertySet(
256 PROPERTY_MAP_REDLINE_PORTION
)->getPropertySetInfo();
258 return (PORTION_REDLINE_START
== m_ePortionType
||
259 PORTION_REDLINE_END
== m_ePortionType
) ? xRedlPorRef
: xTxtPorExtRef
;
261 /*-- 11.12.98 09:56:57---------------------------------------------------
263 -----------------------------------------------------------------------*/
264 void SwXTextPortion::setPropertyValue(const OUString
& rPropertyName
,
265 const uno::Any
& aValue
)
266 throw( beans::UnknownPropertyException
,
267 beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
269 vos::OGuard
aGuard(Application::GetSolarMutex());
270 SwUnoCrsr
* pUnoCrsr
= GetCursor();
272 throw uno::RuntimeException();
274 SwXTextCursor::SetPropertyValue(*pUnoCrsr
, *m_pPropSet
,
275 rPropertyName
, aValue
);
277 /*-- 04.11.03 09:56:58---------------------------------------------------
279 -----------------------------------------------------------------------*/
280 void SwXTextPortion::GetPropertyValue(
282 const SfxItemPropertySimpleEntry
& rEntry
,
286 DBG_ASSERT( pUnoCrsr
, "UNO cursor missing" );
293 case FN_UNO_TEXT_PORTION_TYPE
:
296 switch (m_ePortionType
)
298 case PORTION_TEXT
: pRet
= "Text";break;
299 case PORTION_FIELD
: pRet
= "TextField";break;
300 case PORTION_FRAME
: pRet
= "Frame";break;
301 case PORTION_FOOTNOTE
: pRet
= "Footnote";break;
302 case PORTION_REFMARK_START
:
303 case PORTION_REFMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK
);break;
304 case PORTION_TOXMARK_START
:
305 case PORTION_TOXMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_DOCUMENT_INDEX_MARK
);break;
306 case PORTION_BOOKMARK_START
:
307 case PORTION_BOOKMARK_END
: pRet
= SW_PROP_NAME_STR(UNO_NAME_BOOKMARK
);break;
308 case PORTION_REDLINE_START
:
309 case PORTION_REDLINE_END
: pRet
= "Redline";break;
310 case PORTION_RUBY_START
:
311 case PORTION_RUBY_END
: pRet
= "Ruby";break;
312 case PORTION_SOFT_PAGEBREAK
:pRet
= "SoftPageBreak";break;
313 case PORTION_META
: pRet
= SW_PROP_NAME_STR(UNO_NAME_META
); break;
314 case PORTION_FIELD_START
:pRet
= "TextFieldStart";break;
315 case PORTION_FIELD_END
:pRet
= "TextFieldEnd";break;
316 case PORTION_FIELD_START_END
:pRet
= "TextFieldStartEnd";break;
327 case FN_UNO_CONTROL_CHARACTER
: // obsolete!
329 case FN_UNO_DOCUMENT_INDEX_MARK
:
332 case FN_UNO_REFERENCE_MARK
:
335 case FN_UNO_BOOKMARK
:
336 rVal
<<= m_xBookmark
;
338 case FN_UNO_FOOTNOTE
:
339 rVal
<<= m_xFootnote
;
341 case FN_UNO_TEXT_FIELD
:
342 rVal
<<= m_xTextField
;
347 case FN_UNO_IS_COLLAPSED
:
349 switch (m_ePortionType
)
351 case PORTION_REFMARK_START
:
352 case PORTION_BOOKMARK_START
:
353 case PORTION_TOXMARK_START
:
354 case PORTION_REFMARK_END
:
355 case PORTION_TOXMARK_END
:
356 case PORTION_BOOKMARK_END
:
357 case PORTION_REDLINE_START
:
358 case PORTION_REDLINE_END
:
359 case PORTION_RUBY_START
:
360 case PORTION_RUBY_END
:
361 case PORTION_FIELD_START
:
362 case PORTION_FIELD_END
:
363 rVal
.setValue(&m_bIsCollapsed
, ::getBooleanCppuType());
370 case FN_UNO_IS_START
:
372 BOOL bStart
= TRUE
, bPut
= TRUE
;
373 switch (m_ePortionType
)
375 case PORTION_REFMARK_START
:
376 case PORTION_BOOKMARK_START
:
377 case PORTION_TOXMARK_START
:
378 case PORTION_REDLINE_START
:
379 case PORTION_RUBY_START
:
380 case PORTION_FIELD_START
:
383 case PORTION_REFMARK_END
:
384 case PORTION_TOXMARK_END
:
385 case PORTION_BOOKMARK_END
:
386 case PORTION_REDLINE_END
:
387 case PORTION_RUBY_END
:
388 case PORTION_FIELD_END
:
395 rVal
.setValue(&bStart
, ::getBooleanCppuType());
398 case RES_TXTATR_CJK_RUBY
:
400 const uno::Any
* pToSet
= 0;
401 switch(rEntry
.nMemberId
)
403 case MID_RUBY_TEXT
: pToSet
= m_pRubyText
.get(); break;
404 case MID_RUBY_ADJUST
: pToSet
= m_pRubyAdjust
.get(); break;
405 case MID_RUBY_CHARSTYLE
:pToSet
= m_pRubyStyle
.get(); break;
406 case MID_RUBY_ABOVE
: pToSet
= m_pRubyIsAbove
.get();break;
413 beans::PropertyState eTemp
;
414 BOOL bDone
= SwUnoCursorHelper::getCrsrPropertyValue(
415 rEntry
, *pUnoCrsr
, &(rVal
), eTemp
);
420 pSet
= new SfxItemSet(pUnoCrsr
->GetDoc()->GetAttrPool(),
421 RES_CHRATR_BEGIN
, RES_FRMATR_END
- 1,
422 RES_UNKNOWNATR_CONTAINER
, RES_UNKNOWNATR_CONTAINER
,
423 RES_TXTATR_UNKNOWN_CONTAINER
, RES_TXTATR_UNKNOWN_CONTAINER
,
425 SwXTextCursor::GetCrsrAttr(*pUnoCrsr
, *pSet
);
427 m_pPropSet
->getPropertyValue(rEntry
, *pSet
, rVal
);
434 uno::Sequence
< uno::Any
> SAL_CALL
SwXTextPortion::GetPropertyValues_Impl(
435 const uno::Sequence
< OUString
>& rPropertyNames
)
436 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
438 sal_Int32 nLength
= rPropertyNames
.getLength();
439 const OUString
*pPropertyNames
= rPropertyNames
.getConstArray();
440 uno::Sequence
< uno::Any
> aValues(rPropertyNames
.getLength());
441 uno::Any
*pValues
= aValues
.getArray();
442 SwUnoCrsr
* pUnoCrsr
= GetCursor();
444 throw uno::RuntimeException();
447 SfxItemSet
*pSet
= 0;
448 // get startting pount fo the look-up, either the provided one or else
449 // from the beginning of the map
450 const SfxItemPropertyMap
* pMap
= m_pPropSet
->getPropertyMap();
451 for(sal_Int32 nProp
= 0; nProp
< nLength
; nProp
++)
453 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName(pPropertyNames
[nProp
]);
456 GetPropertyValue( pValues
[nProp
], *pEntry
, pUnoCrsr
, pSet
);
459 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
465 /*-- 11.12.98 09:56:58---------------------------------------------------
467 -----------------------------------------------------------------------*/
468 uno::Any
SwXTextPortion::getPropertyValue(
469 const OUString
& rPropertyName
)
470 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
472 vos::OGuard
aGuard(Application::GetSolarMutex());
473 uno::Sequence
< ::rtl::OUString
> aPropertyNames(1);
474 aPropertyNames
.getArray()[0] = rPropertyName
;
475 return GetPropertyValues_Impl(aPropertyNames
).getConstArray()[0];
477 /* -----------------------------02.04.01 11:44--------------------------------
479 ---------------------------------------------------------------------------*/
480 void SAL_CALL
SwXTextPortion::SetPropertyValues_Impl(
481 const uno::Sequence
< OUString
>& rPropertyNames
,
482 const uno::Sequence
< uno::Any
>& rValues
)
483 throw( beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
,
484 lang::WrappedTargetException
, uno::RuntimeException
)
486 SwUnoCrsr
* pUnoCrsr
= GetCursor();
488 throw uno::RuntimeException();
491 const OUString
* pPropertyNames
= rPropertyNames
.getConstArray();
492 const uno::Any
* pValues
= rValues
.getConstArray();
493 const SfxItemPropertyMap
* pMap
= m_pPropSet
->getPropertyMap();
494 for(sal_Int32 nProp
= 0; nProp
< rPropertyNames
.getLength(); nProp
++)
496 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName(pPropertyNames
[nProp
]);
498 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
499 if ( pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
500 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
502 SwXTextCursor::SetPropertyValue( *pUnoCrsr
, *m_pPropSet
,
503 pPropertyNames
[nProp
], pValues
[nProp
]);
508 void SwXTextPortion::setPropertyValues(
509 const uno::Sequence
< OUString
>& rPropertyNames
,
510 const uno::Sequence
< uno::Any
>& rValues
)
511 throw(beans::PropertyVetoException
, lang::IllegalArgumentException
,
512 lang::WrappedTargetException
, uno::RuntimeException
)
514 vos::OGuard
aGuard(Application::GetSolarMutex());
516 // workaround for bad designed API
519 SetPropertyValues_Impl( rPropertyNames
, rValues
);
521 catch (beans::UnknownPropertyException
&rException
)
523 // wrap the original (here not allowed) exception in
524 // a lang::WrappedTargetException that gets thrown instead.
525 lang::WrappedTargetException aWExc
;
526 aWExc
.TargetException
<<= rException
;
530 /* -----------------------------02.04.01 11:44--------------------------------
532 ---------------------------------------------------------------------------*/
533 uno::Sequence
< uno::Any
> SwXTextPortion::getPropertyValues(
534 const uno::Sequence
< OUString
>& rPropertyNames
)
535 throw(uno::RuntimeException
)
537 vos::OGuard
aGuard(Application::GetSolarMutex());
538 uno::Sequence
< uno::Any
> aValues
;
540 // workaround for bad designed API
543 aValues
= GetPropertyValues_Impl( rPropertyNames
);
545 catch (beans::UnknownPropertyException
&)
547 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject
* > ( this ) );
549 catch (lang::WrappedTargetException
&)
551 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject
* > ( this ) );
556 /* -----------------------------29.09.03 11:44--------------------------------
558 ---------------------------------------------------------------------------*/
560 /* disabled for #i46921# */
562 uno::Sequence
< beans::SetPropertyTolerantFailed
> SAL_CALL
SwXTextPortion::setPropertyValuesTolerant(
563 const uno::Sequence
< OUString
>& rPropertyNames
,
564 const uno::Sequence
< uno::Any
>& rValues
)
565 throw (lang::IllegalArgumentException
, uno::RuntimeException
)
567 vos::OGuard
aGuard(Application::GetSolarMutex());
569 if (rPropertyNames
.getLength() != rValues
.getLength())
570 throw lang::IllegalArgumentException();
571 SwUnoCrsr
* pUnoCrsr
= this->GetCursor();
573 throw uno::RuntimeException();
575 sal_Int32 nProps
= rPropertyNames
.getLength();
576 const OUString
*pProp
= rPropertyNames
.getConstArray();
578 //sal_Int32 nVals = rValues.getLength();
579 const uno::Any
*pValue
= rValues
.getConstArray();
581 sal_Int32 nFailed
= 0;
582 uno::Sequence
< beans::SetPropertyTolerantFailed
> aFailed( nProps
);
583 beans::SetPropertyTolerantFailed
*pFailed
= aFailed
.getArray();
585 const SfxItemPropertyMap
* pPropMap
= m_pPropSet
->getPropertyMap();
588 for (sal_Int32 i
= 0; i
< nProps
; ++i
)
592 pFailed
[ nFailed
].Name
= pProp
[i
];
594 const SfxItemPropertySimpleEntry
* pEntry
= pPropMap
->getByName( pProp
[i
] );
596 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
599 // set property value
600 // (compare to SwXTextPortion::setPropertyValues)
601 if (pEntry
->nFlags
& beans::PropertyAttribute::READONLY
)
602 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
605 SwXTextCursor::SetPropertyValue(
606 *pUnoCrsr
, *m_pPropSet
, pProp
[i
], pValue
[i
] );
610 catch (beans::UnknownPropertyException
&)
612 // should not occur because property was searched for before
613 DBG_ERROR( "unexpected exception catched" );
614 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
616 catch (lang::IllegalArgumentException
&)
618 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT
;
620 catch (beans::PropertyVetoException
&)
622 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
624 catch (lang::WrappedTargetException
&)
626 pFailed
[ nFailed
++ ].Result
= beans::TolerantPropertySetResultType::WRAPPED_TARGET
;
630 aFailed
.realloc( nFailed
);
635 uno::Sequence
< beans::GetPropertyTolerantResult
> SAL_CALL
SwXTextPortion::getPropertyValuesTolerant(
636 const uno::Sequence
< OUString
>& rPropertyNames
)
637 throw (uno::RuntimeException
)
639 vos::OGuard
aGuard( Application::GetSolarMutex() );
641 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> aTmpRes(
642 GetPropertyValuesTolerant_Impl( rPropertyNames
, sal_False
) );
643 const beans::GetDirectPropertyTolerantResult
*pTmpRes
= aTmpRes
.getConstArray();
645 // copy temporary result to final result type
646 sal_Int32 nLen
= aTmpRes
.getLength();
647 uno::Sequence
< beans::GetPropertyTolerantResult
> aRes( nLen
);
648 beans::GetPropertyTolerantResult
*pRes
= aRes
.getArray();
649 for (sal_Int32 i
= 0; i
< nLen
; i
++)
650 *pRes
++ = *pTmpRes
++;
655 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> SAL_CALL
SwXTextPortion::getDirectPropertyValuesTolerant(
656 const uno::Sequence
< OUString
>& rPropertyNames
)
657 throw (uno::RuntimeException
)
659 vos::OGuard
aGuard( Application::GetSolarMutex() );
660 return GetPropertyValuesTolerant_Impl( rPropertyNames
, sal_True
);
664 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> SAL_CALL
SwXTextPortion::GetPropertyValuesTolerant_Impl(
665 const uno::Sequence
< OUString
>& rPropertyNames
,
666 sal_Bool bDirectValuesOnly
)
667 throw (uno::RuntimeException
)
669 vos::OGuard
aGuard(Application::GetSolarMutex());
671 SwUnoCrsr
* pUnoCrsr
= this->GetCursor();
673 throw uno::RuntimeException();
675 sal_Int32 nProps
= rPropertyNames
.getLength();
676 const OUString
*pProp
= rPropertyNames
.getConstArray();
678 SfxItemSet
*pSet
= 0;
680 const SfxItemPropertyMap
* pPropMap
= m_pPropSet
->getPropertyMap();
682 uno::Sequence
< beans::PropertyState
> aPropertyStates
= SwXTextCursor::GetPropertyStates(
683 *pUnoCrsr
, *m_pPropSet
,
685 SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
);
686 const beans::PropertyState
* pPropertyStates
= aPropertyStates
.getConstArray();
688 std::vector
< beans::GetDirectPropertyTolerantResult
> aResultVector
;
689 for (sal_Int32 i
= 0; i
< nProps
; ++i
)
691 beans::GetDirectPropertyTolerantResult aResult
;
694 aResult
.Name
= pProp
[i
];
695 if(pPropertyStates
[i
] == beans::PropertyState_MAKE_FIXED_SIZE
) // property unknown?
697 if( bDirectValuesOnly
)
700 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
704 const SfxItemPropertySimpleEntry
* pEntry
= pPropMap
->getByName( pProp
[i
] );
705 aResult
.State
= pPropertyStates
[i
];
707 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_FAILURE
;
708 //#i104499# ruby portion attributes need special handling:
709 if( pEntry
->nWID
== RES_TXTATR_CJK_RUBY
&&
710 m_ePortionType
== PORTION_RUBY_START
)
712 aResult
.State
= beans::PropertyState_DIRECT_VALUE
;
714 if (!bDirectValuesOnly
|| beans::PropertyState_DIRECT_VALUE
== aResult
.State
)
716 // get property value
717 // (compare to SwXTextPortion::getPropertyValue(s))
718 GetPropertyValue( aResult
.Value
, *pEntry
, pUnoCrsr
, pSet
);
719 aResult
.Result
= beans::TolerantPropertySetResultType::SUCCESS
;
720 aResultVector
.push_back( aResult
);
722 // this assertion should never occur!
723 DBG_ASSERT( !aResultVector
.size() || aResult
.Result
!= beans::TolerantPropertySetResultType::UNKNOWN_FAILURE
,
724 "unknown failure while retrieving property" );
728 catch (beans::UnknownPropertyException
&)
730 // should not occur because property was searched for before
731 DBG_ERROR( "unexpected exception catched" );
732 aResult
.Result
= beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY
;
734 catch (lang::IllegalArgumentException
&)
736 aResult
.Result
= beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT
;
738 catch (beans::PropertyVetoException
&)
740 aResult
.Result
= beans::TolerantPropertySetResultType::PROPERTY_VETO
;
742 catch (lang::WrappedTargetException
&)
744 aResult
.Result
= beans::TolerantPropertySetResultType::WRAPPED_TARGET
;
749 uno::Sequence
< beans::GetDirectPropertyTolerantResult
> aResult( aResultVector
.size() );
750 std::vector
< beans::GetDirectPropertyTolerantResult
>::const_iterator aIt
= aResultVector
.begin();
751 beans::GetDirectPropertyTolerantResult
*pResult
= aResult
.getArray();
752 for( sal_Int32 nResult
= 0; nResult
< aResult
.getLength(); ++nResult
)
754 pResult
[nResult
] = *aIt
;
762 /* -----------------------------02.04.01 11:44--------------------------------
764 ---------------------------------------------------------------------------*/
765 void SwXTextPortion::addPropertiesChangeListener(
766 const uno::Sequence
< OUString
>& /*aPropertyNames*/,
767 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
768 throw(uno::RuntimeException
)
770 /* -----------------------------02.04.01 11:44--------------------------------
772 ---------------------------------------------------------------------------*/
773 void SwXTextPortion::removePropertiesChangeListener(
774 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
775 throw(uno::RuntimeException
)
777 /* -----------------------------02.04.01 11:44--------------------------------
779 ---------------------------------------------------------------------------*/
780 void SwXTextPortion::firePropertiesChangeEvent(
781 const uno::Sequence
< OUString
>& /*aPropertyNames*/,
782 const uno::Reference
< beans::XPropertiesChangeListener
>& /*xListener*/ )
783 throw(uno::RuntimeException
)
785 /*-- 11.12.98 09:56:58---------------------------------------------------
787 -----------------------------------------------------------------------*/
788 void SwXTextPortion::addPropertyChangeListener(
789 const OUString
& /*PropertyName*/,
790 const uno::Reference
< beans::XPropertyChangeListener
> & /*xListener*/)
791 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
793 DBG_WARNING("not implemented");
795 /*-- 11.12.98 09:56:58---------------------------------------------------
797 -----------------------------------------------------------------------*/
798 void SwXTextPortion::removePropertyChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XPropertyChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
800 DBG_WARNING("not implemented");
802 /*-- 11.12.98 09:56:58---------------------------------------------------
804 -----------------------------------------------------------------------*/
805 void SwXTextPortion::addVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
807 DBG_WARNING("not implemented");
809 /*-- 11.12.98 09:56:59---------------------------------------------------
811 -----------------------------------------------------------------------*/
812 void SwXTextPortion::removeVetoableChangeListener(const OUString
& /*rPropertyName*/, const uno::Reference
< beans::XVetoableChangeListener
> & /*aListener*/) throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
814 DBG_WARNING("not implemented");
816 /*-- 08.03.99 09:41:43---------------------------------------------------
818 -----------------------------------------------------------------------*/
819 beans::PropertyState
SwXTextPortion::getPropertyState(const OUString
& rPropertyName
)
820 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
822 vos::OGuard
aGuard(Application::GetSolarMutex());
823 beans::PropertyState eRet
= beans::PropertyState_DEFAULT_VALUE
;
824 SwUnoCrsr
* pUnoCrsr
= GetCursor();
826 throw uno::RuntimeException();
828 if (GetTextPortionType() == PORTION_RUBY_START
&&
829 !rPropertyName
.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
831 eRet
= beans::PropertyState_DIRECT_VALUE
;
835 eRet
= SwXTextCursor::GetPropertyState(*pUnoCrsr
, *m_pPropSet
,
840 /*-- 08.03.99 09:41:47---------------------------------------------------
842 -----------------------------------------------------------------------*/
843 uno::Sequence
< beans::PropertyState
> SwXTextPortion::getPropertyStates(
844 const uno::Sequence
< OUString
>& rPropertyNames
)
845 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
847 vos::OGuard
aGuard(Application::GetSolarMutex());
848 SwUnoCrsr
* pUnoCrsr
= GetCursor();
850 throw uno::RuntimeException();
852 uno::Sequence
< beans::PropertyState
> aRet
=
853 SwXTextCursor::GetPropertyStates(*pUnoCrsr
, *m_pPropSet
,
854 rPropertyNames
, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION
);
856 if(GetTextPortionType() == PORTION_RUBY_START
)
858 const OUString
* pNames
= rPropertyNames
.getConstArray();
859 beans::PropertyState
* pStates
= aRet
.getArray();
860 for(sal_Int32 nProp
= 0; nProp
< rPropertyNames
.getLength();nProp
++)
862 if(!pNames
[nProp
].compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") ))
863 pStates
[nProp
] = beans::PropertyState_DIRECT_VALUE
;
868 /*-- 08.03.99 09:41:47---------------------------------------------------
870 -----------------------------------------------------------------------*/
871 void SwXTextPortion::setPropertyToDefault(const OUString
& rPropertyName
)
872 throw( beans::UnknownPropertyException
, uno::RuntimeException
)
874 vos::OGuard
aGuard(Application::GetSolarMutex());
875 SwUnoCrsr
* pUnoCrsr
= GetCursor();
877 throw uno::RuntimeException();
879 SwXTextCursor::SetPropertyToDefault(*pUnoCrsr
, *m_pPropSet
, rPropertyName
);
881 /*-- 08.03.99 09:41:48---------------------------------------------------
883 -----------------------------------------------------------------------*/
884 uno::Any
SwXTextPortion::getPropertyDefault(const OUString
& rPropertyName
)
885 throw( beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
887 vos::OGuard
aGuard(Application::GetSolarMutex());
889 SwUnoCrsr
* pUnoCrsr
= GetCursor();
891 throw uno::RuntimeException();
893 aRet
= SwXTextCursor::GetPropertyDefault(*pUnoCrsr
, *m_pPropSet
,
898 /*-- 11.12.98 09:56:59---------------------------------------------------
900 -----------------------------------------------------------------------*/
901 void SwXTextPortion::attach(const uno::Reference
< text::XTextRange
> & /*xTextRange*/)
902 throw( lang::IllegalArgumentException
, uno::RuntimeException
)
904 vos::OGuard
aGuard(Application::GetSolarMutex());
905 // SwXTextPortion cannot be created at the factory therefore
906 // they cannot be attached
907 throw uno::RuntimeException();
909 /*-- 11.12.98 09:57:00---------------------------------------------------
911 -----------------------------------------------------------------------*/
912 uno::Reference
< text::XTextRange
> SwXTextPortion::getAnchor()
913 throw( uno::RuntimeException
)
915 vos::OGuard
aGuard(Application::GetSolarMutex());
916 uno::Reference
< text::XTextRange
> aRet
;
917 SwUnoCrsr
* pUnoCrsr
= GetCursor();
919 throw uno::RuntimeException();
921 aRet
= new SwXTextRange(*pUnoCrsr
, m_xParentText
);
924 /*-- 11.12.98 09:57:00---------------------------------------------------
926 -----------------------------------------------------------------------*/
927 void SwXTextPortion::dispose()
928 throw( uno::RuntimeException
)
930 vos::OGuard
aGuard(Application::GetSolarMutex());
931 SwUnoCrsr
* pUnoCrsr
= GetCursor();
933 throw uno::RuntimeException();
935 setString(aEmptyStr
);
936 pUnoCrsr
->Remove(this);
938 /*-- 11.12.98 09:57:00---------------------------------------------------
940 -----------------------------------------------------------------------*/
941 void SwXTextPortion::addEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
943 vos::OGuard
aGuard(Application::GetSolarMutex());
944 if(!GetRegisteredIn())
945 throw uno::RuntimeException();
947 m_ListenerContainer
.AddListener(aListener
);
949 /*-- 11.12.98 09:57:01---------------------------------------------------
951 -----------------------------------------------------------------------*/
952 void SwXTextPortion::removeEventListener(const uno::Reference
< lang::XEventListener
> & aListener
) throw( uno::RuntimeException
)
954 vos::OGuard
aGuard(Application::GetSolarMutex());
955 if (!GetRegisteredIn() || !m_ListenerContainer
.RemoveListener(aListener
))
956 throw uno::RuntimeException();
958 /* -----------------24.03.99 13:30-------------------
960 * --------------------------------------------------*/
961 uno::Reference
< container::XEnumeration
> SwXTextPortion::createContentEnumeration(const OUString
& /*aServiceName*/)
962 throw( uno::RuntimeException
)
964 vos::OGuard
aGuard(Application::GetSolarMutex());
965 SwUnoCrsr
* pUnoCrsr
= GetCursor();
967 throw uno::RuntimeException();
969 uno::Reference
< container::XEnumeration
> xRet
=
970 new SwXParaFrameEnumeration(*pUnoCrsr
, PARAFRAME_PORTION_CHAR
,
975 /* -----------------------------04.07.01 08:52--------------------------------
977 ---------------------------------------------------------------------------*/
978 const uno::Sequence
< sal_Int8
> & SwXTextPortion::getUnoTunnelId()
980 static uno::Sequence
< sal_Int8
> aSeq
= ::CreateUnoTunnelId();
983 /* -----------------------------04.07.01 08:52--------------------------------
985 ---------------------------------------------------------------------------*/
986 sal_Int64
SwXTextPortion::getSomething( const uno::Sequence
< sal_Int8
>& rId
)
987 throw(uno::RuntimeException
)
989 if( rId
.getLength() == 16
990 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
991 rId
.getConstArray(), 16 ) )
993 return sal::static_int_cast
< sal_Int64
>( reinterpret_cast< sal_IntPtr
>(this) );
997 /* -----------------24.03.99 13:30-------------------
999 * --------------------------------------------------*/
1000 uno::Sequence
< OUString
> SwXTextPortion::getAvailableServiceNames()
1001 throw( uno::RuntimeException
)
1003 vos::OGuard
aGuard(Application::GetSolarMutex());
1004 uno::Sequence
< OUString
> aRet(1);
1005 OUString
* pArray
= aRet
.getArray();
1006 pArray
[0] = C2U("com.sun.star.text.TextContent");
1009 /* -----------------25.03.99 10:30-------------------
1011 * --------------------------------------------------*/
1012 OUString
SwXTextPortion::getImplementationName()
1013 throw( uno::RuntimeException
)
1015 return C2U("SwXTextPortion");
1017 /* -----------------25.03.99 10:30-------------------
1019 * --------------------------------------------------*/
1020 sal_Bool
SwXTextPortion::supportsService(const OUString
& rServiceName
) throw( uno::RuntimeException
)
1022 vos::OGuard
aGuard(Application::GetSolarMutex());
1023 SwUnoCrsr
* pUnoCrsr
= GetCursor();
1025 throw uno::RuntimeException();
1027 sal_Bool bRet
= sal_False
;
1028 if(!rServiceName
.compareToAscii("com.sun.star.text.TextPortion") ||
1029 !rServiceName
.compareToAscii("com.sun.star.style.CharacterProperties") ||
1030 !rServiceName
.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") ||
1031 !rServiceName
.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") ||
1032 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphProperties") ||
1033 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
1034 !rServiceName
.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex"))
1041 /* ---------------------------------------------------------------------------
1043 ---------------------------------------------------------------------------*/
1044 uno::Sequence
< OUString
> SwXTextPortion::getSupportedServiceNames()
1045 throw( uno::RuntimeException
)
1047 vos::OGuard
aGuard(Application::GetSolarMutex());
1048 SwUnoCrsr
* pUnoCrsr
= GetCursor();
1050 throw uno::RuntimeException();
1052 uno::Sequence
< OUString
> aRet(7);
1053 OUString
* pArray
= aRet
.getArray();
1054 pArray
[0] = C2U("com.sun.star.text.TextPortion");
1055 pArray
[1] = C2U("com.sun.star.style.CharacterProperties");
1056 pArray
[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
1057 pArray
[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
1058 pArray
[4] = C2U("com.sun.star.style.ParagraphProperties");
1059 pArray
[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
1060 pArray
[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
1063 /*-- 11.12.98 09:57:01---------------------------------------------------
1065 -----------------------------------------------------------------------*/
1066 void SwXTextPortion::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
1068 ClientModify(this, pOld
, pNew
);
1069 if (!m_FrameDepend
.GetRegisteredIn())