1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22*2eda3cbfSmseidel
23*2eda3cbfSmseidel
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
5556b35d86SArmin Le Grand //UUUU
5656b35d86SArmin Le Grand #include <swunohelper.hxx>
5756b35d86SArmin Le Grand #include <svx/unobrushitemhelper.hxx>
5856b35d86SArmin Le Grand #include <editeng/unoipset.hxx>
5956b35d86SArmin Le Grand #include <svx/xflbstit.hxx>
6056b35d86SArmin Le Grand #include <svx/xflbmtit.hxx>
6156b35d86SArmin Le Grand #include <com/sun/star/drawing/BitmapMode.hpp>
62cdf0e10cSrcweir
63cdf0e10cSrcweir using namespace ::com::sun::star;
64cdf0e10cSrcweir using ::rtl::OUString;
65cdf0e10cSrcweir
66cdf0e10cSrcweir /* -----------------------------01.12.00 18:09--------------------------------
67cdf0e10cSrcweir
68cdf0e10cSrcweir ---------------------------------------------------------------------------*/
69cdf0e10cSrcweir class SwParaSelection
70cdf0e10cSrcweir {
71cdf0e10cSrcweir SwCursor & m_rCursor;
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir SwParaSelection(SwCursor & rCursor);
74cdf0e10cSrcweir ~SwParaSelection();
75cdf0e10cSrcweir };
76cdf0e10cSrcweir
SwParaSelection(SwCursor & rCursor)77cdf0e10cSrcweir SwParaSelection::SwParaSelection(SwCursor & rCursor)
78cdf0e10cSrcweir : m_rCursor(rCursor)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir if (m_rCursor.HasMark())
81cdf0e10cSrcweir {
82cdf0e10cSrcweir m_rCursor.DeleteMark();
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // is it at the start?
85cdf0e10cSrcweir if (m_rCursor.GetPoint()->nContent != 0)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir m_rCursor.MovePara(fnParaCurr, fnParaStart);
88cdf0e10cSrcweir }
89cdf0e10cSrcweir // or at the end already?
90cdf0e10cSrcweir if (m_rCursor.GetPoint()->nContent != m_rCursor.GetCntntNode()->Len())
91cdf0e10cSrcweir {
92cdf0e10cSrcweir m_rCursor.SetMark();
93cdf0e10cSrcweir m_rCursor.MovePara(fnParaCurr, fnParaEnd);
94cdf0e10cSrcweir }
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
~SwParaSelection()97cdf0e10cSrcweir SwParaSelection::~SwParaSelection()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir if (m_rCursor.GetPoint()->nContent != 0)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir m_rCursor.DeleteMark();
102cdf0e10cSrcweir m_rCursor.MovePara(fnParaCurr, fnParaStart);
103cdf0e10cSrcweir }
104cdf0e10cSrcweir }
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir /******************************************************************
108cdf0e10cSrcweir * forward declarations
109cdf0e10cSrcweir ******************************************************************/
110cdf0e10cSrcweir
111cdf0e10cSrcweir beans::PropertyState lcl_SwXParagraph_getPropertyState(
112cdf0e10cSrcweir const SwTxtNode& rTxtNode,
113cdf0e10cSrcweir const SwAttrSet** ppSet,
114cdf0e10cSrcweir const SfxItemPropertySimpleEntry& rEntry,
115cdf0e10cSrcweir sal_Bool &rAttrSetFetched )
116cdf0e10cSrcweir throw (beans::UnknownPropertyException);
117cdf0e10cSrcweir
118cdf0e10cSrcweir /******************************************************************
119cdf0e10cSrcweir * SwXParagraph
120cdf0e10cSrcweir ******************************************************************/
121cdf0e10cSrcweir
122cdf0e10cSrcweir class SwXParagraph::Impl
123cdf0e10cSrcweir : public SwClient
124cdf0e10cSrcweir {
125cdf0e10cSrcweir
126cdf0e10cSrcweir public:
127cdf0e10cSrcweir SwXParagraph & m_rThis;
128cdf0e10cSrcweir SwEventListenerContainer m_ListenerContainer;
129cdf0e10cSrcweir SfxItemPropertySet const& m_rPropSet;
130cdf0e10cSrcweir bool m_bIsDescriptor;
131cdf0e10cSrcweir sal_Int32 m_nSelectionStartPos;
132cdf0e10cSrcweir sal_Int32 m_nSelectionEndPos;
133cdf0e10cSrcweir ::rtl::OUString m_sText;
134cdf0e10cSrcweir uno::Reference<text::XText> m_xParentText;
135cdf0e10cSrcweir
Impl(SwXParagraph & rThis,SwTxtNode * const pTxtNode=0,uno::Reference<text::XText> const & xParent=0,const sal_Int32 nSelStart=-1,const sal_Int32 nSelEnd=-1)136cdf0e10cSrcweir Impl( SwXParagraph & rThis,
137cdf0e10cSrcweir SwTxtNode *const pTxtNode = 0,
138cdf0e10cSrcweir uno::Reference< text::XText > const & xParent = 0,
139cdf0e10cSrcweir const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
140cdf0e10cSrcweir : SwClient(pTxtNode)
141cdf0e10cSrcweir , m_rThis(rThis)
142cdf0e10cSrcweir , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
143cdf0e10cSrcweir , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
144cdf0e10cSrcweir // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code
145cdf0e10cSrcweir , m_bIsDescriptor((0 == pTxtNode) ? true : false)
146cdf0e10cSrcweir , m_nSelectionStartPos(nSelStart)
147cdf0e10cSrcweir , m_nSelectionEndPos(nSelEnd)
148cdf0e10cSrcweir , m_xParentText(xParent)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
GetTxtNode() const152cdf0e10cSrcweir const SwTxtNode * GetTxtNode() const {
153cdf0e10cSrcweir return static_cast<const SwTxtNode*>(GetRegisteredIn());
154cdf0e10cSrcweir }
GetTxtNode()155cdf0e10cSrcweir SwTxtNode * GetTxtNode() {
156cdf0e10cSrcweir return static_cast<SwTxtNode*>(GetRegisteredInNonConst());
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
GetTxtNodeOrThrow()159cdf0e10cSrcweir SwTxtNode & GetTxtNodeOrThrow() {
160cdf0e10cSrcweir SwTxtNode *const pTxtNode( GetTxtNode() );
161cdf0e10cSrcweir if (!pTxtNode) {
162cdf0e10cSrcweir throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
163cdf0e10cSrcweir "SwXParagraph: disposed or invalid")), 0);
164cdf0e10cSrcweir }
165cdf0e10cSrcweir return *pTxtNode;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir
IsDescriptor() const168cdf0e10cSrcweir bool IsDescriptor() const { return m_bIsDescriptor; }
169cdf0e10cSrcweir
170cdf0e10cSrcweir void SetPropertyValues_Impl(
171cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rPropertyNames,
172cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues)
173cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
174cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException,
175cdf0e10cSrcweir uno::RuntimeException);
176cdf0e10cSrcweir
177cdf0e10cSrcweir uno::Sequence< uno::Any >
178cdf0e10cSrcweir GetPropertyValues_Impl(
179cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rPropertyNames)
180cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
181cdf0e10cSrcweir uno::RuntimeException);
182cdf0e10cSrcweir
18356b35d86SArmin Le Grand //UUUU
18456b35d86SArmin Le Grand void GetSinglePropertyValue_Impl(
18556b35d86SArmin Le Grand const SfxItemPropertySimpleEntry& rEntry,
18656b35d86SArmin Le Grand const SfxItemSet& rSet,
18756b35d86SArmin Le Grand uno::Any& rAny ) const
18856b35d86SArmin Le Grand throw(uno::RuntimeException);
18956b35d86SArmin Le Grand
190cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult >
191cdf0e10cSrcweir GetPropertyValuesTolerant_Impl(
192cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rPropertyNames,
193cdf0e10cSrcweir bool bDirectValuesOnly)
194cdf0e10cSrcweir throw (uno::RuntimeException);
195cdf0e10cSrcweir protected:
196cdf0e10cSrcweir // SwClient
197cdf0e10cSrcweir virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
198cdf0e10cSrcweir
199cdf0e10cSrcweir };
200cdf0e10cSrcweir
201cdf0e10cSrcweir /*-- 11.12.98 08:12:58---------------------------------------------------
202cdf0e10cSrcweir
203cdf0e10cSrcweir -----------------------------------------------------------------------*/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)204cdf0e10cSrcweir void SwXParagraph::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir ClientModify(this, pOld, pNew);
207cdf0e10cSrcweir if (!GetRegisteredIn())
208cdf0e10cSrcweir {
209cdf0e10cSrcweir m_ListenerContainer.Disposing();
210cdf0e10cSrcweir }
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir /*-- 11.12.98 08:12:47---------------------------------------------------
214cdf0e10cSrcweir
215cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXParagraph()216cdf0e10cSrcweir SwXParagraph::SwXParagraph()
217cdf0e10cSrcweir : m_pImpl( new SwXParagraph::Impl(*this) )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
221cdf0e10cSrcweir /*-- 11.12.98 08:12:47---------------------------------------------------
222cdf0e10cSrcweir
223cdf0e10cSrcweir -----------------------------------------------------------------------*/
SwXParagraph(uno::Reference<text::XText> const & xParent,SwTxtNode & rTxtNode,const sal_Int32 nSelStart,const sal_Int32 nSelEnd)224cdf0e10cSrcweir SwXParagraph::SwXParagraph(
225cdf0e10cSrcweir uno::Reference< text::XText > const & xParent,
226cdf0e10cSrcweir SwTxtNode & rTxtNode,
227cdf0e10cSrcweir const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
228cdf0e10cSrcweir : m_pImpl(
229cdf0e10cSrcweir new SwXParagraph::Impl(*this, &rTxtNode, xParent, nSelStart, nSelEnd))
230cdf0e10cSrcweir {
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
233cdf0e10cSrcweir /*-- 11.12.98 08:12:48---------------------------------------------------
234cdf0e10cSrcweir
235cdf0e10cSrcweir -----------------------------------------------------------------------*/
~SwXParagraph()236cdf0e10cSrcweir SwXParagraph::~SwXParagraph()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
GetTxtNode() const240cdf0e10cSrcweir const SwTxtNode * SwXParagraph::GetTxtNode() const
241cdf0e10cSrcweir {
242cdf0e10cSrcweir return m_pImpl->GetTxtNode();
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
IsDescriptor() const245cdf0e10cSrcweir bool SwXParagraph::IsDescriptor() const
246cdf0e10cSrcweir {
247cdf0e10cSrcweir return m_pImpl->IsDescriptor();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir uno::Reference<text::XTextContent>
CreateXParagraph(SwDoc & rDoc,SwTxtNode & rTxtNode,uno::Reference<text::XText> const & i_xParent,const sal_Int32 nSelStart,const sal_Int32 nSelEnd)251cdf0e10cSrcweir SwXParagraph::CreateXParagraph(SwDoc & rDoc, SwTxtNode& rTxtNode,
252cdf0e10cSrcweir uno::Reference< text::XText> const& i_xParent,
253cdf0e10cSrcweir const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir // re-use existing SwXParagraph
256cdf0e10cSrcweir // #i105557#: do not iterate over the registered clients: race condition
257cdf0e10cSrcweir uno::Reference<text::XTextContent> xParagraph;
258cdf0e10cSrcweir if ((-1 == nSelStart) && (-1 == nSelEnd)) // only use cache if no selection!
259cdf0e10cSrcweir {
260cdf0e10cSrcweir xParagraph.set(rTxtNode.GetXParagraph());
261cdf0e10cSrcweir }
262cdf0e10cSrcweir if (xParagraph.is())
263cdf0e10cSrcweir {
264cdf0e10cSrcweir return xParagraph;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir
267cdf0e10cSrcweir // create new SwXParagraph
268cdf0e10cSrcweir uno::Reference<text::XText> xParentText(i_xParent);
269cdf0e10cSrcweir if (!xParentText.is())
270cdf0e10cSrcweir {
271cdf0e10cSrcweir SwPosition Pos( rTxtNode );
272cdf0e10cSrcweir xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
273cdf0e10cSrcweir }
274cdf0e10cSrcweir SwXParagraph *const pXPara(
275cdf0e10cSrcweir new SwXParagraph(xParentText, rTxtNode, nSelStart, nSelEnd) );
276cdf0e10cSrcweir // this is why the constructor is private: need to acquire pXPara here
277cdf0e10cSrcweir xParagraph.set(pXPara);
278cdf0e10cSrcweir // in order to initialize the weak pointer cache in the core object
279cdf0e10cSrcweir if ((-1 == nSelStart) && (-1 == nSelEnd))
280cdf0e10cSrcweir {
281cdf0e10cSrcweir rTxtNode.SetXParagraph(xParagraph);
282cdf0e10cSrcweir }
283cdf0e10cSrcweir return xParagraph;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir
SelectPaM(SwPaM & rPaM)286cdf0e10cSrcweir bool SwXParagraph::SelectPaM(SwPaM & rPaM)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir SwTxtNode const*const pTxtNode( GetTxtNode() );
289cdf0e10cSrcweir
290cdf0e10cSrcweir if (!pTxtNode)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir return false;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
295cdf0e10cSrcweir *rPaM.GetPoint() = SwPosition( *pTxtNode );
296cdf0e10cSrcweir // set selection to the whole paragraph
297cdf0e10cSrcweir rPaM.SetMark();
298cdf0e10cSrcweir rPaM.GetMark()->nContent = pTxtNode->GetTxt().Len();
299cdf0e10cSrcweir return true;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir
302cdf0e10cSrcweir /* -----------------------------13.03.00 12:15--------------------------------
303cdf0e10cSrcweir
304cdf0e10cSrcweir ---------------------------------------------------------------------------*/
getUnoTunnelId()305cdf0e10cSrcweir const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
306cdf0e10cSrcweir {
307cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
308cdf0e10cSrcweir return aSeq;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir /* -----------------------------10.03.00 18:04--------------------------------
311cdf0e10cSrcweir
312cdf0e10cSrcweir ---------------------------------------------------------------------------*/
313cdf0e10cSrcweir sal_Int64 SAL_CALL
getSomething(const uno::Sequence<sal_Int8> & rId)314cdf0e10cSrcweir SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
315cdf0e10cSrcweir throw (uno::RuntimeException)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir return ::sw::UnoTunnelImpl<SwXParagraph>(rId, this);
318cdf0e10cSrcweir }
319cdf0e10cSrcweir
320cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
321cdf0e10cSrcweir
322cdf0e10cSrcweir ---------------------------------------------------------------------------*/
323cdf0e10cSrcweir OUString SAL_CALL
getImplementationName()324cdf0e10cSrcweir SwXParagraph::getImplementationName() throw (uno::RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir return C2U("SwXParagraph");
327cdf0e10cSrcweir }
328cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
329cdf0e10cSrcweir
330cdf0e10cSrcweir ---------------------------------------------------------------------------*/
331cdf0e10cSrcweir static char const*const g_ServicesParagraph[] =
332cdf0e10cSrcweir {
333cdf0e10cSrcweir "com.sun.star.text.TextContent",
334cdf0e10cSrcweir "com.sun.star.text.Paragraph",
335cdf0e10cSrcweir "com.sun.star.style.CharacterProperties",
336cdf0e10cSrcweir "com.sun.star.style.CharacterPropertiesAsian",
337cdf0e10cSrcweir "com.sun.star.style.CharacterPropertiesComplex",
338cdf0e10cSrcweir "com.sun.star.style.ParagraphProperties",
339cdf0e10cSrcweir "com.sun.star.style.ParagraphPropertiesAsian",
340cdf0e10cSrcweir "com.sun.star.style.ParagraphPropertiesComplex",
341cdf0e10cSrcweir };
342cdf0e10cSrcweir static const size_t g_nServicesParagraph(
343cdf0e10cSrcweir sizeof(g_ServicesParagraph)/sizeof(g_ServicesParagraph[0]));
344cdf0e10cSrcweir
345cdf0e10cSrcweir sal_Bool SAL_CALL
supportsService(const OUString & rServiceName)346cdf0e10cSrcweir SwXParagraph::supportsService(const OUString& rServiceName)
347cdf0e10cSrcweir throw (uno::RuntimeException)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir return ::sw::SupportsServiceImpl(
350cdf0e10cSrcweir g_nServicesParagraph, g_ServicesParagraph, rServiceName);
351cdf0e10cSrcweir }
352cdf0e10cSrcweir /* -----------------------------06.04.00 16:37--------------------------------
353cdf0e10cSrcweir
354cdf0e10cSrcweir ---------------------------------------------------------------------------*/
355cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames()356cdf0e10cSrcweir SwXParagraph::getSupportedServiceNames() throw (uno::RuntimeException)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir return ::sw::GetSupportedServiceNamesImpl(
359cdf0e10cSrcweir g_nServicesParagraph, g_ServicesParagraph);
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir /* -----------------------------11.07.00 14:48--------------------------------
363cdf0e10cSrcweir
364cdf0e10cSrcweir ---------------------------------------------------------------------------*/
365cdf0e10cSrcweir void
attachToText(SwXText & rParent,SwTxtNode & rTxtNode)366cdf0e10cSrcweir SwXParagraph::attachToText(SwXText & rParent, SwTxtNode & rTxtNode)
367cdf0e10cSrcweir {
368cdf0e10cSrcweir DBG_ASSERT(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
369cdf0e10cSrcweir if (m_pImpl->m_bIsDescriptor)
370cdf0e10cSrcweir {
371cdf0e10cSrcweir m_pImpl->m_bIsDescriptor = false;
372cdf0e10cSrcweir rTxtNode.Add(m_pImpl.get());
373cdf0e10cSrcweir rTxtNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
374cdf0e10cSrcweir m_pImpl->m_xParentText = &rParent;
375cdf0e10cSrcweir if (m_pImpl->m_sText.getLength())
376cdf0e10cSrcweir {
377cdf0e10cSrcweir try { setString(m_pImpl->m_sText); }
378cdf0e10cSrcweir catch(...){}
379cdf0e10cSrcweir m_pImpl->m_sText = OUString();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir }
382cdf0e10cSrcweir }
383cdf0e10cSrcweir
384cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
385cdf0e10cSrcweir
386cdf0e10cSrcweir -----------------------------------------------------------------------*/
387cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()388cdf0e10cSrcweir SwXParagraph::getPropertySetInfo()
389cdf0e10cSrcweir throw (uno::RuntimeException)
390cdf0e10cSrcweir {
391cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
392cdf0e10cSrcweir
393cdf0e10cSrcweir static uno::Reference< beans::XPropertySetInfo > xRef =
394cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertySetInfo();
395cdf0e10cSrcweir return xRef;
396cdf0e10cSrcweir }
397cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
398cdf0e10cSrcweir
399cdf0e10cSrcweir -----------------------------------------------------------------------*/
400cdf0e10cSrcweir void SAL_CALL
setPropertyValue(const OUString & rPropertyName,const uno::Any & rValue)401cdf0e10cSrcweir SwXParagraph::setPropertyValue(const OUString& rPropertyName,
402cdf0e10cSrcweir const uno::Any& rValue)
403cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
404cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException,
405cdf0e10cSrcweir uno::RuntimeException )
406cdf0e10cSrcweir {
407cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
408cdf0e10cSrcweir uno::Sequence<OUString> aPropertyNames(1);
409cdf0e10cSrcweir aPropertyNames.getArray()[0] = rPropertyName;
410cdf0e10cSrcweir uno::Sequence<uno::Any> aValues(1);
411cdf0e10cSrcweir aValues.getArray()[0] = rValue;
412cdf0e10cSrcweir m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir /*-- 11.12.98 08:12:49---------------------------------------------------
416cdf0e10cSrcweir
417cdf0e10cSrcweir -----------------------------------------------------------------------*/
418cdf0e10cSrcweir uno::Any
getPropertyValue(const OUString & rPropertyName)419cdf0e10cSrcweir SwXParagraph::getPropertyValue(const OUString& rPropertyName)
420cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
421cdf0e10cSrcweir uno::RuntimeException )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
424cdf0e10cSrcweir uno::Sequence<OUString> aPropertyNames(1);
425cdf0e10cSrcweir aPropertyNames.getArray()[0] = rPropertyName;
426cdf0e10cSrcweir const uno::Sequence< uno::Any > aRet =
427cdf0e10cSrcweir m_pImpl->GetPropertyValues_Impl(aPropertyNames);
428cdf0e10cSrcweir return aRet.getConstArray()[0];
429cdf0e10cSrcweir }
430cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
431cdf0e10cSrcweir
432cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)433cdf0e10cSrcweir void SwXParagraph::Impl::SetPropertyValues_Impl(
434cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
435cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
436cdf0e10cSrcweir throw (beans::UnknownPropertyException, beans::PropertyVetoException,
437cdf0e10cSrcweir lang::IllegalArgumentException, lang::WrappedTargetException,
438cdf0e10cSrcweir uno::RuntimeException)
439cdf0e10cSrcweir {
440cdf0e10cSrcweir SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
441cdf0e10cSrcweir
442cdf0e10cSrcweir SwPosition aPos( rTxtNode );
443cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
444cdf0e10cSrcweir const OUString* pPropertyNames = rPropertyNames.getConstArray();
445cdf0e10cSrcweir const uno::Any* pValues = rValues.getConstArray();
446cdf0e10cSrcweir SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap();
447cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
448cdf0e10cSrcweir for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
451cdf0e10cSrcweir pMap->getByName( pPropertyNames[nProp] );
452cdf0e10cSrcweir if (!pEntry)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir throw beans::UnknownPropertyException(
455cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
456cdf0e10cSrcweir + pPropertyNames[nProp],
457cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(&m_rThis));
458cdf0e10cSrcweir }
459cdf0e10cSrcweir if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
460cdf0e10cSrcweir {
461cdf0e10cSrcweir throw beans::PropertyVetoException(
462cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
463cdf0e10cSrcweir + pPropertyNames[nProp],
464cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(&m_rThis));
465cdf0e10cSrcweir }
466cdf0e10cSrcweir SwUnoCursorHelper::SetPropertyValue(aCursor, m_rPropSet,
467cdf0e10cSrcweir pPropertyNames[nProp], pValues[nProp]);
468cdf0e10cSrcweir }
469cdf0e10cSrcweir }
470cdf0e10cSrcweir
setPropertyValues(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)471cdf0e10cSrcweir void SAL_CALL SwXParagraph::setPropertyValues(
472cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
473cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
474cdf0e10cSrcweir throw (beans::PropertyVetoException, lang::IllegalArgumentException,
475cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
478cdf0e10cSrcweir
479cdf0e10cSrcweir // workaround for bad designed API
480cdf0e10cSrcweir try
481cdf0e10cSrcweir {
482cdf0e10cSrcweir m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir catch (beans::UnknownPropertyException &rException)
485cdf0e10cSrcweir {
486cdf0e10cSrcweir // wrap the original (here not allowed) exception in
487cdf0e10cSrcweir // a lang::WrappedTargetException that gets thrown instead.
488cdf0e10cSrcweir lang::WrappedTargetException aWExc;
489cdf0e10cSrcweir aWExc.TargetException <<= rException;
490cdf0e10cSrcweir throw aWExc;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir }
493cdf0e10cSrcweir
494cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
495cdf0e10cSrcweir
496cdf0e10cSrcweir ---------------------------------------------------------------------------*/
49756b35d86SArmin Le Grand
49856b35d86SArmin Le Grand //UUUU Support for DrawingLayer FillStyles for GetPropertyValue() usages
GetSinglePropertyValue_Impl(const SfxItemPropertySimpleEntry & rEntry,const SfxItemSet & rSet,uno::Any & rAny) const49956b35d86SArmin Le Grand void SwXParagraph::Impl::GetSinglePropertyValue_Impl(
50056b35d86SArmin Le Grand const SfxItemPropertySimpleEntry& rEntry,
50156b35d86SArmin Le Grand const SfxItemSet& rSet,
50256b35d86SArmin Le Grand uno::Any& rAny ) const
50356b35d86SArmin Le Grand throw(uno::RuntimeException)
50456b35d86SArmin Le Grand {
50556b35d86SArmin Le Grand bool bDone(false);
50656b35d86SArmin Le Grand
50756b35d86SArmin Le Grand switch(rEntry.nWID)
50856b35d86SArmin Le Grand {
50956b35d86SArmin Le Grand case RES_BACKGROUND:
51056b35d86SArmin Le Grand {
51156b35d86SArmin Le Grand const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
51256b35d86SArmin Le Grand const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
51356b35d86SArmin Le Grand
51456b35d86SArmin Le Grand if(!aOriginalBrushItem.QueryValue(rAny, nMemberId))
51556b35d86SArmin Le Grand {
51656b35d86SArmin Le Grand OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
51756b35d86SArmin Le Grand }
51856b35d86SArmin Le Grand
51956b35d86SArmin Le Grand bDone = true;
52056b35d86SArmin Le Grand break;
52156b35d86SArmin Le Grand }
52256b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
52356b35d86SArmin Le Grand {
52456b35d86SArmin Le Grand const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
52556b35d86SArmin Le Grand const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
52656b35d86SArmin Le Grand
52756b35d86SArmin Le Grand if( pTileItem && pTileItem->GetValue() )
52856b35d86SArmin Le Grand {
52956b35d86SArmin Le Grand rAny <<= drawing::BitmapMode_REPEAT;
53056b35d86SArmin Le Grand }
53156b35d86SArmin Le Grand else if( pStretchItem && pStretchItem->GetValue() )
53256b35d86SArmin Le Grand {
53356b35d86SArmin Le Grand rAny <<= drawing::BitmapMode_STRETCH;
53456b35d86SArmin Le Grand }
53556b35d86SArmin Le Grand else
53656b35d86SArmin Le Grand {
53756b35d86SArmin Le Grand rAny <<= drawing::BitmapMode_NO_REPEAT;
53856b35d86SArmin Le Grand }
53956b35d86SArmin Le Grand
54056b35d86SArmin Le Grand bDone = true;
54156b35d86SArmin Le Grand break;
54256b35d86SArmin Le Grand }
54356b35d86SArmin Le Grand default: break;
54456b35d86SArmin Le Grand }
54556b35d86SArmin Le Grand
54656b35d86SArmin Le Grand if(!bDone)
54756b35d86SArmin Le Grand {
54856b35d86SArmin Le Grand // fallback to standard get value implementation used before this helper was created
54956b35d86SArmin Le Grand m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
55056b35d86SArmin Le Grand
55156b35d86SArmin Le Grand if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != rAny.getValueType())
55256b35d86SArmin Le Grand {
55356b35d86SArmin Le Grand // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
55456b35d86SArmin Le Grand sal_Int32 nValue(0);
55556b35d86SArmin Le Grand
55656b35d86SArmin Le Grand rAny >>= nValue;
55756b35d86SArmin Le Grand rAny <<= static_cast< sal_Int16 >(nValue);
55856b35d86SArmin Le Grand }
55956b35d86SArmin Le Grand
56056b35d86SArmin Le Grand //UUUU check for needed metric translation
56156b35d86SArmin Le Grand if(rEntry.nMemberId & SFX_METRIC_ITEM)
56256b35d86SArmin Le Grand {
56356b35d86SArmin Le Grand bool bDoIt(true);
56456b35d86SArmin Le Grand
56556b35d86SArmin Le Grand if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
56656b35d86SArmin Le Grand {
56756b35d86SArmin Le Grand // exception: If these ItemTypes are used, do not convert when these are negative
56856b35d86SArmin Le Grand // since this means they are intended as percent values
56956b35d86SArmin Le Grand sal_Int32 nValue = 0;
57056b35d86SArmin Le Grand
57156b35d86SArmin Le Grand if(rAny >>= nValue)
57256b35d86SArmin Le Grand {
57356b35d86SArmin Le Grand bDoIt = nValue > 0;
57456b35d86SArmin Le Grand }
57556b35d86SArmin Le Grand }
57656b35d86SArmin Le Grand
57756b35d86SArmin Le Grand if(bDoIt)
57856b35d86SArmin Le Grand {
57956b35d86SArmin Le Grand const SfxMapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
58056b35d86SArmin Le Grand
58156b35d86SArmin Le Grand if(eMapUnit != SFX_MAPUNIT_100TH_MM)
58256b35d86SArmin Le Grand {
58356b35d86SArmin Le Grand SvxUnoConvertToMM(eMapUnit, rAny);
58456b35d86SArmin Le Grand }
58556b35d86SArmin Le Grand }
58656b35d86SArmin Le Grand }
58756b35d86SArmin Le Grand }
58856b35d86SArmin Le Grand }
58956b35d86SArmin Le Grand
GetPropertyValues_Impl(const uno::Sequence<OUString> & rPropertyNames)590cdf0e10cSrcweir uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl(
591cdf0e10cSrcweir const uno::Sequence< OUString > & rPropertyNames )
592cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
593cdf0e10cSrcweir uno::RuntimeException)
594cdf0e10cSrcweir {
595cdf0e10cSrcweir SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
596cdf0e10cSrcweir
597cdf0e10cSrcweir uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
598cdf0e10cSrcweir SwPosition aPos( rTxtNode );
599cdf0e10cSrcweir SwPaM aPam( aPos );
600cdf0e10cSrcweir uno::Any* pValues = aValues.getArray();
601cdf0e10cSrcweir const OUString* pPropertyNames = rPropertyNames.getConstArray();
602cdf0e10cSrcweir SfxItemPropertyMap const*const pMap = m_rPropSet.getPropertyMap();
603cdf0e10cSrcweir const SwAttrSet& rAttrSet( rTxtNode.GetSwAttrSet() );
604cdf0e10cSrcweir for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
607cdf0e10cSrcweir pMap->getByName( pPropertyNames[nProp] );
608cdf0e10cSrcweir if (!pEntry)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir throw beans::UnknownPropertyException(
611cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
612cdf0e10cSrcweir + pPropertyNames[nProp],
613cdf0e10cSrcweir static_cast< cppu::OWeakObject * >(&m_rThis));
614cdf0e10cSrcweir }
615cdf0e10cSrcweir if (! ::sw::GetDefaultTextContentValue(
616cdf0e10cSrcweir pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
617cdf0e10cSrcweir {
618cdf0e10cSrcweir beans::PropertyState eTemp;
619cdf0e10cSrcweir const bool bDone = SwUnoCursorHelper::getCrsrPropertyValue(
620cdf0e10cSrcweir *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode );
621cdf0e10cSrcweir if (!bDone)
622cdf0e10cSrcweir {
62356b35d86SArmin Le Grand //UUUU
62456b35d86SArmin Le Grand GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
625cdf0e10cSrcweir }
626cdf0e10cSrcweir }
627cdf0e10cSrcweir }
628cdf0e10cSrcweir return aValues;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir
631cdf0e10cSrcweir /* -----------------------------04.11.03 11:43--------------------------------
632cdf0e10cSrcweir
633cdf0e10cSrcweir ---------------------------------------------------------------------------*/
634cdf0e10cSrcweir uno::Sequence< uno::Any > SAL_CALL
getPropertyValues(const uno::Sequence<OUString> & rPropertyNames)635cdf0e10cSrcweir SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
636cdf0e10cSrcweir throw (uno::RuntimeException)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
639cdf0e10cSrcweir uno::Sequence< uno::Any > aValues;
640cdf0e10cSrcweir
641cdf0e10cSrcweir // workaround for bad designed API
642cdf0e10cSrcweir try
643cdf0e10cSrcweir {
644cdf0e10cSrcweir aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
645cdf0e10cSrcweir }
646cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
647cdf0e10cSrcweir {
648cdf0e10cSrcweir throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
649cdf0e10cSrcweir "Unknown property exception caught")),
650cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
651cdf0e10cSrcweir }
652cdf0e10cSrcweir catch (lang::WrappedTargetException &)
653cdf0e10cSrcweir {
654cdf0e10cSrcweir throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
655cdf0e10cSrcweir "WrappedTargetException caught")),
656cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
657cdf0e10cSrcweir }
658cdf0e10cSrcweir
659cdf0e10cSrcweir return aValues;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir
662cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
663cdf0e10cSrcweir
664cdf0e10cSrcweir ---------------------------------------------------------------------------*/
addPropertiesChangeListener(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)665cdf0e10cSrcweir void SAL_CALL SwXParagraph::addPropertiesChangeListener(
666cdf0e10cSrcweir const uno::Sequence< OUString >& /*aPropertyNames*/,
667cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
668cdf0e10cSrcweir throw (uno::RuntimeException)
669cdf0e10cSrcweir {
670cdf0e10cSrcweir OSL_ENSURE(false,
671cdf0e10cSrcweir "SwXParagraph::addPropertiesChangeListener(): not implemented");
672cdf0e10cSrcweir }
673cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
674cdf0e10cSrcweir
675cdf0e10cSrcweir ---------------------------------------------------------------------------*/
removePropertiesChangeListener(const uno::Reference<beans::XPropertiesChangeListener> &)676cdf0e10cSrcweir void SAL_CALL SwXParagraph::removePropertiesChangeListener(
677cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
678cdf0e10cSrcweir throw (uno::RuntimeException)
679cdf0e10cSrcweir {
680cdf0e10cSrcweir OSL_ENSURE(false,
681cdf0e10cSrcweir "SwXParagraph::removePropertiesChangeListener(): not implemented");
682cdf0e10cSrcweir }
683cdf0e10cSrcweir /* -----------------------------02.04.01 11:43--------------------------------
684cdf0e10cSrcweir
685cdf0e10cSrcweir ---------------------------------------------------------------------------*/
firePropertiesChangeEvent(const uno::Sequence<OUString> &,const uno::Reference<beans::XPropertiesChangeListener> &)686cdf0e10cSrcweir void SAL_CALL SwXParagraph::firePropertiesChangeEvent(
687cdf0e10cSrcweir const uno::Sequence< OUString >& /*aPropertyNames*/,
688cdf0e10cSrcweir const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
689cdf0e10cSrcweir throw(uno::RuntimeException)
690cdf0e10cSrcweir {
691cdf0e10cSrcweir OSL_ENSURE(false,
692cdf0e10cSrcweir "SwXParagraph::firePropertiesChangeEvent(): not implemented");
693cdf0e10cSrcweir }
694cdf0e10cSrcweir /* -----------------------------25.09.03 11:09--------------------------------
695cdf0e10cSrcweir
696cdf0e10cSrcweir ---------------------------------------------------------------------------*/
697cdf0e10cSrcweir
698cdf0e10cSrcweir /* disabled for #i46921# */
699cdf0e10cSrcweir
700cdf0e10cSrcweir uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
setPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames,const uno::Sequence<uno::Any> & rValues)701cdf0e10cSrcweir SwXParagraph::setPropertyValuesTolerant(
702cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
703cdf0e10cSrcweir const uno::Sequence< uno::Any >& rValues )
704cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
705cdf0e10cSrcweir {
706cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() );
707cdf0e10cSrcweir
708cdf0e10cSrcweir if (rPropertyNames.getLength() != rValues.getLength())
709cdf0e10cSrcweir {
710cdf0e10cSrcweir throw lang::IllegalArgumentException();
711cdf0e10cSrcweir }
712cdf0e10cSrcweir
713cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
714cdf0e10cSrcweir
715cdf0e10cSrcweir //SwNode& rTxtNode = pUnoCrsr->GetPoint()->nNode.GetNode();
716cdf0e10cSrcweir //const SwAttrSet& rAttrSet = ((SwTxtNode&)rTxtNode).GetSwAttrSet();
717cdf0e10cSrcweir //sal_uInt16 nAttrCount = rAttrSet.Count();
718cdf0e10cSrcweir
719cdf0e10cSrcweir const sal_Int32 nProps = rPropertyNames.getLength();
720cdf0e10cSrcweir const OUString *pProp = rPropertyNames.getConstArray();
721cdf0e10cSrcweir
722cdf0e10cSrcweir //sal_Int32 nVals = rValues.getLength();
723cdf0e10cSrcweir const uno::Any *pValue = rValues.getConstArray();
724cdf0e10cSrcweir
725cdf0e10cSrcweir sal_Int32 nFailed = 0;
726cdf0e10cSrcweir uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
727cdf0e10cSrcweir beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
728cdf0e10cSrcweir
729cdf0e10cSrcweir // get entry to start with
730cdf0e10cSrcweir SfxItemPropertyMap const*const pPropMap =
731cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertyMap();
732cdf0e10cSrcweir
733cdf0e10cSrcweir OUString sTmp;
734cdf0e10cSrcweir SwPosition aPos( rTxtNode );
735cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
736cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
737cdf0e10cSrcweir for (sal_Int32 i = 0; i < nProps; ++i)
738cdf0e10cSrcweir {
739cdf0e10cSrcweir try
740cdf0e10cSrcweir {
741cdf0e10cSrcweir pFailed[ nFailed ].Name = pProp[i];
742cdf0e10cSrcweir
743cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
744cdf0e10cSrcweir pPropMap->getByName( pProp[i] );
745cdf0e10cSrcweir if (!pEntry)
746cdf0e10cSrcweir {
747cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
748cdf0e10cSrcweir beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
749cdf0e10cSrcweir }
750cdf0e10cSrcweir else
751cdf0e10cSrcweir {
752cdf0e10cSrcweir // set property value
753cdf0e10cSrcweir // (compare to SwXParagraph::setPropertyValues)
754cdf0e10cSrcweir if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
755cdf0e10cSrcweir {
756cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
757cdf0e10cSrcweir beans::TolerantPropertySetResultType::PROPERTY_VETO;
758cdf0e10cSrcweir }
759cdf0e10cSrcweir else
760cdf0e10cSrcweir {
761cdf0e10cSrcweir SwUnoCursorHelper::SetPropertyValue(
762cdf0e10cSrcweir aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
763cdf0e10cSrcweir }
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir // should not occur because property was searched for before
769*2eda3cbfSmseidel DBG_ERROR( "unexpected exception caught" );
770cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
771cdf0e10cSrcweir beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
772cdf0e10cSrcweir }
773cdf0e10cSrcweir catch (lang::IllegalArgumentException &)
774cdf0e10cSrcweir {
775cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
776cdf0e10cSrcweir beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir catch (beans::PropertyVetoException &)
779cdf0e10cSrcweir {
780cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
781cdf0e10cSrcweir beans::TolerantPropertySetResultType::PROPERTY_VETO;
782cdf0e10cSrcweir }
783cdf0e10cSrcweir catch (lang::WrappedTargetException &)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir pFailed[ nFailed++ ].Result =
786cdf0e10cSrcweir beans::TolerantPropertySetResultType::WRAPPED_TARGET;
787cdf0e10cSrcweir }
788cdf0e10cSrcweir }
789cdf0e10cSrcweir
790cdf0e10cSrcweir aFailed.realloc( nFailed );
791cdf0e10cSrcweir return aFailed;
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
794cdf0e10cSrcweir
795cdf0e10cSrcweir uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
getPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames)796cdf0e10cSrcweir SwXParagraph::getPropertyValuesTolerant(
797cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames )
798cdf0e10cSrcweir throw (uno::RuntimeException)
799cdf0e10cSrcweir {
800cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() );
801cdf0e10cSrcweir
802cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
803cdf0e10cSrcweir m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
804cdf0e10cSrcweir const beans::GetDirectPropertyTolerantResult *pTmpRes =
805cdf0e10cSrcweir aTmpRes.getConstArray();
806cdf0e10cSrcweir
807cdf0e10cSrcweir // copy temporary result to final result type
808cdf0e10cSrcweir const sal_Int32 nLen = aTmpRes.getLength();
809cdf0e10cSrcweir uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
810cdf0e10cSrcweir beans::GetPropertyTolerantResult *pRes = aRes.getArray();
811cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLen; i++)
812cdf0e10cSrcweir {
813cdf0e10cSrcweir *pRes++ = *pTmpRes++;
814cdf0e10cSrcweir }
815cdf0e10cSrcweir return aRes;
816cdf0e10cSrcweir }
817cdf0e10cSrcweir
818cdf0e10cSrcweir
819cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
getDirectPropertyValuesTolerant(const uno::Sequence<OUString> & rPropertyNames)820cdf0e10cSrcweir SwXParagraph::getDirectPropertyValuesTolerant(
821cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames )
822cdf0e10cSrcweir throw (uno::RuntimeException)
823cdf0e10cSrcweir {
824cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() );
825cdf0e10cSrcweir
826cdf0e10cSrcweir return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
827cdf0e10cSrcweir }
828cdf0e10cSrcweir
829cdf0e10cSrcweir
830cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult >
GetPropertyValuesTolerant_Impl(const uno::Sequence<OUString> & rPropertyNames,bool bDirectValuesOnly)831cdf0e10cSrcweir SwXParagraph::Impl::GetPropertyValuesTolerant_Impl(
832cdf0e10cSrcweir const uno::Sequence< OUString >& rPropertyNames,
833cdf0e10cSrcweir bool bDirectValuesOnly )
834cdf0e10cSrcweir throw (uno::RuntimeException)
835cdf0e10cSrcweir {
836cdf0e10cSrcweir vos::OGuard aGuard( Application::GetSolarMutex() );
837cdf0e10cSrcweir
838cdf0e10cSrcweir SwTxtNode & rTxtNode(GetTxtNodeOrThrow());
839cdf0e10cSrcweir
840cdf0e10cSrcweir // #i46786# Use SwAttrSet pointer for determining the state.
841cdf0e10cSrcweir // Use the value SwAttrSet (from the paragraph OR the style)
842cdf0e10cSrcweir // for determining the actual value(s).
843cdf0e10cSrcweir const SwAttrSet* pAttrSet = rTxtNode.GetpSwAttrSet();
844cdf0e10cSrcweir const SwAttrSet& rValueAttrSet = rTxtNode.GetSwAttrSet();
845cdf0e10cSrcweir
846cdf0e10cSrcweir sal_Int32 nProps = rPropertyNames.getLength();
847cdf0e10cSrcweir const OUString *pProp = rPropertyNames.getConstArray();
848cdf0e10cSrcweir
849cdf0e10cSrcweir uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
850cdf0e10cSrcweir beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
851cdf0e10cSrcweir sal_Int32 nIdx = 0;
852cdf0e10cSrcweir
853cdf0e10cSrcweir // get entry to start with
854cdf0e10cSrcweir SfxItemPropertyMap const*const pPropMap = m_rPropSet.getPropertyMap();
855cdf0e10cSrcweir
856cdf0e10cSrcweir for (sal_Int32 i = 0; i < nProps; ++i)
857cdf0e10cSrcweir {
858cdf0e10cSrcweir DBG_ASSERT( nIdx < nProps, "index out ouf bounds" );
859cdf0e10cSrcweir beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
860cdf0e10cSrcweir
861cdf0e10cSrcweir try
862cdf0e10cSrcweir {
863cdf0e10cSrcweir rResult.Name = pProp[i];
864cdf0e10cSrcweir
865cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
866cdf0e10cSrcweir pPropMap->getByName( pProp[i] );
867cdf0e10cSrcweir if (!pEntry) // property available?
868cdf0e10cSrcweir {
869cdf0e10cSrcweir rResult.Result =
870cdf0e10cSrcweir beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir else
873cdf0e10cSrcweir {
874cdf0e10cSrcweir // get property state
875cdf0e10cSrcweir // (compare to SwXParagraph::getPropertyState)
876cdf0e10cSrcweir sal_Bool bAttrSetFetched = sal_True;
877cdf0e10cSrcweir beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
878cdf0e10cSrcweir rTxtNode, &pAttrSet, *pEntry, bAttrSetFetched );
879cdf0e10cSrcweir rResult.State = eState;
880cdf0e10cSrcweir
881cdf0e10cSrcweir // if (bDirectValuesOnly && PropertyState_DIRECT_VALUE != eState)
882cdf0e10cSrcweir // rResult.Result = beans::TolerantPropertySetResultType::NO_DIRECT_VALUE;
883cdf0e10cSrcweir // else
884cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
885cdf0e10cSrcweir if (!bDirectValuesOnly ||
886cdf0e10cSrcweir (beans::PropertyState_DIRECT_VALUE == eState))
887cdf0e10cSrcweir {
888cdf0e10cSrcweir // get property value
889cdf0e10cSrcweir // (compare to SwXParagraph::getPropertyValue(s))
890cdf0e10cSrcweir uno::Any aValue;
891cdf0e10cSrcweir if (! ::sw::GetDefaultTextContentValue(
892cdf0e10cSrcweir aValue, pProp[i], pEntry->nWID ) )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir SwPosition aPos( rTxtNode );
895cdf0e10cSrcweir SwPaM aPam( aPos );
896cdf0e10cSrcweir // handle properties that are not part of the attribute
897*2eda3cbfSmseidel // and thus only pretend to be paragraph attributes
898cdf0e10cSrcweir beans::PropertyState eTemp;
899cdf0e10cSrcweir const bool bDone =
900cdf0e10cSrcweir SwUnoCursorHelper::getCrsrPropertyValue(
901cdf0e10cSrcweir *pEntry, aPam, &aValue, eTemp, &rTxtNode );
902cdf0e10cSrcweir
903cdf0e10cSrcweir // if not found try the real paragraph attributes...
904cdf0e10cSrcweir if (!bDone)
905cdf0e10cSrcweir {
90656b35d86SArmin Le Grand //UUUU
90756b35d86SArmin Le Grand GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
908cdf0e10cSrcweir }
909cdf0e10cSrcweir }
910cdf0e10cSrcweir
911cdf0e10cSrcweir rResult.Value = aValue;
912cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
913cdf0e10cSrcweir
914cdf0e10cSrcweir nIdx++;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir // this assertion should never occur!
917cdf0e10cSrcweir DBG_ASSERT( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
918cdf0e10cSrcweir "unknown failure while retrieving property" );
919cdf0e10cSrcweir
920cdf0e10cSrcweir }
921cdf0e10cSrcweir }
922cdf0e10cSrcweir catch (beans::UnknownPropertyException &)
923cdf0e10cSrcweir {
924cdf0e10cSrcweir // should not occur because property was searched for before
925cdf0e10cSrcweir DBG_ERROR( "unexpected exception caught" );
926cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
927cdf0e10cSrcweir }
928cdf0e10cSrcweir catch (lang::IllegalArgumentException &)
929cdf0e10cSrcweir {
930cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir catch (beans::PropertyVetoException &)
933cdf0e10cSrcweir {
934cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
935cdf0e10cSrcweir }
936cdf0e10cSrcweir catch (lang::WrappedTargetException &)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
939cdf0e10cSrcweir }
940cdf0e10cSrcweir }
941cdf0e10cSrcweir
942cdf0e10cSrcweir // resize to actually used size
943cdf0e10cSrcweir aResult.realloc( nIdx );
944cdf0e10cSrcweir
945cdf0e10cSrcweir return aResult;
946cdf0e10cSrcweir }
947cdf0e10cSrcweir
948cdf0e10cSrcweir /* -----------------------------12.09.00 11:09--------------------------------
949cdf0e10cSrcweir
950cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetDefaultTextContentValue(uno::Any & rAny,const OUString & rPropertyName,sal_uInt16 nWID)951cdf0e10cSrcweir bool ::sw::GetDefaultTextContentValue(
952cdf0e10cSrcweir uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID)
953cdf0e10cSrcweir {
954cdf0e10cSrcweir if(!nWID)
955cdf0e10cSrcweir {
956cdf0e10cSrcweir if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)))
957cdf0e10cSrcweir nWID = FN_UNO_ANCHOR_TYPE;
958cdf0e10cSrcweir else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)))
959cdf0e10cSrcweir nWID = FN_UNO_ANCHOR_TYPES;
960cdf0e10cSrcweir else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_TEXT_WRAP)))
961cdf0e10cSrcweir nWID = FN_UNO_TEXT_WRAP;
962cdf0e10cSrcweir else
963cdf0e10cSrcweir return sal_False;
964cdf0e10cSrcweir }
965cdf0e10cSrcweir
966cdf0e10cSrcweir switch(nWID)
967cdf0e10cSrcweir {
968cdf0e10cSrcweir case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break;
969cdf0e10cSrcweir case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
970cdf0e10cSrcweir case FN_UNO_ANCHOR_TYPES:
971cdf0e10cSrcweir { uno::Sequence<text::TextContentAnchorType> aTypes(1);
972cdf0e10cSrcweir text::TextContentAnchorType* pArray = aTypes.getArray();
973cdf0e10cSrcweir pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
974cdf0e10cSrcweir rAny.setValue(&aTypes, ::getCppuType((uno::Sequence<text::TextContentAnchorType>*)0));
975cdf0e10cSrcweir }
976cdf0e10cSrcweir break;
977cdf0e10cSrcweir default:
978cdf0e10cSrcweir return sal_False;
979cdf0e10cSrcweir }
980cdf0e10cSrcweir return sal_True;
981cdf0e10cSrcweir }
982cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
983cdf0e10cSrcweir
984cdf0e10cSrcweir -----------------------------------------------------------------------*/
985cdf0e10cSrcweir void SAL_CALL
addPropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)986cdf0e10cSrcweir SwXParagraph::addPropertyChangeListener(
987cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
988cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
989cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
990cdf0e10cSrcweir uno::RuntimeException)
991cdf0e10cSrcweir {
992cdf0e10cSrcweir OSL_ENSURE(false,
993cdf0e10cSrcweir "SwXParagraph::addPropertyChangeListener(): not implemented");
994cdf0e10cSrcweir }
995cdf0e10cSrcweir
996cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
997cdf0e10cSrcweir
998cdf0e10cSrcweir -----------------------------------------------------------------------*/
999cdf0e10cSrcweir void SAL_CALL
removePropertyChangeListener(const::rtl::OUString &,const uno::Reference<beans::XPropertyChangeListener> &)1000cdf0e10cSrcweir SwXParagraph::removePropertyChangeListener(
1001cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1002cdf0e10cSrcweir const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1003cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1004cdf0e10cSrcweir uno::RuntimeException)
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir OSL_ENSURE(false,
1007cdf0e10cSrcweir "SwXParagraph::removePropertyChangeListener(): not implemented");
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir /*-- 11.12.98 08:12:50---------------------------------------------------
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir -----------------------------------------------------------------------*/
1013cdf0e10cSrcweir void SAL_CALL
addVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1014cdf0e10cSrcweir SwXParagraph::addVetoableChangeListener(
1015cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1016cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1017cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1018cdf0e10cSrcweir uno::RuntimeException)
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir OSL_ENSURE(false,
1021cdf0e10cSrcweir "SwXParagraph::addVetoableChangeListener(): not implemented");
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir
1024cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir -----------------------------------------------------------------------*/
1027cdf0e10cSrcweir void SAL_CALL
removeVetoableChangeListener(const::rtl::OUString &,const uno::Reference<beans::XVetoableChangeListener> &)1028cdf0e10cSrcweir SwXParagraph::removeVetoableChangeListener(
1029cdf0e10cSrcweir const ::rtl::OUString& /*rPropertyName*/,
1030cdf0e10cSrcweir const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1031cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1032cdf0e10cSrcweir uno::RuntimeException)
1033cdf0e10cSrcweir {
1034cdf0e10cSrcweir OSL_ENSURE(false,
1035cdf0e10cSrcweir "SwXParagraph::removeVetoableChangeListener(): not implemented");
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir //-----------------------------------------------------------------------------
lcl_SwXParagraph_getPropertyState(const SwTxtNode & rTxtNode,const SwAttrSet ** ppSet,const SfxItemPropertySimpleEntry & rEntry,sal_Bool & rAttrSetFetched)1039cdf0e10cSrcweir beans::PropertyState lcl_SwXParagraph_getPropertyState(
1040cdf0e10cSrcweir // SwUnoCrsr& rUnoCrsr,
1041cdf0e10cSrcweir const SwTxtNode& rTxtNode,
1042cdf0e10cSrcweir const SwAttrSet** ppSet,
1043cdf0e10cSrcweir const SfxItemPropertySimpleEntry& rEntry,
1044cdf0e10cSrcweir sal_Bool &rAttrSetFetched)
1045cdf0e10cSrcweir throw (beans::UnknownPropertyException)
1046cdf0e10cSrcweir {
104756b35d86SArmin Le Grand beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
1048cdf0e10cSrcweir
1049cdf0e10cSrcweir if(!(*ppSet) && !rAttrSetFetched)
1050cdf0e10cSrcweir {
1051cdf0e10cSrcweir (*ppSet) = rTxtNode.GetpSwAttrSet();
1052cdf0e10cSrcweir rAttrSetFetched = sal_True;
1053cdf0e10cSrcweir }
105456b35d86SArmin Le Grand
1055cdf0e10cSrcweir SwPosition aPos(rTxtNode);
1056cdf0e10cSrcweir SwPaM aPam(aPos);
105756b35d86SArmin Le Grand bool bDone(false);
105856b35d86SArmin Le Grand
1059cdf0e10cSrcweir switch(rEntry.nWID)
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir case FN_UNO_NUM_RULES:
106256b35d86SArmin Le Grand {
1063cdf0e10cSrcweir // if numbering is set, return it; else do nothing
1064cdf0e10cSrcweir SwUnoCursorHelper::getNumberingProperty(aPam,eRet,NULL);
106556b35d86SArmin Le Grand bDone = true;
1066cdf0e10cSrcweir break;
106756b35d86SArmin Le Grand }
1068cdf0e10cSrcweir case FN_UNO_ANCHOR_TYPES:
106956b35d86SArmin Le Grand {
107056b35d86SArmin Le Grand bDone = true;
1071cdf0e10cSrcweir break;
107256b35d86SArmin Le Grand }
1073cdf0e10cSrcweir case RES_ANCHOR:
107456b35d86SArmin Le Grand {
107556b35d86SArmin Le Grand bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId);
1076cdf0e10cSrcweir break;
107756b35d86SArmin Le Grand }
1078cdf0e10cSrcweir case RES_SURROUND:
107956b35d86SArmin Le Grand {
108056b35d86SArmin Le Grand bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId);
1081cdf0e10cSrcweir break;
108256b35d86SArmin Le Grand }
1083cdf0e10cSrcweir case FN_UNO_PARA_STYLE:
1084cdf0e10cSrcweir case FN_UNO_PARA_CONDITIONAL_STYLE_NAME:
1085cdf0e10cSrcweir {
108656b35d86SArmin Le Grand SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(aPam,rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME);
108756b35d86SArmin Le Grand eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
108856b35d86SArmin Le Grand bDone = true;
1089cdf0e10cSrcweir break;
109056b35d86SArmin Le Grand }
1091cdf0e10cSrcweir case FN_UNO_PAGE_STYLE:
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir String sVal;
1094cdf0e10cSrcweir SwUnoCursorHelper::GetCurPageStyle(aPam,sVal);
109556b35d86SArmin Le Grand eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
109656b35d86SArmin Le Grand bDone = true;
1097cdf0e10cSrcweir break;
109856b35d86SArmin Le Grand }
109956b35d86SArmin Le Grand
110056b35d86SArmin Le Grand //UUUU DrawingLayer PropertyStyle support
110156b35d86SArmin Le Grand case OWN_ATTR_FILLBMP_MODE:
110256b35d86SArmin Le Grand {
110356b35d86SArmin Le Grand if(*ppSet)
110456b35d86SArmin Le Grand {
110556b35d86SArmin Le Grand if(SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
110656b35d86SArmin Le Grand || SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
110756b35d86SArmin Le Grand {
1108cdf0e10cSrcweir eRet = beans::PropertyState_DIRECT_VALUE;
110956b35d86SArmin Le Grand }
111056b35d86SArmin Le Grand else
111156b35d86SArmin Le Grand {
111256b35d86SArmin Le Grand eRet = beans::PropertyState_AMBIGUOUS_VALUE;
111356b35d86SArmin Le Grand }
111456b35d86SArmin Le Grand
111556b35d86SArmin Le Grand bDone = true;
111656b35d86SArmin Le Grand }
1117cdf0e10cSrcweir break;
1118cdf0e10cSrcweir }
111956b35d86SArmin Le Grand case RES_BACKGROUND:
112056b35d86SArmin Le Grand {
112156b35d86SArmin Le Grand if(*ppSet)
112256b35d86SArmin Le Grand {
112356b35d86SArmin Le Grand if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet))
112456b35d86SArmin Le Grand {
112556b35d86SArmin Le Grand eRet = beans::PropertyState_DIRECT_VALUE;
112656b35d86SArmin Le Grand bDone = true;
112756b35d86SArmin Le Grand }
112856b35d86SArmin Le Grand }
112956b35d86SArmin Le Grand break;
113056b35d86SArmin Le Grand }
113156b35d86SArmin Le Grand }
113256b35d86SArmin Le Grand
113356b35d86SArmin Le Grand if(!bDone)
113456b35d86SArmin Le Grand {
113556b35d86SArmin Le Grand if((*ppSet) && SFX_ITEM_SET == (*ppSet)->GetItemState(rEntry.nWID,sal_False))
113656b35d86SArmin Le Grand {
113756b35d86SArmin Le Grand eRet = beans::PropertyState_DIRECT_VALUE;
113856b35d86SArmin Le Grand }
113956b35d86SArmin Le Grand }
114056b35d86SArmin Le Grand
1141cdf0e10cSrcweir return eRet;
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir /*-- 05.03.99 11:37:30---------------------------------------------------
1145cdf0e10cSrcweir
1146cdf0e10cSrcweir -----------------------------------------------------------------------*/
1147cdf0e10cSrcweir beans::PropertyState SAL_CALL
getPropertyState(const OUString & rPropertyName)1148cdf0e10cSrcweir SwXParagraph::getPropertyState(const OUString& rPropertyName)
1149cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
1150cdf0e10cSrcweir {
1151cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1152cdf0e10cSrcweir
1153cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir const SwAttrSet* pSet = 0;
1156cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
1157cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
1158cdf0e10cSrcweir if (!pEntry)
1159cdf0e10cSrcweir {
1160cdf0e10cSrcweir throw beans::UnknownPropertyException(
1161cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1162cdf0e10cSrcweir + rPropertyName,
1163cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir sal_Bool bDummy = sal_False;
1166cdf0e10cSrcweir const beans::PropertyState eRet =
1167cdf0e10cSrcweir lcl_SwXParagraph_getPropertyState(rTxtNode, &pSet, *pEntry, bDummy);
1168cdf0e10cSrcweir return eRet;
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir /*-- 05.03.99 11:37:32---------------------------------------------------
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir -----------------------------------------------------------------------*/
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SAL_CALL
getPropertyStates(const uno::Sequence<OUString> & PropertyNames)1175cdf0e10cSrcweir SwXParagraph::getPropertyStates(
1176cdf0e10cSrcweir const uno::Sequence< OUString >& PropertyNames)
1177cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1180cdf0e10cSrcweir
1181cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1182cdf0e10cSrcweir
1183cdf0e10cSrcweir const OUString* pNames = PropertyNames.getConstArray();
1184cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
1185cdf0e10cSrcweir beans::PropertyState* pStates = aRet.getArray();
1186cdf0e10cSrcweir SfxItemPropertyMap const*const pMap = m_pImpl->m_rPropSet.getPropertyMap();
1187cdf0e10cSrcweir const SwAttrSet* pSet = 0;
1188cdf0e10cSrcweir sal_Bool bAttrSetFetched = sal_False;
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
1191cdf0e10cSrcweir ++i, ++pStates, ++pNames)
1192cdf0e10cSrcweir {
1193cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
1194cdf0e10cSrcweir pMap->getByName( *pNames );
1195cdf0e10cSrcweir if (!pEntry)
1196cdf0e10cSrcweir {
1197cdf0e10cSrcweir throw beans::UnknownPropertyException(
1198cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1199cdf0e10cSrcweir + *pNames,
1200cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir
1203cdf0e10cSrcweir if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir *pStates = beans::PropertyState_DEFAULT_VALUE;
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir else
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir *pStates = lcl_SwXParagraph_getPropertyState(
1210cdf0e10cSrcweir rTxtNode, &pSet, *pEntry, bAttrSetFetched );
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir }
1213cdf0e10cSrcweir
1214cdf0e10cSrcweir return aRet;
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir
1217cdf0e10cSrcweir /*-- 05.03.99 11:37:33---------------------------------------------------
1218cdf0e10cSrcweir
1219cdf0e10cSrcweir -----------------------------------------------------------------------*/
1220cdf0e10cSrcweir void SAL_CALL
setPropertyToDefault(const OUString & rPropertyName)1221cdf0e10cSrcweir SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
1222cdf0e10cSrcweir throw (beans::UnknownPropertyException, uno::RuntimeException)
1223cdf0e10cSrcweir {
1224cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1225cdf0e10cSrcweir
1226cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1227cdf0e10cSrcweir
1228cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1229cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1230cdf0e10cSrcweir if (rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE)) ||
1231cdf0e10cSrcweir rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_ANCHOR_TYPES)) ||
1232cdf0e10cSrcweir rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_TEXT_WRAP)))
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir return;
1235cdf0e10cSrcweir }
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir // select paragraph
1238cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1239cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
1240cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertyMap()->getByName( rPropertyName );
1241cdf0e10cSrcweir if (!pEntry)
1242cdf0e10cSrcweir {
1243cdf0e10cSrcweir throw beans::UnknownPropertyException(
1244cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1245cdf0e10cSrcweir + rPropertyName,
1246cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1250cdf0e10cSrcweir {
1251cdf0e10cSrcweir throw uno::RuntimeException(
1252cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
1253cdf0e10cSrcweir + rPropertyName,
1254cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir
125756b35d86SArmin Le Grand const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END);
125856b35d86SArmin Le Grand const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
125956b35d86SArmin Le Grand
126056b35d86SArmin Le Grand if(bBelowFrmAtrEnd || bDrawingLayerRange)
1261cdf0e10cSrcweir {
1262cdf0e10cSrcweir SvUShortsSort aWhichIds;
126356b35d86SArmin Le Grand
126456b35d86SArmin Le Grand //UUUU For FillBitmapMode two IDs have to be reset (!)
126556b35d86SArmin Le Grand if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
126656b35d86SArmin Le Grand {
126756b35d86SArmin Le Grand aWhichIds.Insert(XATTR_FILLBMP_STRETCH);
126856b35d86SArmin Le Grand aWhichIds.Insert(XATTR_FILLBMP_TILE);
126956b35d86SArmin Le Grand }
127056b35d86SArmin Le Grand else
127156b35d86SArmin Le Grand {
1272cdf0e10cSrcweir aWhichIds.Insert(pEntry->nWID);
127356b35d86SArmin Le Grand }
127456b35d86SArmin Le Grand
1275cdf0e10cSrcweir if (pEntry->nWID < RES_PARATR_BEGIN)
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds);
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir else
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir // for paragraph attributes the selection must be extended
1282cdf0e10cSrcweir // to paragraph boundaries
1283cdf0e10cSrcweir SwPosition aStart( *aCursor.Start() );
1284cdf0e10cSrcweir SwPosition aEnd ( *aCursor.End() );
128556b35d86SArmin Le Grand ::std::auto_ptr<SwUnoCrsr> pTemp( aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) );
128656b35d86SArmin Le Grand
1287cdf0e10cSrcweir if(!SwUnoCursorHelper::IsStartOfPara(*pTemp))
1288cdf0e10cSrcweir {
1289cdf0e10cSrcweir pTemp->MovePara(fnParaCurr, fnParaStart);
1290cdf0e10cSrcweir }
129156b35d86SArmin Le Grand
1292cdf0e10cSrcweir pTemp->SetMark();
1293cdf0e10cSrcweir *pTemp->GetPoint() = aEnd;
1294cdf0e10cSrcweir //pTemp->Exchange();
129556b35d86SArmin Le Grand
1296cdf0e10cSrcweir SwUnoCursorHelper::SelectPam(*pTemp, true);
129756b35d86SArmin Le Grand
1298cdf0e10cSrcweir if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir pTemp->MovePara(fnParaCurr, fnParaEnd);
1301cdf0e10cSrcweir }
130256b35d86SArmin Le Grand
1303cdf0e10cSrcweir pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds);
1304cdf0e10cSrcweir }
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir else
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir SwUnoCursorHelper::resetCrsrPropertyValue(*pEntry, aCursor);
1309cdf0e10cSrcweir }
1310cdf0e10cSrcweir }
1311cdf0e10cSrcweir
1312cdf0e10cSrcweir /*-- 05.03.99 11:37:33---------------------------------------------------
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir -----------------------------------------------------------------------*/
1315cdf0e10cSrcweir uno::Any SAL_CALL
getPropertyDefault(const OUString & rPropertyName)1316cdf0e10cSrcweir SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
1317cdf0e10cSrcweir throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1318cdf0e10cSrcweir uno::RuntimeException)
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1321cdf0e10cSrcweir
1322cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir uno::Any aRet;
1325cdf0e10cSrcweir if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
1326cdf0e10cSrcweir {
1327cdf0e10cSrcweir return aRet;
1328cdf0e10cSrcweir }
1329cdf0e10cSrcweir
1330cdf0e10cSrcweir SfxItemPropertySimpleEntry const*const pEntry =
1331cdf0e10cSrcweir m_pImpl->m_rPropSet.getPropertyMap()->getByName(rPropertyName);
1332cdf0e10cSrcweir if (!pEntry)
1333cdf0e10cSrcweir {
1334cdf0e10cSrcweir throw beans::UnknownPropertyException(
1335cdf0e10cSrcweir OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1336cdf0e10cSrcweir + rPropertyName,
1337cdf0e10cSrcweir static_cast<cppu::OWeakObject *>(this));
1338cdf0e10cSrcweir }
1339cdf0e10cSrcweir
134056b35d86SArmin Le Grand const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END);
134156b35d86SArmin Le Grand const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
134256b35d86SArmin Le Grand
134356b35d86SArmin Le Grand if(bBelowFrmAtrEnd || bDrawingLayerRange)
1344cdf0e10cSrcweir {
134556b35d86SArmin Le Grand const SfxPoolItem& rDefItem = rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
134656b35d86SArmin Le Grand
1347cdf0e10cSrcweir rDefItem.QueryValue(aRet, pEntry->nMemberId);
1348cdf0e10cSrcweir }
1349cdf0e10cSrcweir
1350cdf0e10cSrcweir return aRet;
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir
1353cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
1354cdf0e10cSrcweir
1355cdf0e10cSrcweir -----------------------------------------------------------------------*/
1356cdf0e10cSrcweir void SAL_CALL
attach(const uno::Reference<text::XTextRange> &)1357cdf0e10cSrcweir SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
1358cdf0e10cSrcweir throw (lang::IllegalArgumentException, uno::RuntimeException)
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1361cdf0e10cSrcweir // SwXParagraph will only created in order to be inserted by
1362cdf0e10cSrcweir // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
1363cdf0e10cSrcweir // they cannot be attached
1364cdf0e10cSrcweir throw uno::RuntimeException();
1365cdf0e10cSrcweir }
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir /*-- 11.12.98 08:12:51---------------------------------------------------
1368cdf0e10cSrcweir
1369cdf0e10cSrcweir -----------------------------------------------------------------------*/
1370cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getAnchor()1371cdf0e10cSrcweir SwXParagraph::getAnchor() throw (uno::RuntimeException)
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1374cdf0e10cSrcweir
1375cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1376cdf0e10cSrcweir
1377cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1378cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1379cdf0e10cSrcweir // select paragraph
1380cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1381cdf0e10cSrcweir const uno::Reference< text::XTextRange > xRet =
1382cdf0e10cSrcweir new SwXTextRange(aCursor, m_pImpl->m_xParentText);
1383cdf0e10cSrcweir return xRet;
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir /*-- 11.12.98 08:12:52---------------------------------------------------
1387cdf0e10cSrcweir
1388cdf0e10cSrcweir -----------------------------------------------------------------------*/
dispose()1389cdf0e10cSrcweir void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException)
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1392cdf0e10cSrcweir
1393cdf0e10cSrcweir SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1394cdf0e10cSrcweir if (pTxtNode)
1395cdf0e10cSrcweir {
1396cdf0e10cSrcweir SwCursor aCursor( SwPosition( *pTxtNode ), 0, false );
1397cdf0e10cSrcweir // select paragraph
1398cdf0e10cSrcweir {
1399cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1400cdf0e10cSrcweir pTxtNode->GetDoc()->DelFullPara(aCursor);
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir m_pImpl->m_ListenerContainer.Disposing();
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir }
1405cdf0e10cSrcweir
1406cdf0e10cSrcweir /*-- 11.12.98 08:12:52---------------------------------------------------
1407cdf0e10cSrcweir
1408cdf0e10cSrcweir -----------------------------------------------------------------------*/
addEventListener(const uno::Reference<lang::XEventListener> & xListener)1409cdf0e10cSrcweir void SAL_CALL SwXParagraph::addEventListener(
1410cdf0e10cSrcweir const uno::Reference< lang::XEventListener > & xListener)
1411cdf0e10cSrcweir throw (uno::RuntimeException)
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1414cdf0e10cSrcweir
1415cdf0e10cSrcweir if (!m_pImpl->GetTxtNode())
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir throw uno::RuntimeException();
1418cdf0e10cSrcweir }
1419cdf0e10cSrcweir m_pImpl->m_ListenerContainer.AddListener(xListener);
1420cdf0e10cSrcweir }
1421cdf0e10cSrcweir /*-- 11.12.98 08:12:53---------------------------------------------------
1422cdf0e10cSrcweir
1423cdf0e10cSrcweir -----------------------------------------------------------------------*/
removeEventListener(const uno::Reference<lang::XEventListener> & xListener)1424cdf0e10cSrcweir void SAL_CALL SwXParagraph::removeEventListener(
1425cdf0e10cSrcweir const uno::Reference< lang::XEventListener > & xListener)
1426cdf0e10cSrcweir throw (uno::RuntimeException)
1427cdf0e10cSrcweir {
1428cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1429cdf0e10cSrcweir
1430cdf0e10cSrcweir if (!m_pImpl->GetTxtNode() ||
1431cdf0e10cSrcweir !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
1432cdf0e10cSrcweir {
1433cdf0e10cSrcweir throw uno::RuntimeException();
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir
1437cdf0e10cSrcweir /*-- 11.12.98 08:12:53---------------------------------------------------
1438cdf0e10cSrcweir
1439cdf0e10cSrcweir -----------------------------------------------------------------------*/
1440cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createEnumeration()1441cdf0e10cSrcweir SwXParagraph::createEnumeration() throw (uno::RuntimeException)
1442cdf0e10cSrcweir {
1443cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1446cdf0e10cSrcweir
1447cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1448cdf0e10cSrcweir SwPaM aPam ( aPos );
1449cdf0e10cSrcweir const uno::Reference< container::XEnumeration > xRef =
1450cdf0e10cSrcweir new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
1451cdf0e10cSrcweir m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
1452cdf0e10cSrcweir return xRef;
1453cdf0e10cSrcweir }
1454cdf0e10cSrcweir
1455cdf0e10cSrcweir /*-- 11.12.98 08:12:54---------------------------------------------------
1456cdf0e10cSrcweir
1457cdf0e10cSrcweir -----------------------------------------------------------------------*/
getElementType()1458cdf0e10cSrcweir uno::Type SAL_CALL SwXParagraph::getElementType() throw (uno::RuntimeException)
1459cdf0e10cSrcweir {
1460cdf0e10cSrcweir return text::XTextRange::static_type();
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir /*-- 11.12.98 08:12:54---------------------------------------------------
1463cdf0e10cSrcweir
1464cdf0e10cSrcweir -----------------------------------------------------------------------*/
hasElements()1465cdf0e10cSrcweir sal_Bool SAL_CALL SwXParagraph::hasElements() throw (uno::RuntimeException)
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1468cdf0e10cSrcweir return (GetTxtNode()) ? sal_True : sal_False;
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir
1471cdf0e10cSrcweir /*-- 11.12.98 08:12:55---------------------------------------------------
1472cdf0e10cSrcweir
1473cdf0e10cSrcweir -----------------------------------------------------------------------*/
1474cdf0e10cSrcweir uno::Reference< text::XText > SAL_CALL
getText()1475cdf0e10cSrcweir SwXParagraph::getText() throw (uno::RuntimeException)
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1478cdf0e10cSrcweir
1479cdf0e10cSrcweir return m_pImpl->m_xParentText;
1480cdf0e10cSrcweir }
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir /*-- 11.12.98 08:12:55---------------------------------------------------
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir -----------------------------------------------------------------------*/
1485cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getStart()1486cdf0e10cSrcweir SwXParagraph::getStart() throw (uno::RuntimeException)
1487cdf0e10cSrcweir {
1488cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1489cdf0e10cSrcweir
1490cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1493cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1494cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1495cdf0e10cSrcweir SwPaM aPam( *aCursor.Start() );
1496cdf0e10cSrcweir uno::Reference< text::XText > xParent = getText();
1497cdf0e10cSrcweir const uno::Reference< text::XTextRange > xRet =
1498cdf0e10cSrcweir new SwXTextRange(aPam, xParent);
1499cdf0e10cSrcweir return xRet;
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir /*-- 11.12.98 08:12:56---------------------------------------------------
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir -----------------------------------------------------------------------*/
1504cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL
getEnd()1505cdf0e10cSrcweir SwXParagraph::getEnd() throw (uno::RuntimeException)
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1510cdf0e10cSrcweir
1511cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1512cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1513cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1514cdf0e10cSrcweir SwPaM aPam( *aCursor.End() );
1515cdf0e10cSrcweir uno::Reference< text::XText > xParent = getText();
1516cdf0e10cSrcweir const uno::Reference< text::XTextRange > xRet =
1517cdf0e10cSrcweir new SwXTextRange(aPam, xParent);
1518cdf0e10cSrcweir return xRet;
1519cdf0e10cSrcweir }
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir /*-- 11.12.98 08:12:56---------------------------------------------------
1522cdf0e10cSrcweir
1523cdf0e10cSrcweir -----------------------------------------------------------------------*/
getString()1524cdf0e10cSrcweir OUString SAL_CALL SwXParagraph::getString() throw (uno::RuntimeException)
1525cdf0e10cSrcweir {
1526cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1527cdf0e10cSrcweir OUString aRet;
1528cdf0e10cSrcweir SwTxtNode const*const pTxtNode( GetTxtNode() );
1529cdf0e10cSrcweir if (pTxtNode)
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir SwPosition aPos( *pTxtNode );
1532cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1533cdf0e10cSrcweir SwParaSelection aParaSel( aCursor );
1534cdf0e10cSrcweir SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir else if (m_pImpl->IsDescriptor())
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir aRet = m_pImpl->m_sText;
1539cdf0e10cSrcweir }
1540cdf0e10cSrcweir else
1541cdf0e10cSrcweir {
1542cdf0e10cSrcweir throw uno::RuntimeException();
1543cdf0e10cSrcweir }
1544cdf0e10cSrcweir return aRet;
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir /*-- 11.12.98 08:12:57---------------------------------------------------
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir -----------------------------------------------------------------------*/
setString(const OUString & aString)1549cdf0e10cSrcweir void SAL_CALL SwXParagraph::setString(const OUString& aString)
1550cdf0e10cSrcweir throw (uno::RuntimeException)
1551cdf0e10cSrcweir {
1552cdf0e10cSrcweir vos::OGuard aGuard(Application::GetSolarMutex());
1553cdf0e10cSrcweir
1554cdf0e10cSrcweir SwTxtNode const*const pTxtNode( GetTxtNode() );
1555cdf0e10cSrcweir if (pTxtNode)
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir SwPosition aPos( *pTxtNode );
1558cdf0e10cSrcweir SwCursor aCursor( aPos, 0, false );
1559cdf0e10cSrcweir if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
1560cdf0e10cSrcweir aCursor.MovePara(fnParaCurr, fnParaStart);
1561cdf0e10cSrcweir }
1562cdf0e10cSrcweir SwUnoCursorHelper::SelectPam(aCursor, true);
1563cdf0e10cSrcweir if (pTxtNode->GetTxt().Len()) {
1564cdf0e10cSrcweir aCursor.MovePara(fnParaCurr, fnParaEnd);
1565cdf0e10cSrcweir }
1566cdf0e10cSrcweir SwUnoCursorHelper::SetString(aCursor, aString);
1567cdf0e10cSrcweir SwUnoCursorHelper::SelectPam(aCursor, false);
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir else if (m_pImpl->IsDescriptor())
1570cdf0e10cSrcweir {
1571cdf0e10cSrcweir m_pImpl->m_sText = aString;
1572cdf0e10cSrcweir }
1573cdf0e10cSrcweir else
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir throw uno::RuntimeException();
1576cdf0e10cSrcweir }
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir
1579cdf0e10cSrcweir /* -----------------23.03.99 12:49-------------------
1580cdf0e10cSrcweir *
1581cdf0e10cSrcweir * --------------------------------------------------*/
1582cdf0e10cSrcweir uno::Reference< container::XEnumeration > SAL_CALL
createContentEnumeration(const OUString & rServiceName)1583cdf0e10cSrcweir SwXParagraph::createContentEnumeration(const OUString& rServiceName)
1584cdf0e10cSrcweir throw (uno::RuntimeException)
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir vos::OGuard g(Application::GetSolarMutex());
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir if (!rServiceName.equalsAscii("com.sun.star.text.TextContent"))
1589cdf0e10cSrcweir {
1590cdf0e10cSrcweir throw uno::RuntimeException();
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir
1593cdf0e10cSrcweir SwTxtNode & rTxtNode(m_pImpl->GetTxtNodeOrThrow());
1594cdf0e10cSrcweir
1595cdf0e10cSrcweir SwPosition aPos( rTxtNode );
1596cdf0e10cSrcweir SwPaM aPam( aPos );
1597cdf0e10cSrcweir uno::Reference< container::XEnumeration > xRet =
1598cdf0e10cSrcweir new SwXParaFrameEnumeration(aPam, PARAFRAME_PORTION_PARAGRAPH);
1599cdf0e10cSrcweir return xRet;
1600cdf0e10cSrcweir }
1601cdf0e10cSrcweir /* -----------------23.03.99 12:49-------------------
1602cdf0e10cSrcweir *
1603cdf0e10cSrcweir * --------------------------------------------------*/
1604cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL
getAvailableServiceNames()1605cdf0e10cSrcweir SwXParagraph::getAvailableServiceNames() throw (uno::RuntimeException)
1606cdf0e10cSrcweir {
1607cdf0e10cSrcweir uno::Sequence< OUString > aRet(1);
1608cdf0e10cSrcweir OUString* pArray = aRet.getArray();
1609cdf0e10cSrcweir pArray[0] = C2U("com.sun.star.text.TextContent");
1610cdf0e10cSrcweir return aRet;
1611cdf0e10cSrcweir }
1612cdf0e10cSrcweir
1613cdf0e10cSrcweir
1614cdf0e10cSrcweir // MetadatableMixin
GetCoreObject()1615cdf0e10cSrcweir ::sfx2::Metadatable* SwXParagraph::GetCoreObject()
1616cdf0e10cSrcweir {
1617cdf0e10cSrcweir SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1618cdf0e10cSrcweir return pTxtNode;
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir
GetModel()1621cdf0e10cSrcweir uno::Reference<frame::XModel> SwXParagraph::GetModel()
1622cdf0e10cSrcweir {
1623cdf0e10cSrcweir SwTxtNode *const pTxtNode( m_pImpl->GetTxtNode() );
1624cdf0e10cSrcweir if (pTxtNode)
1625cdf0e10cSrcweir {
1626cdf0e10cSrcweir SwDocShell const*const pShell( pTxtNode->GetDoc()->GetDocShell() );
1627cdf0e10cSrcweir return (pShell) ? pShell->GetModel() : 0;
1628cdf0e10cSrcweir }
1629cdf0e10cSrcweir return 0;
1630cdf0e10cSrcweir }
1631