xref: /AOO41X/main/sw/source/core/unocore/unoparagraph.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <unoparagraph.hxx>
28cdf0e10cSrcweir #include <cmdid.h>
29cdf0e10cSrcweir #include <unomid.h>
30cdf0e10cSrcweir #include <unoparaframeenum.hxx>
31cdf0e10cSrcweir #include <unotext.hxx>
32cdf0e10cSrcweir #include <unotextrange.hxx>
33cdf0e10cSrcweir #include <unoport.hxx>
34cdf0e10cSrcweir #include <unomap.hxx>
35cdf0e10cSrcweir #include <unocrsr.hxx>
36cdf0e10cSrcweir #include <unoprnms.hxx>
37cdf0e10cSrcweir #include <unocrsrhelper.hxx>
38cdf0e10cSrcweir #include <doc.hxx>
39cdf0e10cSrcweir #include <ndtxt.hxx>
40cdf0e10cSrcweir #include <vos/mutex.hxx>
41cdf0e10cSrcweir #include <vcl/svapp.hxx>
42cdf0e10cSrcweir #include <docsh.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #define _SVSTDARR_USHORTS
45cdf0e10cSrcweir #define _SVSTDARR_USHORTSSORT
46cdf0e10cSrcweir #include <svl/svstdarr.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
49cdf0e10cSrcweir #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
50cdf0e10cSrcweir #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
51cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
52cdf0e10cSrcweir #include <com/sun/star/text/WrapTextMode.hpp>
53cdf0e10cSrcweir #include <com/sun/star/text/TextContentAnchorType.hpp>
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using namespace ::com::sun::star;
57cdf0e10cSrcweir using ::rtl::OUString;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /* -----------------------------01.12.00 18:09--------------------------------
61cdf0e10cSrcweir 
62cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
63cdf0e10cSrcweir class SwParaSelection
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     SwCursor & m_rCursor;
66cdf0e10cSrcweir public:
67cdf0e10cSrcweir     SwParaSelection(SwCursor & rCursor);
68cdf0e10cSrcweir     ~SwParaSelection();
69cdf0e10cSrcweir };
70cdf0e10cSrcweir 
SwParaSelection(SwCursor & rCursor)71cdf0e10cSrcweir SwParaSelection::SwParaSelection(SwCursor & rCursor)
72cdf0e10cSrcweir     : m_rCursor(rCursor)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir     if (m_rCursor.HasMark())
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         m_rCursor.DeleteMark();
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir     // is it at the start?
79cdf0e10cSrcweir     if (m_rCursor.GetPoint()->nContent != 0)
80cdf0e10cSrcweir     {
81cdf0e10cSrcweir         m_rCursor.MovePara(fnParaCurr, fnParaStart);
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir     // or at the end already?
84cdf0e10cSrcweir     if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len())
85cdf0e10cSrcweir     {
86cdf0e10cSrcweir         m_rCursor.SetMark();
87cdf0e10cSrcweir         m_rCursor.MovePara(fnParaCurr, fnParaEnd);
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
~SwParaSelection()91cdf0e10cSrcweir SwParaSelection::~SwParaSelection()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     if (m_rCursor.GetPoint()->nContent != 0)
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         m_rCursor.DeleteMark();
96cdf0e10cSrcweir         m_rCursor.MovePara(fnParaCurr, fnParaStart);
97cdf0e10cSrcweir     }
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir /******************************************************************
102cdf0e10cSrcweir  * forward declarations
103cdf0e10cSrcweir  ******************************************************************/
104cdf0e10cSrcweir 
105cdf0e10cSrcweir beans::PropertyState lcl_SwXParagraph_getPropertyState(
106cdf0e10cSrcweir                             const SwTxtNode& rTxtNode,
107cdf0e10cSrcweir                             const SwAttrSet** ppSet,
108cdf0e10cSrcweir                             const SfxItemPropertySimpleEntry& rEntry,
109cdf0e10cSrcweir                             sal_Bool &rAttrSetFetched )
110cdf0e10cSrcweir     throw (beans::UnknownPropertyException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir /******************************************************************
113cdf0e10cSrcweir  * SwXParagraph
114cdf0e10cSrcweir  ******************************************************************/
115cdf0e10cSrcweir 
116cdf0e10cSrcweir class SwXParagraph::Impl
117cdf0e10cSrcweir     : public SwClient
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 
120cdf0e10cSrcweir public:
121cdf0e10cSrcweir     SwXParagraph &              m_rThis;
122cdf0e10cSrcweir     SwEventListenerContainer    m_ListenerContainer;
123cdf0e10cSrcweir     SfxItemPropertySet const&   m_rPropSet;
124cdf0e10cSrcweir     bool                        m_bIsDescriptor;
125cdf0e10cSrcweir     sal_Int32                   m_nSelectionStartPos;
126cdf0e10cSrcweir     sal_Int32                   m_nSelectionEndPos;
127cdf0e10cSrcweir     ::rtl::OUString             m_sText;
128cdf0e10cSrcweir     uno::Reference<text::XText> m_xParentText;
129cdf0e10cSrcweir 
Impl(SwXParagraph & rThis,SwTxtNode * const pTxtNode=0,uno::Reference<text::XText> const & xParent=0,const sal_Int32 nSelStart=-1,const sal_Int32 nSelEnd=-1)130cdf0e10cSrcweir     Impl(   SwXParagraph & rThis,
131cdf0e10cSrcweir             SwTxtNode *const pTxtNode = 0,
132cdf0e10cSrcweir             uno::Reference< text::XText > const & xParent = 0,
133cdf0e10cSrcweir             const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
134cdf0e10cSrcweir         : SwClient(pTxtNode)
135cdf0e10cSrcweir         , m_rThis(rThis)
136cdf0e10cSrcweir         , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
137cdf0e10cSrcweir         , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
138cdf0e10cSrcweir         // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code
139cdf0e10cSrcweir         , m_bIsDescriptor((0 == pTxtNode) ? true : false)
140cdf0e10cSrcweir         , m_nSelectionStartPos(nSelStart)
141cdf0e10cSrcweir         , m_nSelectionEndPos(nSelEnd)
142cdf0e10cSrcweir         , m_xParentText(xParent)
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir 
GetTxtNode() const146cdf0e10cSrcweir     const SwTxtNode * GetTxtNode() const {
147cdf0e10cSrcweir         return static_cast<const SwTxtNode*>(GetRegisteredIn());
148cdf0e10cSrcweir     }
GetTxtNode()149cdf0e10cSrcweir           SwTxtNode * GetTxtNode()       {
150cdf0e10cSrcweir         return static_cast<SwTxtNode*>(GetRegisteredInNonConst());
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
GetTxtNodeOrThrow()153cdf0e10cSrcweir     SwTxtNode & GetTxtNodeOrThrow() {
154cdf0e10cSrcweir         SwTxtNode *const pTxtNode( GetTxtNode() );
155cdf0e10cSrcweir         if (!pTxtNode) {
156cdf0e10cSrcweir             throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
157cdf0e10cSrcweir                     "SwXParagraph: disposed or invalid")), 0);
158cdf0e10cSrcweir         }
159cdf0e10cSrcweir         return *pTxtNode;
160cdf0e10cSrcweir     }
161cdf0e10cSrcweir 
IsDescriptor() const162cdf0e10cSrcweir     bool IsDescriptor() const { return m_bIsDescriptor; }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     void SetPropertyValues_Impl(
165cdf0e10cSrcweir             const uno::Sequence< ::rtl::OUString >& rPropertyNames,
166cdf0e10cSrcweir             const uno::Sequence< uno::Any >& rValues)
167cdf0e10cSrcweir         throw (beans::UnknownPropertyException, beans::PropertyVetoException,
168cdf0e10cSrcweir                 lang::IllegalArgumentException, lang::WrappedTargetException,
169cdf0e10cSrcweir                 uno::RuntimeException);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     uno::Sequence< uno::Any >
172cdf0e10cSrcweir         GetPropertyValues_Impl(
173cdf0e10cSrcweir             const uno::Sequence< ::rtl::OUString >& rPropertyNames)
174cdf0e10cSrcweir         throw (beans::UnknownPropertyException, lang::WrappedTargetException,
175cdf0e10cSrcweir                 uno::RuntimeException);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     uno::Sequence< beans::GetDirectPropertyTolerantResult >
178cdf0e10cSrcweir         GetPropertyValuesTolerant_Impl(
179cdf0e10cSrcweir             const uno::Sequence< ::rtl::OUString >& rPropertyNames,
180cdf0e10cSrcweir             bool bDirectValuesOnly)
181cdf0e10cSrcweir         throw (uno::RuntimeException);
182cdf0e10cSrcweir protected:
183cdf0e10cSrcweir     // SwClient
184cdf0e10cSrcweir     virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir };
187cdf0e10cSrcweir 
188cdf0e10cSrcweir /*-- 11.12.98 08:12:58---------------------------------------------------
189cdf0e10cSrcweir 
190cdf0e10cSrcweir   -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)191cdf0e10cSrcweir void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     ClientModify(this, pOld, pNew);
194cdf0e10cSrcweir     if (!GetRegisteredIn())
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         m_ListenerContainer.Disposing();
197cdf0e10cSrcweir     }
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir /*-- 11.12.98 08:12:47---------------------------------------------------
201cdf0e10cSrcweir 
202cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwXParagraph()203cdf0e10cSrcweir SwXParagraph::SwXParagraph()
204cdf0e10cSrcweir     : m_pImpl( new SwXParagraph::Impl(*this) )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir /*-- 11.12.98 08:12:47---------------------------------------------------
209cdf0e10cSrcweir 
210cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SwXParagraph(uno::Reference<text::XText> const & xParent,SwTxtNode & rTxtNode,const sal_Int32 nSelStart,const sal_Int32 nSelEnd)211cdf0e10cSrcweir SwXParagraph::SwXParagraph(
212cdf0e10cSrcweir         uno::Reference< text::XText > const & xParent,
213cdf0e10cSrcweir         SwTxtNode & rTxtNode,
214cdf0e10cSrcweir         const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
215cdf0e10cSrcweir     : m_pImpl(
216cdf0e10cSrcweir         new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd))
217cdf0e10cSrcweir {
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir /*-- 11.12.98 08:12:48---------------------------------------------------
221cdf0e10cSrcweir 
222cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwXParagraph()223cdf0e10cSrcweir SwXParagraph::~SwXParagraph()
224cdf0e10cSrcweir {
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
GetTxtNode() const227cdf0e10cSrcweir const SwTxtNode * SwXParagraph::GetTxtNode() const
228cdf0e10cSrcweir {
229cdf0e10cSrcweir     return m_pImpl->GetTxtNode();
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
IsDescriptor() const232cdf0e10cSrcweir bool SwXParagraph::IsDescriptor() const
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     return m_pImpl->IsDescriptor();
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir uno::Reference<text::XTextContent>
CreateXParagraph(SwDoc & rDoc,SwTxtNode & rTxtNode,uno::Reference<text::XText> const & i_xParent,const sal_Int32 nSelStart,const sal_Int32 nSelEnd)238cdf0e10cSrcweir SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode,
239cdf0e10cSrcweir         uno::Reference< text::XText> const& i_xParent,
240cdf0e10cSrcweir         const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir     // re-use existing SwXParagraph
243cdf0e10cSrcweir     // #i105557#: do not iterate over the registered clients: race condition
244cdf0e10cSrcweir     uno::Reference<text::XTextContent> xParagraph;
245cdf0e10cSrcweir     if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection!
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         xParagraph.set(rTxtNode.GetXParagraph());
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir     if (xParagraph.is())
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir         return xParagraph;
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     // create new SwXParagraph
255cdf0e10cSrcweir     uno::Reference<text::XText> xParentText(i_xParent);
256cdf0e10cSrcweir     if (!xParentText.is())
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         SwPosition Pos( rTxtNode );
259cdf0e10cSrcweir         xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir     SwXParagraph *const pXPara(
262cdf0e10cSrcweir             new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) );
263cdf0e10cSrcweir     // this is why the constructor is private: need to acquire pXPara here
264cdf0e10cSrcweir     xParagraph.set(pXPara);
265cdf0e10cSrcweir     // in order to initialize the weak pointer cache in the core object
266cdf0e10cSrcweir     if ((-1 == nSelStart) && (-1 == nSelEnd))
267cdf0e10cSrcweir     {
268cdf0e10cSrcweir         rTxtNode.SetXParagraph(xParagraph);
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir     return xParagraph;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
SelectPaM(SwPaM & rPaM)273cdf0e10cSrcweir bool SwXParagraph::SelectPaM(SwPaM & rPaM)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     SwTxtNode const*const pTxtNode( GetTxtNode() );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     if (!pTxtNode)
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         return false;
280cdf0e10cSrcweir     }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir     *rPaM.GetPoint() = SwPosition( *pTxtNode );
283cdf0e10cSrcweir     // set selection to the whole paragraph
284cdf0e10cSrcweir     rPaM.SetMark();
285cdf0e10cSrcweir     rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len();
286cdf0e10cSrcweir     return true;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir /* -----------------------------13.03.00 12:15--------------------------------
290cdf0e10cSrcweir 
291cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
getUnoTunnelId()292cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
293cdf0e10cSrcweir {
294cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
295cdf0e10cSrcweir 	return aSeq;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir /* -----------------------------10.03.00 18:04--------------------------------
298cdf0e10cSrcweir 
299cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
300cdf0e10cSrcweir sal_Int64 SAL_CALL
getSomething(const uno::Sequence<sal_Int8> & rId)301cdf0e10cSrcweir SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
302cdf0e10cSrcweir throw (uno::RuntimeException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir     return ::sw::UnoTunnelImpl<SwXParagraph>(rId, this);
305cdf0e10cSrcweir }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
308cdf0e10cSrcweir 
309cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
310cdf0e10cSrcweir OUString SAL_CALL
getImplementationName()311cdf0e10cSrcweir SwXParagraph::getImplementationName() throw (uno::RuntimeException)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	return C2U("SwXParagraph");
314cdf0e10cSrcweir }
315cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
316cdf0e10cSrcweir 
317cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
318cdf0e10cSrcweir static char const*const g_ServicesParagraph[] =
319cdf0e10cSrcweir {
320cdf0e10cSrcweir     "com.sun.star.text.TextContent",
321cdf0e10cSrcweir     "com.sun.star.text.Paragraph",
322cdf0e10cSrcweir     "com.sun.star.style.CharacterProperties",
323cdf0e10cSrcweir     "com.sun.star.style.CharacterPropertiesAsian",
324cdf0e10cSrcweir     "com.sun.star.style.CharacterPropertiesComplex",
325cdf0e10cSrcweir     "com.sun.star.style.ParagraphProperties",
326cdf0e10cSrcweir     "com.sun.star.style.ParagraphPropertiesAsian",
327cdf0e10cSrcweir     "com.sun.star.style.ParagraphPropertiesComplex",
328cdf0e10cSrcweir };
329cdf0e10cSrcweir static const size_t g_nServicesParagraph(
330cdf0e10cSrcweir     sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0]));
331cdf0e10cSrcweir 
332cdf0e10cSrcweir sal_Bool SAL_CALL
supportsService(const OUString & rServiceName)333cdf0e10cSrcweir SwXParagraph::supportsService(const OUString& rServiceName)
334cdf0e10cSrcweir throw (uno::RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     return ::sw::SupportsServiceImpl(
337cdf0e10cSrcweir             g_nServicesParagraph, g_ServicesParagraph, rServiceName);
338cdf0e10cSrcweir }
339cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
340cdf0e10cSrcweir 
341cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
342cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames()343cdf0e10cSrcweir SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     return ::sw::GetSupportedServiceNamesImpl(
346cdf0e10cSrcweir             g_nServicesParagraph, g_ServicesParagraph);
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir /* -----------------------------11.07.00 14:48--------------------------------
350cdf0e10cSrcweir 
351cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
352cdf0e10cSrcweir void
attachToText(SwXText & rParent,SwTxtNode & rTxtNode)353cdf0e10cSrcweir SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
356cdf0e10cSrcweir     if (m_pImpl->m_bIsDescriptor)
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir         m_pImpl->m_bIsDescriptor = false;
359cdf0e10cSrcweir         rTxtNode.Add(m_pImpl.get());
360cdf0e10cSrcweir         rTxtNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
361cdf0e10cSrcweir         m_pImpl->m_xParentText = &rParent;
362cdf0e10cSrcweir         if (m_pImpl->m_sText.getLength())
363cdf0e10cSrcweir         {
364cdf0e10cSrcweir             try { setString(m_pImpl->m_sText); }
365cdf0e10cSrcweir 			catch(...){}
366cdf0e10cSrcweir             m_pImpl->m_sText = OUString();
367cdf0e10cSrcweir         }
368cdf0e10cSrcweir     }
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
372cdf0e10cSrcweir 
373cdf0e10cSrcweir   -----------------------------------------------------------------------*/
374cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()375cdf0e10cSrcweir SwXParagraph::getPropertySetInfo()
376cdf0e10cSrcweir throw (uno::RuntimeException)
377cdf0e10cSrcweir {
378cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     static uno::Reference< beans::XPropertySetInfo > xRef =
381cdf0e10cSrcweir         m_pImpl->m_rPropSet.getPropertySetInfo();
382cdf0e10cSrcweir 	return xRef;
383cdf0e10cSrcweir }
384cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
385cdf0e10cSrcweir 
386cdf0e10cSrcweir   -----------------------------------------------------------------------*/
387cdf0e10cSrcweir void SAL_CALL
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)388cdf0e10cSrcweir SwXParagraph::setPropertyValue(const OUString& rPropertyName,
389cdf0e10cSrcweir         const uno::Any& rValue)
390cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
391cdf0e10cSrcweir     lang::IllegalArgumentException, lang::WrappedTargetException,
392cdf0e10cSrcweir     uno::RuntimeException )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
395cdf0e10cSrcweir     uno::Sequence<OUString> aPropertyNames(1);
396cdf0e10cSrcweir     aPropertyNames.getArray()[0] = rPropertyName;
397cdf0e10cSrcweir     uno::Sequence<uno::Any> aValues(1);
398cdf0e10cSrcweir     aValues.getArray()[0] = rValue;
399cdf0e10cSrcweir     m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
403cdf0e10cSrcweir 
404cdf0e10cSrcweir   -----------------------------------------------------------------------*/
405cdf0e10cSrcweir uno::Any
getPropertyValue(const OUString & rPropertyName)406cdf0e10cSrcweir SwXParagraph::getPropertyValue(const OUString& rPropertyName)
407cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
408cdf0e10cSrcweir     uno::RuntimeException )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
411cdf0e10cSrcweir     uno::Sequence<OUString> aPropertyNames(1);
412cdf0e10cSrcweir     aPropertyNames.getArray()[0] = rPropertyName;
413cdf0e10cSrcweir     const uno::Sequence< uno::Any > aRet =
414cdf0e10cSrcweir         m_pImpl->GetPropertyValues_Impl(aPropertyNames);
415cdf0e10cSrcweir     return aRet.getConstArray()[0];
416cdf0e10cSrcweir }
417cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
418cdf0e10cSrcweir 
419cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)420cdf0e10cSrcweir void SwXParagraph::Impl::SetPropertyValues_Impl(
421cdf0e10cSrcweir     const uno::Sequence< OUString >& rPropertyNames,
422cdf0e10cSrcweir     const uno::Sequence< uno::Any >& rValues )
423cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
424cdf0e10cSrcweir     lang::IllegalArgumentException, lang::WrappedTargetException,
425cdf0e10cSrcweir     uno::RuntimeException)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
430cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
431cdf0e10cSrcweir     const OUString* pPropertyNames = rPropertyNames.getConstArray();
432cdf0e10cSrcweir     const uno::Any* pValues = rValues.getConstArray();
433cdf0e10cSrcweir     SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap();
434cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
435cdf0e10cSrcweir     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
436cdf0e10cSrcweir     {
437cdf0e10cSrcweir         SfxItemPropertySimpleEntry const*const pEntry =
438cdf0e10cSrcweir             pMap->getByName( pPropertyNames[nProp] );
439cdf0e10cSrcweir         if (!pEntry)
440cdf0e10cSrcweir         {
441cdf0e10cSrcweir             throw beans::UnknownPropertyException(
442cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
443cdf0e10cSrcweir                     + pPropertyNames[nProp],
444cdf0e10cSrcweir                 static_cast< cppu::OWeakObject * >(&m_rThis));
445cdf0e10cSrcweir         }
446cdf0e10cSrcweir         if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
447cdf0e10cSrcweir         {
448cdf0e10cSrcweir             throw beans::PropertyVetoException(
449cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
450cdf0e10cSrcweir                     + pPropertyNames[nProp],
451cdf0e10cSrcweir                 static_cast< cppu::OWeakObject * >(&m_rThis));
452cdf0e10cSrcweir         }
453cdf0e10cSrcweir         SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet,
454cdf0e10cSrcweir                 pPropertyNames[nProp], pValues[nProp]);
455cdf0e10cSrcweir     }
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)458cdf0e10cSrcweir void SAL_CALL SwXParagraph::setPropertyValues(
459cdf0e10cSrcweir     const uno::Sequence< OUString >& rPropertyNames,
460cdf0e10cSrcweir     const uno::Sequence< uno::Any >& rValues )
461cdf0e10cSrcweir throw (beans::PropertyVetoException, lang::IllegalArgumentException,
462cdf0e10cSrcweir     lang::WrappedTargetException, uno::RuntimeException)
463cdf0e10cSrcweir {
464cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     // workaround for bad designed API
467cdf0e10cSrcweir     try
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir         m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
470cdf0e10cSrcweir     }
471cdf0e10cSrcweir     catch (beans::UnknownPropertyException &rException)
472cdf0e10cSrcweir     {
473cdf0e10cSrcweir         // wrap the original (here not allowed) exception in
474cdf0e10cSrcweir         // a lang::WrappedTargetException that gets thrown instead.
475cdf0e10cSrcweir         lang::WrappedTargetException aWExc;
476cdf0e10cSrcweir         aWExc.TargetException <<= rException;
477cdf0e10cSrcweir         throw aWExc;
478cdf0e10cSrcweir     }
479cdf0e10cSrcweir }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
482cdf0e10cSrcweir 
483cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)484cdf0e10cSrcweir uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl(
485cdf0e10cSrcweir         const uno::Sequence< OUString > & rPropertyNames )
486cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
487cdf0e10cSrcweir     uno::RuntimeException)
488cdf0e10cSrcweir {
489cdf0e10cSrcweir     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
492cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
493cdf0e10cSrcweir     SwPaM aPam( aPos );
494cdf0e10cSrcweir     uno::Any* pValues = aValues.getArray();
495cdf0e10cSrcweir     const OUString* pPropertyNames = rPropertyNames.getConstArray();
496cdf0e10cSrcweir     SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap();
497cdf0e10cSrcweir     const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() );
498cdf0e10cSrcweir     for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         SfxItemPropertySimpleEntry const*const pEntry =
501cdf0e10cSrcweir             pMap->getByName( pPropertyNames[nProp] );
502cdf0e10cSrcweir         if (!pEntry)
503cdf0e10cSrcweir         {
504cdf0e10cSrcweir             throw beans::UnknownPropertyException(
505cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
506cdf0e10cSrcweir                     + pPropertyNames[nProp],
507cdf0e10cSrcweir                 static_cast< cppu::OWeakObject * >(&m_rThis));
508cdf0e10cSrcweir         }
509cdf0e10cSrcweir         if (! ::sw::GetDefaultTextContentValue(
510cdf0e10cSrcweir                 pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
511cdf0e10cSrcweir         {
512cdf0e10cSrcweir             beans::PropertyState eTemp;
513cdf0e10cSrcweir             const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
514cdf0e10cSrcweir                 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode );
515cdf0e10cSrcweir             if (!bDone)
516cdf0e10cSrcweir             {
517cdf0e10cSrcweir                 m_rPropSet.getPropertyValue(
518cdf0e10cSrcweir                     *pEntry, rAttrSet, pValues[nProp]);
519cdf0e10cSrcweir             }
520cdf0e10cSrcweir         }
521cdf0e10cSrcweir     }
522cdf0e10cSrcweir     return aValues;
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir /* -----------------------------04.11.03 11:43--------------------------------
526cdf0e10cSrcweir 
527cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
528cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)529cdf0e10cSrcweir SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
530cdf0e10cSrcweir throw (uno::RuntimeException)
531cdf0e10cSrcweir {
532cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
533cdf0e10cSrcweir     uno::Sequence< uno::Any > aValues;
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     // workaround for bad designed API
536cdf0e10cSrcweir     try
537cdf0e10cSrcweir     {
538cdf0e10cSrcweir         aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
539cdf0e10cSrcweir     }
540cdf0e10cSrcweir     catch (beans::UnknownPropertyException &)
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
543cdf0e10cSrcweir                 "Unknown property exception caught")),
544cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
545cdf0e10cSrcweir     }
546cdf0e10cSrcweir     catch (lang::WrappedTargetException &)
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir         throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
549cdf0e10cSrcweir                 "WrappedTargetException caught")),
550cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
551cdf0e10cSrcweir     }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     return aValues;
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
557cdf0e10cSrcweir 
558cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
addPropertiesChangeListener(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)559cdf0e10cSrcweir void SAL_CALL SwXParagraph::addPropertiesChangeListener(
560cdf0e10cSrcweir     const uno::Sequence< OUString >& /*aPropertyNames*/,
561cdf0e10cSrcweir     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
562cdf0e10cSrcweir throw (uno::RuntimeException)
563cdf0e10cSrcweir {
564cdf0e10cSrcweir     OSL_ENSURE(false,
565cdf0e10cSrcweir         "SwXParagraph::addPropertiesChangeListener(): not implemented");
566cdf0e10cSrcweir }
567cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
568cdf0e10cSrcweir 
569cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)570cdf0e10cSrcweir void SAL_CALL SwXParagraph::removePropertiesChangeListener(
571cdf0e10cSrcweir     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
572cdf0e10cSrcweir throw (uno::RuntimeException)
573cdf0e10cSrcweir {
574cdf0e10cSrcweir     OSL_ENSURE(false,
575cdf0e10cSrcweir         "SwXParagraph::removePropertiesChangeListener(): not implemented");
576cdf0e10cSrcweir }
577cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
578cdf0e10cSrcweir 
579cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
firePropertiesChangeEvent(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)580cdf0e10cSrcweir void SAL_CALL SwXParagraph::firePropertiesChangeEvent(
581cdf0e10cSrcweir     const uno::Sequence< OUString >& /*aPropertyNames*/,
582cdf0e10cSrcweir     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
583cdf0e10cSrcweir         throw(uno::RuntimeException)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     OSL_ENSURE(false,
586cdf0e10cSrcweir         "SwXParagraph::firePropertiesChangeEvent(): not implemented");
587cdf0e10cSrcweir }
588cdf0e10cSrcweir /* -----------------------------25.09.03 11:09--------------------------------
589cdf0e10cSrcweir 
590cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
591cdf0e10cSrcweir 
592cdf0e10cSrcweir /* disabled for #i46921# */
593cdf0e10cSrcweir 
594cdf0e10cSrcweir uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
setPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)595cdf0e10cSrcweir SwXParagraph::setPropertyValuesTolerant(
596cdf0e10cSrcweir         const uno::Sequence< OUString >& rPropertyNames,
597cdf0e10cSrcweir         const uno::Sequence< uno::Any >& rValues )
598cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
601cdf0e10cSrcweir 
602cdf0e10cSrcweir     if (rPropertyNames.getLength() != rValues.getLength())
603cdf0e10cSrcweir     {
604cdf0e10cSrcweir         throw lang::IllegalArgumentException();
605cdf0e10cSrcweir     }
606cdf0e10cSrcweir 
607cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
608cdf0e10cSrcweir 
609cdf0e10cSrcweir     //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode();
610cdf0e10cSrcweir     //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet();
611cdf0e10cSrcweir     //sal_uInt16 nAttrCount = rAttrSet.Count();
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     const sal_Int32 nProps = rPropertyNames.getLength();
614cdf0e10cSrcweir     const OUString *pProp = rPropertyNames.getConstArray();
615cdf0e10cSrcweir 
616cdf0e10cSrcweir     //sal_Int32 nVals = rValues.getLength();
617cdf0e10cSrcweir     const uno::Any *pValue = rValues.getConstArray();
618cdf0e10cSrcweir 
619cdf0e10cSrcweir     sal_Int32 nFailed = 0;
620cdf0e10cSrcweir     uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
621cdf0e10cSrcweir     beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
622cdf0e10cSrcweir 
623cdf0e10cSrcweir     // get entry to start with
624cdf0e10cSrcweir     SfxItemPropertyMap const*const pPropMap =
625cdf0e10cSrcweir         m_pImpl->m_rPropSet.getPropertyMap();
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     OUString sTmp;
628cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
629cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
630cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
631cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nProps;  ++i)
632cdf0e10cSrcweir     {
633cdf0e10cSrcweir         try
634cdf0e10cSrcweir         {
635cdf0e10cSrcweir             pFailed[ nFailed ].Name = pProp[i];
636cdf0e10cSrcweir 
637cdf0e10cSrcweir             SfxItemPropertySimpleEntry const*const pEntry =
638cdf0e10cSrcweir                 pPropMap->getByName( pProp[i] );
639cdf0e10cSrcweir             if (!pEntry)
640cdf0e10cSrcweir             {
641cdf0e10cSrcweir                 pFailed[ nFailed++ ].Result  =
642cdf0e10cSrcweir                     beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
643cdf0e10cSrcweir             }
644cdf0e10cSrcweir             else
645cdf0e10cSrcweir             {
646cdf0e10cSrcweir                 // set property value
647cdf0e10cSrcweir                 // (compare to SwXParagraph::setPropertyValues)
648cdf0e10cSrcweir                 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
649cdf0e10cSrcweir                 {
650cdf0e10cSrcweir                     pFailed[ nFailed++ ].Result  =
651cdf0e10cSrcweir                         beans::TolerantPropertySetResultType::PROPERTY_VETO;
652cdf0e10cSrcweir                 }
653cdf0e10cSrcweir                 else
654cdf0e10cSrcweir                 {
655cdf0e10cSrcweir                     SwUnoCursorHelper::SetPropertyValue(
656cdf0e10cSrcweir                         aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
657cdf0e10cSrcweir                 }
658cdf0e10cSrcweir             }
659cdf0e10cSrcweir         }
660cdf0e10cSrcweir         catch (beans::UnknownPropertyException &)
661cdf0e10cSrcweir         {
662cdf0e10cSrcweir             // should not occur because property was searched for before
663cdf0e10cSrcweir             DBG_ERROR( "unexpected exception catched" );
664cdf0e10cSrcweir             pFailed[ nFailed++ ].Result =
665cdf0e10cSrcweir                 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
666cdf0e10cSrcweir         }
667cdf0e10cSrcweir         catch (lang::IllegalArgumentException &)
668cdf0e10cSrcweir         {
669cdf0e10cSrcweir             pFailed[ nFailed++ ].Result =
670cdf0e10cSrcweir                 beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
671cdf0e10cSrcweir         }
672cdf0e10cSrcweir         catch (beans::PropertyVetoException &)
673cdf0e10cSrcweir         {
674cdf0e10cSrcweir             pFailed[ nFailed++ ].Result =
675cdf0e10cSrcweir                 beans::TolerantPropertySetResultType::PROPERTY_VETO;
676cdf0e10cSrcweir         }
677cdf0e10cSrcweir         catch (lang::WrappedTargetException &)
678cdf0e10cSrcweir         {
679cdf0e10cSrcweir             pFailed[ nFailed++ ].Result =
680cdf0e10cSrcweir                 beans::TolerantPropertySetResultType::WRAPPED_TARGET;
681cdf0e10cSrcweir         }
682cdf0e10cSrcweir     }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir     aFailed.realloc( nFailed );
685cdf0e10cSrcweir     return aFailed;
686cdf0e10cSrcweir }
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 
689cdf0e10cSrcweir uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
getPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames)690cdf0e10cSrcweir SwXParagraph::getPropertyValuesTolerant(
691cdf0e10cSrcweir         const uno::Sequence< OUString >& rPropertyNames )
692cdf0e10cSrcweir throw (uno::RuntimeException)
693cdf0e10cSrcweir {
694cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
695cdf0e10cSrcweir 
696cdf0e10cSrcweir     uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
697cdf0e10cSrcweir         m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
698cdf0e10cSrcweir     const beans::GetDirectPropertyTolerantResult *pTmpRes =
699cdf0e10cSrcweir         aTmpRes.getConstArray();
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     // copy temporary result to final result type
702cdf0e10cSrcweir     const sal_Int32 nLen = aTmpRes.getLength();
703cdf0e10cSrcweir     uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
704cdf0e10cSrcweir     beans::GetPropertyTolerantResult *pRes = aRes.getArray();
705cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nLen;  i++)
706cdf0e10cSrcweir     {
707cdf0e10cSrcweir         *pRes++ = *pTmpRes++;
708cdf0e10cSrcweir     }
709cdf0e10cSrcweir     return aRes;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 
713cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
getDirectPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames)714cdf0e10cSrcweir SwXParagraph::getDirectPropertyValuesTolerant(
715cdf0e10cSrcweir         const uno::Sequence< OUString >& rPropertyNames )
716cdf0e10cSrcweir throw (uno::RuntimeException)
717cdf0e10cSrcweir {
718cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
719cdf0e10cSrcweir 
720cdf0e10cSrcweir     return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
721cdf0e10cSrcweir }
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 
724cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult >
GetPropertyValuesTolerant_Impl(const uno::Sequence<OUString> & rPropertyNames,bool bDirectValuesOnly)725cdf0e10cSrcweir SwXParagraph::Impl::GetPropertyValuesTolerant_Impl(
726cdf0e10cSrcweir         const uno::Sequence< OUString >& rPropertyNames,
727cdf0e10cSrcweir         bool bDirectValuesOnly )
728cdf0e10cSrcweir throw (uno::RuntimeException)
729cdf0e10cSrcweir {
730cdf0e10cSrcweir     vos::OGuard aGuard( Application::GetSolarMutex() );
731cdf0e10cSrcweir 
732cdf0e10cSrcweir     SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
733cdf0e10cSrcweir 
734cdf0e10cSrcweir     // #i46786# Use SwAttrSet pointer for determining the state.
735cdf0e10cSrcweir     //          Use the value SwAttrSet (from the paragraph OR the style)
736cdf0e10cSrcweir     //          for determining the actual value(s).
737cdf0e10cSrcweir     const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet();
738cdf0e10cSrcweir     const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet();
739cdf0e10cSrcweir 
740cdf0e10cSrcweir     sal_Int32 nProps = rPropertyNames.getLength();
741cdf0e10cSrcweir     const OUString *pProp = rPropertyNames.getConstArray();
742cdf0e10cSrcweir 
743cdf0e10cSrcweir     uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
744cdf0e10cSrcweir     beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
745cdf0e10cSrcweir     sal_Int32 nIdx = 0;
746cdf0e10cSrcweir 
747cdf0e10cSrcweir     // get entry to start with
748cdf0e10cSrcweir     SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap();
749cdf0e10cSrcweir 
750cdf0e10cSrcweir     for (sal_Int32 i = 0;  i < nProps;  ++i)
751cdf0e10cSrcweir     {
752cdf0e10cSrcweir         DBG_ASSERT( nIdx < nProps, "index out ouf bounds" );
753cdf0e10cSrcweir         beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
754cdf0e10cSrcweir 
755cdf0e10cSrcweir         try
756cdf0e10cSrcweir         {
757cdf0e10cSrcweir             rResult.Name = pProp[i];
758cdf0e10cSrcweir 
759cdf0e10cSrcweir             SfxItemPropertySimpleEntry const*const pEntry =
760cdf0e10cSrcweir                 pPropMap->getByName( pProp[i] );
761cdf0e10cSrcweir             if (!pEntry)  // property available?
762cdf0e10cSrcweir             {
763cdf0e10cSrcweir                 rResult.Result =
764cdf0e10cSrcweir                     beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
765cdf0e10cSrcweir             }
766cdf0e10cSrcweir             else
767cdf0e10cSrcweir             {
768cdf0e10cSrcweir                 // get property state
769cdf0e10cSrcweir                 // (compare to SwXParagraph::getPropertyState)
770cdf0e10cSrcweir                 sal_Bool bAttrSetFetched = sal_True;
771cdf0e10cSrcweir                 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
772cdf0e10cSrcweir                             rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched );
773cdf0e10cSrcweir                 rResult.State  = eState;
774cdf0e10cSrcweir 
775cdf0e10cSrcweir //                if (bDirectValuesOnly  &&  PropertyState_DIRECT_VALUE != eState)
776cdf0e10cSrcweir //                    rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE;
777cdf0e10cSrcweir //                else
778cdf0e10cSrcweir                 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
779cdf0e10cSrcweir                 if (!bDirectValuesOnly ||
780cdf0e10cSrcweir                     (beans::PropertyState_DIRECT_VALUE == eState))
781cdf0e10cSrcweir                 {
782cdf0e10cSrcweir                     // get property value
783cdf0e10cSrcweir                     // (compare to SwXParagraph::getPropertyValue(s))
784cdf0e10cSrcweir                     uno::Any aValue;
785cdf0e10cSrcweir                     if (! ::sw::GetDefaultTextContentValue(
786cdf0e10cSrcweir                                 aValue, pProp[i], pEntry->nWID ) )
787cdf0e10cSrcweir                     {
788cdf0e10cSrcweir                         SwPosition aPos( rTxtNode );
789cdf0e10cSrcweir                         SwPaM aPam( aPos );
790cdf0e10cSrcweir                         // handle properties that are not part of the attribute
791cdf0e10cSrcweir                         // and thus only pretendend to be paragraph attributes
792cdf0e10cSrcweir                         beans::PropertyState eTemp;
793cdf0e10cSrcweir                         const bool bDone =
794cdf0e10cSrcweir                             SwUnoCursorHelper::getCrsrPropertyValue(
795cdf0e10cSrcweir                                     *pEntry, aPam, &aValue, eTemp, &rTxtNode );
796cdf0e10cSrcweir 
797cdf0e10cSrcweir                         // if not found try the real paragraph attributes...
798cdf0e10cSrcweir                         if (!bDone)
799cdf0e10cSrcweir                         {
800cdf0e10cSrcweir                             m_rPropSet.getPropertyValue(
801cdf0e10cSrcweir                                 *pEntry, rValueAttrSet, aValue );
802cdf0e10cSrcweir                         }
803cdf0e10cSrcweir                     }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir                     rResult.Value  = aValue;
806cdf0e10cSrcweir                     rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
807cdf0e10cSrcweir 
808cdf0e10cSrcweir                     nIdx++;
809cdf0e10cSrcweir                 }
810cdf0e10cSrcweir                 // this assertion should never occur!
811cdf0e10cSrcweir                 DBG_ASSERT( nIdx < 1  ||  pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
812cdf0e10cSrcweir                         "unknown failure while retrieving property" );
813cdf0e10cSrcweir 
814cdf0e10cSrcweir             }
815cdf0e10cSrcweir         }
816cdf0e10cSrcweir         catch (beans::UnknownPropertyException &)
817cdf0e10cSrcweir         {
818cdf0e10cSrcweir             // should not occur because property was searched for before
819cdf0e10cSrcweir             DBG_ERROR( "unexpected exception caught" );
820cdf0e10cSrcweir             rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
821cdf0e10cSrcweir         }
822cdf0e10cSrcweir         catch (lang::IllegalArgumentException &)
823cdf0e10cSrcweir         {
824cdf0e10cSrcweir             rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
825cdf0e10cSrcweir         }
826cdf0e10cSrcweir         catch (beans::PropertyVetoException &)
827cdf0e10cSrcweir         {
828cdf0e10cSrcweir             rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
829cdf0e10cSrcweir         }
830cdf0e10cSrcweir         catch (lang::WrappedTargetException &)
831cdf0e10cSrcweir         {
832cdf0e10cSrcweir             rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
833cdf0e10cSrcweir         }
834cdf0e10cSrcweir     }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir     // resize to actually used size
837cdf0e10cSrcweir     aResult.realloc( nIdx );
838cdf0e10cSrcweir 
839cdf0e10cSrcweir     return aResult;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir 
842cdf0e10cSrcweir /* -----------------------------12.09.00 11:09--------------------------------
843cdf0e10cSrcweir 
844cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
GetDefaultTextContentValue(uno::Any & rAny,const OUString & rPropertyName,sal_uInt16 nWID)845cdf0e10cSrcweir bool ::sw::GetDefaultTextContentValue(
846cdf0e10cSrcweir         uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID)
847cdf0e10cSrcweir {
848cdf0e10cSrcweir 	if(!nWID)
849cdf0e10cSrcweir 	{
850cdf0e10cSrcweir 		if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)))
851cdf0e10cSrcweir 			nWID = FN_UNO_ANCHOR_TYPE;
852cdf0e10cSrcweir 		else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)))
853cdf0e10cSrcweir 			nWID = FN_UNO_ANCHOR_TYPES;
854cdf0e10cSrcweir 		else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP)))
855cdf0e10cSrcweir 			nWID = FN_UNO_TEXT_WRAP;
856cdf0e10cSrcweir 		else
857cdf0e10cSrcweir 			return sal_False;
858cdf0e10cSrcweir 	}
859cdf0e10cSrcweir 
860cdf0e10cSrcweir 	switch(nWID)
861cdf0e10cSrcweir 	{
862cdf0e10cSrcweir 		case FN_UNO_TEXT_WRAP:  rAny <<= text::WrapTextMode_NONE; break;
863cdf0e10cSrcweir 		case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
864cdf0e10cSrcweir 		case FN_UNO_ANCHOR_TYPES:
865cdf0e10cSrcweir 		{	uno::Sequence<text::TextContentAnchorType> aTypes(1);
866cdf0e10cSrcweir 			text::TextContentAnchorType* pArray = aTypes.getArray();
867cdf0e10cSrcweir 			pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
868cdf0e10cSrcweir 			rAny.setValue(&aTypes, ::getCppuType((uno::Sequence<text::TextContentAnchorType>*)0));
869cdf0e10cSrcweir 		}
870cdf0e10cSrcweir 		break;
871cdf0e10cSrcweir 		default:
872cdf0e10cSrcweir 			return sal_False;
873cdf0e10cSrcweir 	}
874cdf0e10cSrcweir 	return sal_True;
875cdf0e10cSrcweir }
876cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
877cdf0e10cSrcweir 
878cdf0e10cSrcweir   -----------------------------------------------------------------------*/
879cdf0e10cSrcweir void SAL_CALL
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)880cdf0e10cSrcweir SwXParagraph::addPropertyChangeListener(
881cdf0e10cSrcweir         const ::rtl::OUString& /*rPropertyName*/,
882cdf0e10cSrcweir         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
883cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
884cdf0e10cSrcweir     uno::RuntimeException)
885cdf0e10cSrcweir {
886cdf0e10cSrcweir     OSL_ENSURE(false,
887cdf0e10cSrcweir         "SwXParagraph::addPropertyChangeListener(): not implemented");
888cdf0e10cSrcweir }
889cdf0e10cSrcweir 
890cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
891cdf0e10cSrcweir 
892cdf0e10cSrcweir   -----------------------------------------------------------------------*/
893cdf0e10cSrcweir void SAL_CALL
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)894cdf0e10cSrcweir SwXParagraph::removePropertyChangeListener(
895cdf0e10cSrcweir         const ::rtl::OUString& /*rPropertyName*/,
896cdf0e10cSrcweir         const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
897cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
898cdf0e10cSrcweir     uno::RuntimeException)
899cdf0e10cSrcweir {
900cdf0e10cSrcweir     OSL_ENSURE(false,
901cdf0e10cSrcweir         "SwXParagraph::removePropertyChangeListener(): not implemented");
902cdf0e10cSrcweir }
903cdf0e10cSrcweir 
904cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
905cdf0e10cSrcweir 
906cdf0e10cSrcweir   -----------------------------------------------------------------------*/
907cdf0e10cSrcweir void SAL_CALL
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)908cdf0e10cSrcweir SwXParagraph::addVetoableChangeListener(
909cdf0e10cSrcweir         const ::rtl::OUString& /*rPropertyName*/,
910cdf0e10cSrcweir         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
911cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
912cdf0e10cSrcweir     uno::RuntimeException)
913cdf0e10cSrcweir {
914cdf0e10cSrcweir     OSL_ENSURE(false,
915cdf0e10cSrcweir         "SwXParagraph::addVetoableChangeListener(): not implemented");
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
919cdf0e10cSrcweir 
920cdf0e10cSrcweir   -----------------------------------------------------------------------*/
921cdf0e10cSrcweir void SAL_CALL
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)922cdf0e10cSrcweir SwXParagraph::removeVetoableChangeListener(
923cdf0e10cSrcweir         const ::rtl::OUString& /*rPropertyName*/,
924cdf0e10cSrcweir         const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
925cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
926cdf0e10cSrcweir         uno::RuntimeException)
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     OSL_ENSURE(false,
929cdf0e10cSrcweir         "SwXParagraph::removeVetoableChangeListener(): not implemented");
930cdf0e10cSrcweir }
931cdf0e10cSrcweir 
932cdf0e10cSrcweir //-----------------------------------------------------------------------------
lcl_SwXParagraph_getPropertyState(const SwTxtNode & rTxtNode,const SwAttrSet ** ppSet,const SfxItemPropertySimpleEntry & rEntry,sal_Bool & rAttrSetFetched)933cdf0e10cSrcweir beans::PropertyState lcl_SwXParagraph_getPropertyState(
934cdf0e10cSrcweir //							SwUnoCrsr& rUnoCrsr,
935cdf0e10cSrcweir 							const SwTxtNode& rTxtNode,
936cdf0e10cSrcweir 							const SwAttrSet** ppSet,
937cdf0e10cSrcweir                             const SfxItemPropertySimpleEntry& rEntry,
938cdf0e10cSrcweir 							sal_Bool &rAttrSetFetched )
939cdf0e10cSrcweir throw (beans::UnknownPropertyException)
940cdf0e10cSrcweir {
941cdf0e10cSrcweir 	beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
942cdf0e10cSrcweir 
943cdf0e10cSrcweir 	if(!(*ppSet) && !rAttrSetFetched )
944cdf0e10cSrcweir 	{
945cdf0e10cSrcweir         (*ppSet) = rTxtNode.GetpSwAttrSet();
946cdf0e10cSrcweir 		rAttrSetFetched = sal_True;
947cdf0e10cSrcweir 	}
948cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
949cdf0e10cSrcweir     SwPaM aPam( aPos );
950cdf0e10cSrcweir     switch( rEntry.nWID )
951cdf0e10cSrcweir 	{
952cdf0e10cSrcweir 	case FN_UNO_NUM_RULES:
953cdf0e10cSrcweir         // if numbering is set, return it; else do nothing
954cdf0e10cSrcweir         SwUnoCursorHelper::getNumberingProperty( aPam, eRet, NULL );
955cdf0e10cSrcweir         break;
956cdf0e10cSrcweir 	case FN_UNO_ANCHOR_TYPES:
957cdf0e10cSrcweir 		break;
958cdf0e10cSrcweir 	case RES_ANCHOR:
959cdf0e10cSrcweir         if ( MID_SURROUND_SURROUNDTYPE != rEntry.nMemberId )
960cdf0e10cSrcweir 			goto lcl_SwXParagraph_getPropertyStateDEFAULT;
961cdf0e10cSrcweir 		break;
962cdf0e10cSrcweir 	case RES_SURROUND:
963cdf0e10cSrcweir         if ( MID_ANCHOR_ANCHORTYPE != rEntry.nMemberId )
964cdf0e10cSrcweir 			goto lcl_SwXParagraph_getPropertyStateDEFAULT;
965cdf0e10cSrcweir 		break;
966cdf0e10cSrcweir 	case FN_UNO_PARA_STYLE:
967cdf0e10cSrcweir 	case FN_UNO_PARA_CONDITIONAL_STYLE_NAME:
968cdf0e10cSrcweir 		{
969cdf0e10cSrcweir             SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(
970cdf0e10cSrcweir                 aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME);
971cdf0e10cSrcweir 			eRet = pFmt ? beans::PropertyState_DIRECT_VALUE
972cdf0e10cSrcweir 						: beans::PropertyState_AMBIGUOUS_VALUE;
973cdf0e10cSrcweir 		}
974cdf0e10cSrcweir 		break;
975cdf0e10cSrcweir 	case FN_UNO_PAGE_STYLE:
976cdf0e10cSrcweir 		{
977cdf0e10cSrcweir 			String sVal;
978cdf0e10cSrcweir             SwUnoCursorHelper::GetCurPageStyle( aPam, sVal );
979cdf0e10cSrcweir 			eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE
980cdf0e10cSrcweir 							  : beans::PropertyState_AMBIGUOUS_VALUE;
981cdf0e10cSrcweir 		}
982cdf0e10cSrcweir 		break;
983cdf0e10cSrcweir 	lcl_SwXParagraph_getPropertyStateDEFAULT:
984cdf0e10cSrcweir 	default:
985cdf0e10cSrcweir         if((*ppSet) && SFX_ITEM_SET == (*ppSet)->GetItemState(rEntry.nWID, sal_False))
986cdf0e10cSrcweir 			eRet = beans::PropertyState_DIRECT_VALUE;
987cdf0e10cSrcweir 		break;
988cdf0e10cSrcweir 	}
989cdf0e10cSrcweir     return eRet;
990cdf0e10cSrcweir }
991cdf0e10cSrcweir 
992cdf0e10cSrcweir /*-- 05.03.99 11:37:30---------------------------------------------------
993cdf0e10cSrcweir 
994cdf0e10cSrcweir   -----------------------------------------------------------------------*/
995cdf0e10cSrcweir beans::PropertyState SAL_CALL
getPropertyState(const OUString & rPropertyName)996cdf0e10cSrcweir SwXParagraph::getPropertyState(const OUString& rPropertyName)
997cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
998cdf0e10cSrcweir {
999cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir     const SwAttrSet* pSet = 0;
1004cdf0e10cSrcweir     SfxItemPropertySimpleEntry const*const pEntry =
1005cdf0e10cSrcweir         m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
1006cdf0e10cSrcweir     if (!pEntry)
1007cdf0e10cSrcweir     {
1008cdf0e10cSrcweir         throw beans::UnknownPropertyException(
1009cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1010cdf0e10cSrcweir                 + rPropertyName,
1011cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
1012cdf0e10cSrcweir     }
1013cdf0e10cSrcweir     sal_Bool bDummy = sal_False;
1014cdf0e10cSrcweir     const beans::PropertyState eRet =
1015cdf0e10cSrcweir         lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy);
1016cdf0e10cSrcweir 	return eRet;
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir /*-- 05.03.99 11:37:32---------------------------------------------------
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1021cdf0e10cSrcweir 
1022cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SAL_CALL
getPropertyStates(const uno::Sequence<OUString> & PropertyNames)1023cdf0e10cSrcweir SwXParagraph::getPropertyStates(
1024cdf0e10cSrcweir 		const uno::Sequence< OUString >& PropertyNames)
1025cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 	const OUString* pNames = PropertyNames.getConstArray();
1032cdf0e10cSrcweir 	uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
1033cdf0e10cSrcweir 	beans::PropertyState* pStates = aRet.getArray();
1034cdf0e10cSrcweir     SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap();
1035cdf0e10cSrcweir     const SwAttrSet* pSet = 0;
1036cdf0e10cSrcweir     sal_Bool bAttrSetFetched = sal_False;
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
1039cdf0e10cSrcweir             ++i, ++pStates, ++pNames)
1040cdf0e10cSrcweir     {
1041cdf0e10cSrcweir         SfxItemPropertySimpleEntry const*const pEntry =
1042cdf0e10cSrcweir             pMap->getByName( *pNames );
1043cdf0e10cSrcweir         if (!pEntry)
1044cdf0e10cSrcweir         {
1045cdf0e10cSrcweir             throw beans::UnknownPropertyException(
1046cdf0e10cSrcweir                 OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1047cdf0e10cSrcweir                     + *pNames,
1048cdf0e10cSrcweir                 static_cast<cppu::OWeakObject *>(this));
1049cdf0e10cSrcweir         }
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir         if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
1052cdf0e10cSrcweir         {
1053cdf0e10cSrcweir             *pStates = beans::PropertyState_DEFAULT_VALUE;
1054cdf0e10cSrcweir         }
1055cdf0e10cSrcweir         else
1056cdf0e10cSrcweir         {
1057cdf0e10cSrcweir             *pStates = lcl_SwXParagraph_getPropertyState(
1058cdf0e10cSrcweir                 rTxtNode, &pSet, *pEntry, bAttrSetFetched );
1059cdf0e10cSrcweir         }
1060cdf0e10cSrcweir     }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir 	return aRet;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir /*-- 05.03.99 11:37:33---------------------------------------------------
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1068cdf0e10cSrcweir void SAL_CALL
setPropertyToDefault(const OUString & rPropertyName)1069cdf0e10cSrcweir SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
1070cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1077cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
1078cdf0e10cSrcweir     if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE))  ||
1079cdf0e10cSrcweir         rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) ||
1080cdf0e10cSrcweir         rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP)))
1081cdf0e10cSrcweir     {
1082cdf0e10cSrcweir         return;
1083cdf0e10cSrcweir     }
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir     // select paragraph
1086cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
1087cdf0e10cSrcweir     SfxItemPropertySimpleEntry const*const pEntry =
1088cdf0e10cSrcweir         m_pImpl->m_rPropSet.getPropertyMap()->getByName( rPropertyName );
1089cdf0e10cSrcweir     if (!pEntry)
1090cdf0e10cSrcweir     {
1091cdf0e10cSrcweir         throw beans::UnknownPropertyException(
1092cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1093cdf0e10cSrcweir                 + rPropertyName,
1094cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
1095cdf0e10cSrcweir     }
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir     if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1098cdf0e10cSrcweir     {
1099cdf0e10cSrcweir         throw uno::RuntimeException(
1100cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
1101cdf0e10cSrcweir                 + rPropertyName,
1102cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
1103cdf0e10cSrcweir     }
1104cdf0e10cSrcweir 
1105cdf0e10cSrcweir     if (pEntry->nWID < RES_FRMATR_END)
1106cdf0e10cSrcweir     {
1107cdf0e10cSrcweir         SvUShortsSort aWhichIds;
1108cdf0e10cSrcweir         aWhichIds.Insert(pEntry->nWID);
1109cdf0e10cSrcweir         if (pEntry->nWID < RES_PARATR_BEGIN)
1110cdf0e10cSrcweir         {
1111cdf0e10cSrcweir             aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds);
1112cdf0e10cSrcweir         }
1113cdf0e10cSrcweir         else
1114cdf0e10cSrcweir         {
1115cdf0e10cSrcweir             // for paragraph attributes the selection must be extended
1116cdf0e10cSrcweir             // to paragraph boundaries
1117cdf0e10cSrcweir             SwPosition aStart( *aCursor.Start() );
1118cdf0e10cSrcweir             SwPosition aEnd  ( *aCursor.End()   );
1119cdf0e10cSrcweir             ::std::auto_ptr<SwUnoCrsr> pTemp(
1120cdf0e10cSrcweir                 aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) );
1121cdf0e10cSrcweir             if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
1122cdf0e10cSrcweir             {
1123cdf0e10cSrcweir                 pTemp->MovePara(fnParaCurr, fnParaStart);
1124cdf0e10cSrcweir             }
1125cdf0e10cSrcweir             pTemp->SetMark();
1126cdf0e10cSrcweir             *pTemp->GetPoint() = aEnd;
1127cdf0e10cSrcweir             //pTemp->Exchange();
1128cdf0e10cSrcweir             SwUnoCursorHelper::SelectPam(*pTemp, true);
1129cdf0e10cSrcweir             if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1130cdf0e10cSrcweir             {
1131cdf0e10cSrcweir                 pTemp->MovePara(fnParaCurr, fnParaEnd);
1132cdf0e10cSrcweir             }
1133cdf0e10cSrcweir             pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds);
1134cdf0e10cSrcweir         }
1135cdf0e10cSrcweir     }
1136cdf0e10cSrcweir     else
1137cdf0e10cSrcweir     {
1138cdf0e10cSrcweir         SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor);
1139cdf0e10cSrcweir     }
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir /*-- 05.03.99 11:37:33---------------------------------------------------
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1145cdf0e10cSrcweir uno::Any SAL_CALL
getPropertyDefault(const OUString & rPropertyName)1146cdf0e10cSrcweir SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
1147cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1148cdf0e10cSrcweir     uno::RuntimeException)
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir 	uno::Any aRet;
1155cdf0e10cSrcweir     if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
1156cdf0e10cSrcweir     {
1157cdf0e10cSrcweir         return aRet;
1158cdf0e10cSrcweir     }
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir     SfxItemPropertySimpleEntry const*const pEntry =
1161cdf0e10cSrcweir         m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
1162cdf0e10cSrcweir     if (!pEntry)
1163cdf0e10cSrcweir     {
1164cdf0e10cSrcweir         throw beans::UnknownPropertyException(
1165cdf0e10cSrcweir             OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1166cdf0e10cSrcweir                 + rPropertyName,
1167cdf0e10cSrcweir             static_cast<cppu::OWeakObject *>(this));
1168cdf0e10cSrcweir     }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     if (pEntry->nWID < RES_FRMATR_END)
1171cdf0e10cSrcweir     {
1172cdf0e10cSrcweir         const SfxPoolItem& rDefItem =
1173cdf0e10cSrcweir             rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
1174cdf0e10cSrcweir         rDefItem.QueryValue(aRet, pEntry->nMemberId);
1175cdf0e10cSrcweir     }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir 	return aRet;
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1183cdf0e10cSrcweir void SAL_CALL
attach(const uno::Reference<text::XTextRange> &)1184cdf0e10cSrcweir SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
1185cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1186cdf0e10cSrcweir {
1187cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1188cdf0e10cSrcweir     // SwXParagraph will only created in order to be inserted by
1189cdf0e10cSrcweir     // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
1190cdf0e10cSrcweir     // they cannot be attached
1191cdf0e10cSrcweir     throw uno::RuntimeException();
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1197cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getAnchor()1198cdf0e10cSrcweir SwXParagraph::getAnchor() throw (uno::RuntimeException)
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1205cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
1206cdf0e10cSrcweir     // select paragraph
1207cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
1208cdf0e10cSrcweir     const uno::Reference< text::XTextRange >  xRet =
1209cdf0e10cSrcweir         new SwXTextRange(aCursor, m_pImpl->m_xParentText);
1210cdf0e10cSrcweir     return xRet;
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir /*-- 11.12.98 08:12:52---------------------------------------------------
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir   -----------------------------------------------------------------------*/
dispose()1216cdf0e10cSrcweir void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException)
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1221cdf0e10cSrcweir     if (pTxtNode)
1222cdf0e10cSrcweir     {
1223cdf0e10cSrcweir         SwCursor aCursor( SwPosition( *pTxtNode ), 0, false );
1224cdf0e10cSrcweir         // select paragraph
1225cdf0e10cSrcweir         {
1226cdf0e10cSrcweir             SwParaSelection aParaSel( aCursor );
1227cdf0e10cSrcweir             pTxtNode->GetDoc()->DelFullPara(aCursor);
1228cdf0e10cSrcweir         }
1229cdf0e10cSrcweir         m_pImpl->m_ListenerContainer.Disposing();
1230cdf0e10cSrcweir     }
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir /*-- 11.12.98 08:12:52---------------------------------------------------
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir   -----------------------------------------------------------------------*/
addEventListener(const uno::Reference<lang::XEventListener> & xListener)1236cdf0e10cSrcweir void SAL_CALL SwXParagraph::addEventListener(
1237cdf0e10cSrcweir         const uno::Reference< lang::XEventListener > & xListener)
1238cdf0e10cSrcweir throw (uno::RuntimeException)
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir     if (!m_pImpl->GetTxtNode())
1243cdf0e10cSrcweir     {
1244cdf0e10cSrcweir 		throw uno::RuntimeException();
1245cdf0e10cSrcweir     }
1246cdf0e10cSrcweir     m_pImpl->m_ListenerContainer.AddListener(xListener);
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir /*-- 11.12.98 08:12:53---------------------------------------------------
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir   -----------------------------------------------------------------------*/
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)1251cdf0e10cSrcweir void SAL_CALL SwXParagraph::removeEventListener(
1252cdf0e10cSrcweir         const uno::Reference< lang::XEventListener > & xListener)
1253cdf0e10cSrcweir throw (uno::RuntimeException)
1254cdf0e10cSrcweir {
1255cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir     if (!m_pImpl->GetTxtNode() ||
1258cdf0e10cSrcweir         !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
1259cdf0e10cSrcweir     {
1260cdf0e10cSrcweir 		throw uno::RuntimeException();
1261cdf0e10cSrcweir     }
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir /*-- 11.12.98 08:12:53---------------------------------------------------
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1267cdf0e10cSrcweir uno::Reference< container::XEnumeration >  SAL_CALL
createEnumeration()1268cdf0e10cSrcweir SwXParagraph::createEnumeration() throw (uno::RuntimeException)
1269cdf0e10cSrcweir {
1270cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1275cdf0e10cSrcweir     SwPaM aPam ( aPos );
1276cdf0e10cSrcweir     const uno::Reference< container::XEnumeration > xRef =
1277cdf0e10cSrcweir         new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
1278cdf0e10cSrcweir             m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
1279cdf0e10cSrcweir     return xRef;
1280cdf0e10cSrcweir }
1281cdf0e10cSrcweir 
1282cdf0e10cSrcweir /*-- 11.12.98 08:12:54---------------------------------------------------
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getElementType()1285cdf0e10cSrcweir uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException)
1286cdf0e10cSrcweir {
1287cdf0e10cSrcweir     return text::XTextRange::static_type();
1288cdf0e10cSrcweir }
1289cdf0e10cSrcweir /*-- 11.12.98 08:12:54---------------------------------------------------
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir   -----------------------------------------------------------------------*/
hasElements()1292cdf0e10cSrcweir sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException)
1293cdf0e10cSrcweir {
1294cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1295cdf0e10cSrcweir     return (GetTxtNode()) ? sal_True : sal_False;
1296cdf0e10cSrcweir }
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir /*-- 11.12.98 08:12:55---------------------------------------------------
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1301cdf0e10cSrcweir uno::Reference< text::XText > SAL_CALL
getText()1302cdf0e10cSrcweir SwXParagraph::getText() throw (uno::RuntimeException)
1303cdf0e10cSrcweir {
1304cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
1305cdf0e10cSrcweir 
1306cdf0e10cSrcweir     return m_pImpl->m_xParentText;
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir /*-- 11.12.98 08:12:55---------------------------------------------------
1310cdf0e10cSrcweir 
1311cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1312cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getStart()1313cdf0e10cSrcweir SwXParagraph::getStart() throw (uno::RuntimeException)
1314cdf0e10cSrcweir {
1315cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1318cdf0e10cSrcweir 
1319cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1320cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
1321cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
1322cdf0e10cSrcweir     SwPaM aPam( *aCursor.Start() );
1323cdf0e10cSrcweir     uno::Reference< text::XText >  xParent = getText();
1324cdf0e10cSrcweir     const uno::Reference< text::XTextRange > xRet =
1325cdf0e10cSrcweir         new SwXTextRange(aPam, xParent);
1326cdf0e10cSrcweir 	return xRet;
1327cdf0e10cSrcweir }
1328cdf0e10cSrcweir /*-- 11.12.98 08:12:56---------------------------------------------------
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir   -----------------------------------------------------------------------*/
1331cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getEnd()1332cdf0e10cSrcweir SwXParagraph::getEnd() throw (uno::RuntimeException)
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1335cdf0e10cSrcweir 
1336cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1337cdf0e10cSrcweir 
1338cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1339cdf0e10cSrcweir     SwCursor aCursor( aPos, 0, false );
1340cdf0e10cSrcweir     SwParaSelection aParaSel( aCursor );
1341cdf0e10cSrcweir     SwPaM aPam( *aCursor.End() );
1342cdf0e10cSrcweir     uno::Reference< text::XText >  xParent = getText();
1343cdf0e10cSrcweir     const uno::Reference< text::XTextRange > xRet =
1344cdf0e10cSrcweir         new SwXTextRange(aPam, xParent);
1345cdf0e10cSrcweir 	return xRet;
1346cdf0e10cSrcweir }
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir /*-- 11.12.98 08:12:56---------------------------------------------------
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir   -----------------------------------------------------------------------*/
getString()1351cdf0e10cSrcweir OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException)
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1354cdf0e10cSrcweir 	OUString aRet;
1355cdf0e10cSrcweir     SwTxtNode const*const pTxtNode( GetTxtNode() );
1356cdf0e10cSrcweir     if (pTxtNode)
1357cdf0e10cSrcweir     {
1358cdf0e10cSrcweir         SwPosition aPos( *pTxtNode );
1359cdf0e10cSrcweir         SwCursor aCursor( aPos, 0, false );
1360cdf0e10cSrcweir         SwParaSelection aParaSel( aCursor );
1361cdf0e10cSrcweir         SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
1362cdf0e10cSrcweir     }
1363cdf0e10cSrcweir     else if (m_pImpl->IsDescriptor())
1364cdf0e10cSrcweir     {
1365cdf0e10cSrcweir         aRet = m_pImpl->m_sText;
1366cdf0e10cSrcweir     }
1367cdf0e10cSrcweir     else
1368cdf0e10cSrcweir     {
1369cdf0e10cSrcweir 		throw uno::RuntimeException();
1370cdf0e10cSrcweir     }
1371cdf0e10cSrcweir 	return aRet;
1372cdf0e10cSrcweir }
1373cdf0e10cSrcweir /*-- 11.12.98 08:12:57---------------------------------------------------
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir   -----------------------------------------------------------------------*/
setString(const OUString & aString)1376cdf0e10cSrcweir void SAL_CALL SwXParagraph::setString(const OUString& aString)
1377cdf0e10cSrcweir throw (uno::RuntimeException)
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir     SwTxtNode const*const pTxtNode( GetTxtNode() );
1382cdf0e10cSrcweir     if (pTxtNode)
1383cdf0e10cSrcweir     {
1384cdf0e10cSrcweir         SwPosition aPos( *pTxtNode );
1385cdf0e10cSrcweir         SwCursor aCursor( aPos, 0, false );
1386cdf0e10cSrcweir         if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
1387cdf0e10cSrcweir             aCursor.MovePara(fnParaCurr, fnParaStart);
1388cdf0e10cSrcweir         }
1389cdf0e10cSrcweir         SwUnoCursorHelper::SelectPam(aCursor, true);
1390cdf0e10cSrcweir         if (pTxtNode->GetTxt().Len()) {
1391cdf0e10cSrcweir             aCursor.MovePara(fnParaCurr, fnParaEnd);
1392cdf0e10cSrcweir         }
1393cdf0e10cSrcweir         SwUnoCursorHelper::SetString(aCursor, aString);
1394cdf0e10cSrcweir         SwUnoCursorHelper::SelectPam(aCursor, false);
1395cdf0e10cSrcweir     }
1396cdf0e10cSrcweir     else if (m_pImpl->IsDescriptor())
1397cdf0e10cSrcweir     {
1398cdf0e10cSrcweir         m_pImpl->m_sText = aString;
1399cdf0e10cSrcweir     }
1400cdf0e10cSrcweir 	else
1401cdf0e10cSrcweir     {
1402cdf0e10cSrcweir 		throw uno::RuntimeException();
1403cdf0e10cSrcweir     }
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir /* -----------------23.03.99 12:49-------------------
1407cdf0e10cSrcweir  *
1408cdf0e10cSrcweir  * --------------------------------------------------*/
1409cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createContentEnumeration(const OUString & rServiceName)1410cdf0e10cSrcweir SwXParagraph::createContentEnumeration(const OUString& rServiceName)
1411cdf0e10cSrcweir throw (uno::RuntimeException)
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir     vos::OGuard g(Application::GetSolarMutex());
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir     if (!rServiceName.equalsAscii("com.sun.star.text.TextContent"))
1416cdf0e10cSrcweir     {
1417cdf0e10cSrcweir         throw uno::RuntimeException();
1418cdf0e10cSrcweir     }
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir     SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir     SwPosition aPos( rTxtNode );
1423cdf0e10cSrcweir     SwPaM aPam( aPos );
1424cdf0e10cSrcweir     uno::Reference< container::XEnumeration > xRet =
1425cdf0e10cSrcweir         new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH);
1426cdf0e10cSrcweir 	return xRet;
1427cdf0e10cSrcweir }
1428cdf0e10cSrcweir /* -----------------23.03.99 12:49-------------------
1429cdf0e10cSrcweir  *
1430cdf0e10cSrcweir  * --------------------------------------------------*/
1431cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getAvailableServiceNames()1432cdf0e10cSrcweir SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException)
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir 	uno::Sequence< OUString > aRet(1);
1435cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
1436cdf0e10cSrcweir 	pArray[0] = C2U("com.sun.star.text.TextContent");
1437cdf0e10cSrcweir 	return aRet;
1438cdf0e10cSrcweir }
1439cdf0e10cSrcweir 
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir // MetadatableMixin
GetCoreObject()1442cdf0e10cSrcweir ::sfx2::Metadatable* SwXParagraph::GetCoreObject()
1443cdf0e10cSrcweir {
1444cdf0e10cSrcweir     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1445cdf0e10cSrcweir     return pTxtNode;
1446cdf0e10cSrcweir }
1447cdf0e10cSrcweir 
GetModel()1448cdf0e10cSrcweir uno::Reference<frame::XModel> SwXParagraph::GetModel()
1449cdf0e10cSrcweir {
1450cdf0e10cSrcweir     SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1451cdf0e10cSrcweir     if (pTxtNode)
1452cdf0e10cSrcweir     {
1453cdf0e10cSrcweir         SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() );
1454cdf0e10cSrcweir         return (pShell) ? pShell->GetModel() : 0;
1455cdf0e10cSrcweir     }
1456cdf0e10cSrcweir     return 0;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir 
1459