Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
31 : : #include <com/sun/star/text/SectionFileLink.hpp>
32 : :
33 : : #include <cmdid.h>
34 : : #include <hintids.hxx>
35 : : #include <svl/urihelper.hxx>
36 : : #include <editeng/brshitem.hxx>
37 : : #include <editeng/xmlcnitm.hxx>
38 : : #include <sfx2/linkmgr.hxx>
39 : : #include <sfx2/lnkbase.hxx>
40 : : #include <osl/mutex.hxx>
41 : : #include <vcl/svapp.hxx>
42 : : #include <fmtclds.hxx>
43 : : #include <unotextrange.hxx>
44 : : #include <unosection.hxx>
45 : : #include <TextCursorHelper.hxx>
46 : : #include <unoredline.hxx>
47 : : #include <redline.hxx>
48 : : #include <unomap.hxx>
49 : : #include <unocrsr.hxx>
50 : : #include <section.hxx>
51 : : #include <doc.hxx>
52 : : #include <IDocumentUndoRedo.hxx>
53 : : #include <docsh.hxx>
54 : : #include <sfx2/docfile.hxx>
55 : : #include <docary.hxx>
56 : : #include <swundo.hxx>
57 : : #include <hints.hxx>
58 : : #include <tox.hxx>
59 : : #include <unoidx.hxx>
60 : : #include <doctxm.hxx>
61 : : #include <fmtftntx.hxx>
62 : : #include <fmtclbl.hxx>
63 : : #include <editeng/frmdiritem.hxx>
64 : : #include <fmtcntnt.hxx>
65 : : #include <editeng/lrspitem.hxx>
66 : : #include <comphelper/servicehelper.hxx>
67 : : #include <comphelper/string.hxx>
68 : :
69 : :
70 : : using namespace ::com::sun::star;
71 : : using ::rtl::OUString;
72 : :
73 [ + - ][ + - ]: 92 : struct SwTextSectionProperties_Impl
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
74 : : {
75 : : uno::Sequence<sal_Int8> m_Password;
76 : : ::rtl::OUString m_sCondition;
77 : : ::rtl::OUString m_sLinkFileName;
78 : : ::rtl::OUString m_sSectionFilter;
79 : : ::rtl::OUString m_sSectionRegion;
80 : :
81 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
82 : : ::std::auto_ptr<SwFmtCol> m_pColItem;
83 : : ::std::auto_ptr<SvxBrushItem> m_pBrushItem;
84 : : ::std::auto_ptr<SwFmtFtnAtTxtEnd> m_pFtnItem;
85 : : ::std::auto_ptr<SwFmtEndAtTxtEnd> m_pEndItem;
86 : : ::std::auto_ptr<SvXMLAttrContainerItem> m_pXMLAttr;
87 : : ::std::auto_ptr<SwFmtNoBalancedColumns> m_pNoBalanceItem;
88 : : ::std::auto_ptr<SvxFrameDirectionItem> m_pFrameDirItem;
89 : : ::std::auto_ptr<SvxLRSpaceItem> m_pLRSpaceItem;
90 : : SAL_WNODEPRECATED_DECLARATIONS_POP
91 : :
92 : : bool m_bDDE;
93 : : bool m_bHidden;
94 : : bool m_bCondHidden;
95 : : bool m_bProtect;
96 : : bool m_bEditInReadonly;
97 : : bool m_bUpdateType;
98 : :
99 : 92 : SwTextSectionProperties_Impl()
100 : : : m_bDDE(false)
101 : : , m_bHidden(false)
102 : : , m_bCondHidden(false)
103 : : , m_bProtect(false)
104 : : , m_bEditInReadonly(false)
105 : 92 : , m_bUpdateType(true)
106 : : {
107 : 92 : }
108 : :
109 : : };
110 : :
111 [ + - ][ + - ]: 356 : class SwXTextSection::Impl
[ - + ]
112 : : : public SwClient
113 : : {
114 : :
115 : : public:
116 : :
117 : : SwXTextSection & m_rThis;
118 : : const SfxItemPropertySet & m_rPropSet;
119 : : SwEventListenerContainer m_ListenerContainer;
120 : : const bool m_bIndexHeader;
121 : : bool m_bIsDescriptor;
122 : : ::rtl::OUString m_sName;
123 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
124 : : ::std::auto_ptr<SwTextSectionProperties_Impl> m_pProps;
125 : : SAL_WNODEPRECATED_DECLARATIONS_POP
126 : :
127 : 178 : Impl( SwXTextSection & rThis,
128 : : SwSectionFmt *const pFmt, const bool bIndexHeader)
129 : : : SwClient(pFmt)
130 : : , m_rThis(rThis)
131 [ + - ]: 178 : , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_SECTION))
132 : : , m_ListenerContainer(static_cast< ::cppu::OWeakObject* >(&rThis))
133 : : , m_bIndexHeader(bIndexHeader)
134 : : // #i111177# unxsols4 (Sun C++ 5.9 SunOS_sparc) may generate wrong code
135 : : , m_bIsDescriptor((0 == pFmt) ? true : false)
136 [ + - ][ + + ]: 356 : , m_pProps((pFmt) ? 0 : new SwTextSectionProperties_Impl())
[ + - ][ + - ]
137 : : {
138 : 178 : }
139 : :
140 : 1161 : SwSectionFmt * GetSectionFmt() const
141 : : {
142 : : return static_cast<SwSectionFmt*>(const_cast<SwModify*>(
143 : 1161 : GetRegisteredIn()));
144 : : }
145 : :
146 : 68 : SwSectionFmt & GetSectionFmtOrThrow() const {
147 : 68 : SwSectionFmt *const pFmt( GetSectionFmt() );
148 [ - + ]: 68 : if (!pFmt) {
149 : : throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
150 [ # # ][ # # ]: 0 : "SwXTextSection: disposed or invalid")), 0);
[ # # ]
151 : : }
152 : 68 : return *pFmt;
153 : : }
154 : :
155 : : void SAL_CALL SetPropertyValues_Impl(
156 : : const uno::Sequence< ::rtl::OUString >& rPropertyNames,
157 : : const uno::Sequence< uno::Any >& aValues)
158 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
159 : : lang::IllegalArgumentException, lang::WrappedTargetException,
160 : : uno::RuntimeException);
161 : : uno::Sequence< uno::Any > SAL_CALL
162 : : GetPropertyValues_Impl(
163 : : const uno::Sequence< ::rtl::OUString >& rPropertyNames)
164 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
165 : : uno::RuntimeException);
166 : : protected:
167 : : // SwClient
168 : : virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew);
169 : :
170 : : };
171 : :
172 : 338 : void SwXTextSection::Impl::Modify( const SfxPoolItem *pOld, const SfxPoolItem *pNew)
173 : : {
174 : 338 : ClientModify(this, pOld, pNew);
175 [ + + ]: 338 : if (!GetRegisteredIn())
176 : : {
177 : 120 : m_ListenerContainer.Disposing();
178 : : }
179 : 338 : }
180 : :
181 : 24 : SwSectionFmt * SwXTextSection::GetFmt() const
182 : : {
183 : 24 : return m_pImpl->GetSectionFmt();
184 : : }
185 : :
186 : : uno::Reference< text::XTextSection >
187 : 378 : SwXTextSection::CreateXTextSection(
188 : : SwSectionFmt *const pFmt, const bool bIndexHeader)
189 : : {
190 : : // re-use existing SwXTextSection
191 : : // #i105557#: do not iterate over the registered clients: race condition
192 : 378 : uno::Reference< text::XTextSection > xSection;
193 [ + + ]: 378 : if (pFmt)
194 : : {
195 [ + - ][ + - ]: 286 : xSection.set(pFmt->GetXTextSection());
196 : : }
197 [ + + ]: 378 : if ( !xSection.is() )
198 : : {
199 [ + - ]: 178 : SwXTextSection *const pNew = new SwXTextSection(pFmt, bIndexHeader);
200 [ + - ][ + - ]: 178 : xSection.set(pNew);
201 [ + + ]: 178 : if (pFmt)
202 : : {
203 [ + - ]: 86 : pFmt->SetXTextSection(xSection);
204 : : }
205 : : }
206 : 378 : return xSection;
207 : : }
208 : :
209 : 178 : SwXTextSection::SwXTextSection(
210 : : SwSectionFmt *const pFmt, const bool bIndexHeader)
211 [ + - ][ + - ]: 178 : : m_pImpl( new SwXTextSection::Impl(*this, pFmt, bIndexHeader) )
212 : : {
213 : 178 : }
214 : :
215 [ + - ]: 178 : SwXTextSection::~SwXTextSection()
216 : : {
217 [ - + ]: 356 : }
218 : :
219 : : namespace
220 : : {
221 : : class theSwXTextSectionUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextSectionUnoTunnelId > {};
222 : : }
223 : :
224 : 5480 : const uno::Sequence< sal_Int8 > & SwXTextSection::getUnoTunnelId()
225 : : {
226 : 5480 : return theSwXTextSectionUnoTunnelId::get().getSeq();
227 : : }
228 : :
229 : : sal_Int64 SAL_CALL
230 : 442 : SwXTextSection::getSomething(const uno::Sequence< sal_Int8 >& rId)
231 : : throw (uno::RuntimeException)
232 : : {
233 : 442 : return ::sw::UnoTunnelImpl<SwXTextSection>(rId, this);
234 : : }
235 : :
236 : : uno::Reference< text::XTextSection > SAL_CALL
237 : 66 : SwXTextSection::getParentSection() throw (uno::RuntimeException)
238 : : {
239 [ + - ]: 66 : SolarMutexGuard aGuard;
240 : :
241 [ + - ]: 66 : SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() );
242 : :
243 [ + - ]: 66 : SwSectionFmt *const pParentFmt = rSectionFmt.GetParent();
244 : : const uno::Reference< text::XTextSection > xRet =
245 [ + + ][ + - ]: 66 : (pParentFmt) ? CreateXTextSection(pParentFmt) : 0;
[ + - ]
246 [ + - ]: 66 : return xRet;
247 : : }
248 : :
249 : : uno::Sequence< uno::Reference< text::XTextSection > > SAL_CALL
250 : 2 : SwXTextSection::getChildSections() throw (uno::RuntimeException)
251 : : {
252 [ + - ]: 2 : SolarMutexGuard aGuard;
253 : :
254 [ + - ]: 2 : SwSectionFmt & rSectionFmt( m_pImpl->GetSectionFmtOrThrow() );
255 : :
256 [ + - ]: 2 : SwSections aChildren;
257 [ + - ]: 2 : rSectionFmt.GetChildSections(aChildren, SORTSECT_NOT, sal_False);
258 [ + - ]: 2 : uno::Sequence<uno::Reference<text::XTextSection> > aSeq(aChildren.size());
259 [ + - ]: 2 : uno::Reference< text::XTextSection > * pArray = aSeq.getArray();
260 [ + + ]: 4 : for (sal_uInt16 i = 0; i < aChildren.size(); i++)
261 : : {
262 [ + - ]: 2 : SwSectionFmt *const pChild = aChildren[i]->GetFmt();
263 [ + - ][ + - ]: 2 : pArray[i] = CreateXTextSection(pChild);
264 : : }
265 [ + - ]: 2 : return aSeq;
266 : : }
267 : :
268 : : void SAL_CALL
269 : 76 : SwXTextSection::attach(const uno::Reference< text::XTextRange > & xTextRange)
270 : : throw (lang::IllegalArgumentException, uno::RuntimeException)
271 : : {
272 [ + - ]: 76 : SolarMutexGuard g;
273 : :
274 [ - + ]: 76 : if (!m_pImpl->m_bIsDescriptor)
275 : : {
276 [ # # ]: 0 : throw uno::RuntimeException();
277 : : }
278 : :
279 [ + - ]: 76 : uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
280 : 76 : SwXTextRange* pRange = 0;
281 : 76 : OTextCursorHelper* pCursor = 0;
282 [ + - ]: 76 : if(xRangeTunnel.is())
283 : : {
284 [ + - ]: 76 : pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
285 : : pCursor =
286 [ + - ]: 76 : ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
287 : : }
288 : :
289 : : SwDoc *const pDoc =
290 [ + + ][ + - ]: 76 : (pRange) ? pRange->GetDoc() : ((pCursor) ? pCursor->GetDoc() : 0);
[ + - ][ + - ]
291 [ - + ]: 76 : if (!pDoc)
292 : : {
293 [ # # ]: 0 : throw lang::IllegalArgumentException();
294 : : }
295 : :
296 [ + - ]: 76 : SwUnoInternalPaM aPam(*pDoc);
297 : : //das muss jetzt sal_True liefern
298 [ + - ]: 76 : ::sw::XTextRangeToSwPaM(aPam, xTextRange);
299 [ + - ]: 76 : UnoActionContext aCont(pDoc);
300 [ + - ][ + - ]: 76 : pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL );
301 : :
302 [ + + ]: 76 : if (m_pImpl->m_sName.isEmpty())
303 : : {
304 [ + - ]: 37 : m_pImpl->m_sName = C2U("TextSection");
305 : : }
306 : 76 : SectionType eType = (m_pImpl->m_pProps->m_bDDE)
307 : : ? DDE_LINK_SECTION
308 : 76 : : ((!m_pImpl->m_pProps->m_sLinkFileName.isEmpty() ||
309 : 76 : !m_pImpl->m_pProps->m_sSectionRegion.isEmpty())
310 [ + - - + ]: 228 : ? FILE_LINK_SECTION : CONTENT_SECTION);
[ - + ]
311 : : // index header section?
312 [ + + ]: 76 : if (m_pImpl->m_bIndexHeader)
313 : : {
314 : : // caller wants an index header section, but will only
315 : : // give him one if a) we are inside an index, and b) said
316 : : // index doesn't yet have a header section.
317 [ + - ][ + - ]: 28 : const SwTOXBase* pBase = aPam.GetDoc()->GetCurTOX(*aPam.Start());
318 : :
319 : : // are we inside an index?
320 [ + - ]: 28 : if (pBase)
321 : : {
322 : : // get all child sections
323 [ + - ]: 28 : SwSections aSectionsArr;
324 : : static_cast<const SwTOXBaseSection*>(pBase)->GetFmt()->
325 [ + - ]: 28 : GetChildSections(aSectionsArr);
326 : :
327 : : // and search for current header section
328 : 28 : const sal_uInt16 nCount = aSectionsArr.size();
329 : 28 : sal_Bool bHeaderPresent = sal_False;
330 [ - + ]: 28 : for(sal_uInt16 i = 0; i < nCount; i++)
331 : : {
332 : : bHeaderPresent |=
333 [ # # ]: 0 : (aSectionsArr[i]->GetType() == TOX_HEADER_SECTION);
334 : : }
335 [ + - ]: 28 : if (! bHeaderPresent)
336 : : {
337 : 28 : eType = TOX_HEADER_SECTION;
338 : 28 : }
339 : : }
340 : : }
341 : :
342 [ + - ]: 76 : String tmp(m_pImpl->m_sName);
343 [ + - ][ + - ]: 76 : SwSectionData aSect(eType, pDoc->GetUniqueSectionName(&tmp));
[ + - ]
344 [ + - ][ + - ]: 76 : aSect.SetCondition(m_pImpl->m_pProps->m_sCondition);
[ + - ]
345 [ + - ]: 76 : ::rtl::OUStringBuffer sLinkNameBuf(m_pImpl->m_pProps->m_sLinkFileName);
346 [ + - ]: 76 : sLinkNameBuf.append(sfx2::cTokenSeperator);
347 [ + - ]: 76 : sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionFilter);
348 [ + - ]: 76 : sLinkNameBuf.append(sfx2::cTokenSeperator);
349 [ + - ]: 76 : sLinkNameBuf.append(m_pImpl->m_pProps->m_sSectionRegion);
350 [ + - ][ + - ]: 76 : aSect.SetLinkFileName(sLinkNameBuf.makeStringAndClear());
[ + - ][ + - ]
351 : :
352 : 76 : aSect.SetHidden(m_pImpl->m_pProps->m_bHidden);
353 : 76 : aSect.SetProtectFlag(m_pImpl->m_pProps->m_bProtect);
354 : 76 : aSect.SetEditInReadonlyFlag(m_pImpl->m_pProps->m_bEditInReadonly);
355 : :
356 : 76 : SfxItemSet aSet(pDoc->GetAttrPool(),
357 : : RES_COL, RES_COL,
358 : : RES_BACKGROUND, RES_BACKGROUND,
359 : : RES_FTN_AT_TXTEND, RES_FRAMEDIR,
360 : : RES_LR_SPACE, RES_LR_SPACE,
361 : : RES_UNKNOWNATR_CONTAINER,RES_UNKNOWNATR_CONTAINER,
362 [ + - ]: 76 : 0);
363 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pBrushItem.get())
364 : : {
365 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pBrushItem);
366 : : }
367 [ + + ]: 76 : if (m_pImpl->m_pProps->m_pColItem.get())
368 : : {
369 [ + - ]: 39 : aSet.Put(*m_pImpl->m_pProps->m_pColItem);
370 : : }
371 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pFtnItem.get())
372 : : {
373 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pFtnItem);
374 : : }
375 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pEndItem.get())
376 : : {
377 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pEndItem);
378 : : }
379 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pXMLAttr.get())
380 : : {
381 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pXMLAttr);
382 : : }
383 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pNoBalanceItem.get())
384 : : {
385 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pNoBalanceItem);
386 : : }
387 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pFrameDirItem.get())
388 : : {
389 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pFrameDirItem);
390 : : }
391 [ - + ]: 76 : if (m_pImpl->m_pProps->m_pLRSpaceItem.get())
392 : : {
393 [ # # ]: 0 : aSet.Put(*m_pImpl->m_pProps->m_pLRSpaceItem);
394 : : }
395 : : // section password
396 [ + + ]: 76 : if (m_pImpl->m_pProps->m_Password.getLength() > 0)
397 : : {
398 [ + - ]: 4 : aSect.SetPassword(m_pImpl->m_pProps->m_Password);
399 : : }
400 : :
401 : : SwSection *const pRet =
402 [ + + ][ + - ]: 76 : pDoc->InsertSwSection( aPam, aSect, 0, aSet.Count() ? &aSet : 0 );
403 [ + - ]: 76 : pRet->GetFmt()->Add(m_pImpl.get());
404 [ + - ][ + - ]: 76 : pRet->GetFmt()->SetXObject(static_cast< ::cppu::OWeakObject*>(this));
405 : :
406 : : // XML import must hide sections depending on their old
407 : : // condition status
408 [ + + ]: 76 : if (!m_pImpl->m_pProps->m_sCondition.isEmpty())
409 : : {
410 [ + - ]: 3 : pRet->SetCondHidden(m_pImpl->m_pProps->m_bCondHidden);
411 : : }
412 : :
413 : : // set update type if DDE link (and connect, if necessary)
414 [ - + ]: 76 : if (m_pImpl->m_pProps->m_bDDE)
415 : : {
416 [ # # ]: 0 : if (! pRet->IsConnected())
417 : : {
418 [ # # ]: 0 : pRet->CreateLink(CREATE_CONNECT);
419 : : }
420 : : pRet->SetUpdateType( static_cast< sal_uInt16 >(
421 : 0 : (m_pImpl->m_pProps->m_bUpdateType) ?
422 [ # # ][ # # ]: 0 : sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
423 : : }
424 : :
425 : : // Undo-Klammerung hier beenden
426 [ + - ][ + - ]: 76 : pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL );
427 : 76 : m_pImpl->m_pProps.reset();
428 [ + - ][ + - ]: 76 : m_pImpl->m_bIsDescriptor = false;
[ + - ][ + - ]
[ + - ][ + - ]
429 : 76 : }
430 : :
431 : : uno::Reference< text::XTextRange > SAL_CALL
432 : 2 : SwXTextSection::getAnchor() throw (uno::RuntimeException)
433 : : {
434 [ + - ]: 2 : SolarMutexGuard aGuard;
435 : :
436 : 2 : uno::Reference< text::XTextRange > xRet;
437 : 2 : SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt();
438 [ + - ]: 2 : if(pSectFmt)
439 : : {
440 : : const SwNodeIndex* pIdx;
441 [ + - ][ + - ]: 6 : if( 0 != ( pSectFmt->GetSection() ) &&
[ + - ][ + - ]
[ + - ]
442 [ + - ]: 2 : 0 != ( pIdx = pSectFmt->GetCntnt().GetCntntIdx() ) &&
443 [ + - ]: 2 : pIdx->GetNode().GetNodes().IsDocNodes() )
444 : : {
445 [ + - ]: 2 : SwPaM aPaM(*pIdx);
446 [ + - ]: 2 : aPaM.Move( fnMoveForward, fnGoCntnt );
447 : :
448 : 2 : const SwEndNode* pEndNode = pIdx->GetNode().EndOfSectionNode();
449 [ + - ]: 2 : SwPaM aEnd(*pEndNode);
450 [ + - ]: 2 : aEnd.Move( fnMoveBackward, fnGoCntnt );
451 : 2 : xRet = SwXTextRange::CreateXTextRange(*pSectFmt->GetDoc(),
452 [ + - ]: 4 : *aPaM.Start(), aEnd.Start());
[ + - + - ]
[ + - ][ + - ]
[ + - ]
453 : : }
454 : : }
455 [ + - ]: 2 : return xRet;
456 : : }
457 : :
458 : 6 : void SAL_CALL SwXTextSection::dispose() throw (uno::RuntimeException)
459 : : {
460 [ + - ]: 6 : SolarMutexGuard aGuard;
461 : :
462 : 6 : SwSectionFmt *const pSectFmt = m_pImpl->GetSectionFmt();
463 [ + - ]: 6 : if (pSectFmt)
464 : : {
465 [ + - ]: 6 : pSectFmt->GetDoc()->DelSectionFmt( pSectFmt );
466 [ + - ]: 6 : }
467 : 6 : }
468 : :
469 : 4 : void SAL_CALL SwXTextSection::addEventListener(
470 : : const uno::Reference< lang::XEventListener > & xListener)
471 : : throw (uno::RuntimeException)
472 : : {
473 [ + - ]: 4 : SolarMutexGuard g;
474 : :
475 [ - + ]: 4 : if (!m_pImpl->GetSectionFmt())
476 : : {
477 [ # # ]: 0 : throw uno::RuntimeException();
478 : : }
479 [ + - ][ + - ]: 4 : m_pImpl->m_ListenerContainer.AddListener(xListener);
480 : 4 : }
481 : :
482 : 2 : void SAL_CALL SwXTextSection::removeEventListener(
483 : : const uno::Reference< lang::XEventListener > & xListener)
484 : : throw (uno::RuntimeException)
485 : : {
486 [ + - ]: 2 : SolarMutexGuard g;
487 : :
488 [ + - ][ - + ]: 4 : if (!m_pImpl->GetSectionFmt() ||
[ - + ]
489 [ + - ]: 2 : !m_pImpl->m_ListenerContainer.RemoveListener(xListener))
490 : : {
491 [ # # ]: 0 : throw uno::RuntimeException();
492 [ + - ]: 2 : }
493 : 2 : }
494 : :
495 : : uno::Reference< beans::XPropertySetInfo > SAL_CALL
496 : 258 : SwXTextSection::getPropertySetInfo() throw (uno::RuntimeException)
497 : : {
498 [ + - ]: 258 : SolarMutexGuard g;
499 : :
500 : : static const uno::Reference< beans::XPropertySetInfo > aRef =
501 [ + + ][ + - ]: 258 : m_pImpl->m_rPropSet.getPropertySetInfo();
[ + - ][ # # ]
502 [ + - ]: 258 : return aRef;
503 : : }
504 : :
505 : : static void
506 : 4 : lcl_UpdateLinkType(SwSection & rSection, bool const bLinkUpdateAlways = true)
507 : : {
508 [ + - ]: 4 : if (rSection.GetType() == DDE_LINK_SECTION)
509 : : {
510 : : // set update type; needs an established link
511 [ - + ]: 4 : if (!rSection.IsConnected())
512 : : {
513 : 0 : rSection.CreateLink(CREATE_CONNECT);
514 : : }
515 : : rSection.SetUpdateType( static_cast< sal_uInt16 >((bLinkUpdateAlways)
516 [ - + ]: 4 : ? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL) );
517 : : }
518 : 4 : }
519 : :
520 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
521 : : static void
522 : 218 : lcl_UpdateSection(SwSectionFmt *const pFmt,
523 : : ::std::auto_ptr<SwSectionData> const& pSectionData,
524 : : ::std::auto_ptr<SfxItemSet> const& pItemSet,
525 : : bool const bLinkModeChanged, bool const bLinkUpdateAlways = true)
526 : : {
527 [ + + ]: 218 : if (pFmt)
528 : : {
529 [ + - ]: 122 : SwSection & rSection = *pFmt->GetSection();
530 : 122 : SwDoc *const pDoc = pFmt->GetDoc();
531 : 122 : SwSectionFmts const& rFmts = pDoc->GetSections();
532 [ + - ]: 122 : UnoActionContext aContext(pDoc);
533 [ + - ]: 122 : for (sal_uInt16 i = 0; i < rFmts.size(); i++)
534 : : {
535 [ + - ][ + - ]: 244 : if (rFmts[i]->GetSection()->GetSectionName()
[ + - ]
536 [ + - ]: 244 : == rSection.GetSectionName())
537 : : {
538 : 122 : pDoc->UpdateSection(i, *pSectionData, pItemSet.get(),
539 [ + - ]: 244 : pDoc->IsInReading());
540 : : {
541 : : // temporarily remove actions to allow cursor update
542 [ + - ][ + - ]: 122 : UnoActionRemoveContext aRemoveContext( pDoc );
543 : : }
544 : :
545 [ + + ]: 122 : if (bLinkModeChanged)
546 : : {
547 [ + - ]: 4 : lcl_UpdateLinkType(rSection, bLinkUpdateAlways);
548 : : }
549 : : // section found and processed: break from loop
550 : 122 : break;
551 : : }
552 [ + - ]: 122 : }
553 : : }
554 : 218 : }
555 : : SAL_WNODEPRECATED_DECLARATIONS_POP
556 : :
557 : 228 : void SwXTextSection::Impl::SetPropertyValues_Impl(
558 : : const uno::Sequence< OUString >& rPropertyNames,
559 : : const uno::Sequence< uno::Any >& rValues)
560 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
561 : : lang::IllegalArgumentException, lang::WrappedTargetException,
562 : : uno::RuntimeException)
563 : : {
564 [ - + ]: 228 : if(rPropertyNames.getLength() != rValues.getLength())
565 : : {
566 [ # # ]: 0 : throw lang::IllegalArgumentException();
567 : : }
568 : 228 : SwSectionFmt *const pFmt = GetSectionFmt();
569 [ - + ][ + + ]: 228 : if (!pFmt && !m_bIsDescriptor)
570 : : {
571 [ # # ]: 0 : throw uno::RuntimeException();
572 : : }
573 : :
574 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
575 : : ::std::auto_ptr<SwSectionData> const pSectionData(
576 [ + + ][ + - ]: 228 : (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0);
[ + - ][ + - ]
577 : : SAL_WNODEPRECATED_DECLARATIONS_POP
578 : :
579 : 228 : OUString const*const pPropertyNames = rPropertyNames.getConstArray();
580 : 228 : uno::Any const*const pValues = rValues.getConstArray();
581 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
582 : 228 : ::std::auto_ptr<SfxItemSet> pItemSet;
583 : : SAL_WNODEPRECATED_DECLARATIONS_POP
584 : 228 : sal_Bool bLinkModeChanged = sal_False;
585 : 228 : sal_Bool bLinkMode = sal_False;
586 : :
587 [ + + ]: 483 : for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength();
588 : : nProperty++)
589 : : {
590 : : SfxItemPropertySimpleEntry const*const pEntry =
591 [ + - ]: 267 : m_rPropSet.getPropertyMap().getByName(pPropertyNames[nProperty]);
592 [ - + ]: 267 : if (!pEntry)
593 : : {
594 : : throw beans::UnknownPropertyException(
595 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
596 : 0 : + pPropertyNames[nProperty],
597 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(& m_rThis));
[ # # ]
598 : : }
599 [ + + ]: 267 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
600 : : {
601 : : throw beans::PropertyVetoException(
602 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Property is read-only: "))
603 : 6 : + pPropertyNames[nProperty],
604 [ + - ][ + - ]: 6 : static_cast<cppu::OWeakObject *>(& m_rThis));
[ + - ]
605 : : }
606 [ + + + + : 261 : switch (pEntry->nWID)
+ + + + +
+ + ]
607 : : {
608 : : case WID_SECT_CONDITION:
609 : : {
610 : 7 : OUString uTmp;
611 : 7 : pValues[nProperty] >>= uTmp;
612 [ + + ]: 7 : if (m_bIsDescriptor)
613 : : {
614 : 3 : m_pProps->m_sCondition = uTmp;
615 : : }
616 : : else
617 : : {
618 [ + - ][ + - ]: 4 : pSectionData->SetCondition(uTmp);
[ + - ]
619 : 7 : }
620 : : }
621 : 7 : break;
622 : : case WID_SECT_DDE_TYPE:
623 : : case WID_SECT_DDE_FILE:
624 : : case WID_SECT_DDE_ELEMENT:
625 : : {
626 : 12 : OUString uTmp;
627 : 12 : pValues[nProperty] >>= uTmp;
628 [ + - ]: 12 : String sTmp(uTmp);
629 [ - + ]: 12 : if (m_bIsDescriptor)
630 : : {
631 [ # # ]: 0 : if (!m_pProps->m_bDDE)
632 : : {
633 : 0 : ::rtl::OUStringBuffer buf;
634 [ # # ]: 0 : buf.append(sfx2::cTokenSeperator);
635 [ # # ]: 0 : buf.append(sfx2::cTokenSeperator);
636 [ # # ]: 0 : m_pProps->m_sLinkFileName = buf.makeStringAndClear();
637 : 0 : m_pProps->m_bDDE = true;
638 : : }
639 [ # # ]: 0 : String sLinkFileName(m_pProps->m_sLinkFileName);
640 : : sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,
641 [ # # ]: 0 : sfx2::cTokenSeperator, sTmp);
642 [ # # ][ # # ]: 0 : m_pProps->m_sLinkFileName = sLinkFileName;
643 : : }
644 : : else
645 : : {
646 [ + - ]: 12 : String sLinkFileName(pSectionData->GetLinkFileName());
647 [ + + ]: 12 : if (pSectionData->GetType() != DDE_LINK_SECTION)
648 : : {
649 [ + - ]: 8 : sLinkFileName = sfx2::cTokenSeperator;
650 [ + - ]: 8 : sLinkFileName += sfx2::cTokenSeperator;
651 : 8 : pSectionData->SetType(DDE_LINK_SECTION);
652 : : }
653 : : sLinkFileName.SetToken(pEntry->nWID - WID_SECT_DDE_TYPE,
654 [ + - ]: 12 : sfx2::cTokenSeperator, sTmp);
655 [ + - ][ + - ]: 12 : pSectionData->SetLinkFileName(sLinkFileName);
656 [ + - ]: 12 : }
657 : : }
658 : 12 : break;
659 : : case WID_SECT_DDE_AUTOUPDATE:
660 : : {
661 : 4 : sal_Bool bVal(sal_False);
662 [ - + ]: 4 : if (!(pValues[nProperty] >>= bVal))
663 : : {
664 [ # # ]: 0 : throw lang::IllegalArgumentException();
665 : : }
666 [ - + ]: 4 : if (m_bIsDescriptor)
667 : : {
668 : 0 : m_pProps->m_bUpdateType = bVal;
669 : : }
670 : : else
671 : : {
672 : 4 : bLinkModeChanged = sal_True;
673 : 4 : bLinkMode = bVal;
674 : : }
675 : : }
676 : 4 : break;
677 : : case WID_SECT_LINK:
678 : : {
679 : 4 : text::SectionFileLink aLink;
680 [ - + ][ + - ]: 4 : if (!(pValues[nProperty] >>= aLink))
681 : : {
682 [ # # ]: 0 : throw lang::IllegalArgumentException();
683 : : }
684 [ - + ]: 4 : if (m_bIsDescriptor)
685 : : {
686 : 0 : m_pProps->m_bDDE = sal_False;
687 : 0 : m_pProps->m_sLinkFileName = aLink.FileURL;
688 : 0 : m_pProps->m_sSectionFilter = aLink.FilterName;
689 : : }
690 : : else
691 : : {
692 [ + - + - ]: 8 : if (pSectionData->GetType() != FILE_LINK_SECTION &&
[ + - ]
693 : 4 : !aLink.FileURL.isEmpty())
694 : : {
695 : 4 : pSectionData->SetType(FILE_LINK_SECTION);
696 : : }
697 : 4 : ::rtl::OUStringBuffer sFileNameBuf;
698 [ + - ]: 4 : if (!aLink.FileURL.isEmpty())
699 : : {
700 : : sFileNameBuf.append( URIHelper::SmartRel2Abs(
701 : 4 : pFmt->GetDoc()->GetDocShell()->GetMedium()
702 [ + - ]: 4 : ->GetURLObject(),
703 [ + - ][ + - ]: 8 : aLink.FileURL, URIHelper::GetMaybeFileHdl()));
[ + - ]
704 : : }
705 [ + - ]: 4 : sFileNameBuf.append(sfx2::cTokenSeperator);
706 [ + - ]: 4 : sFileNameBuf.append(aLink.FilterName);
707 [ + - ]: 4 : sFileNameBuf.append(sfx2::cTokenSeperator);
708 : : sFileNameBuf.append(
709 : 4 : pSectionData->GetLinkFileName().GetToken(2,
710 [ + - ][ + - ]: 4 : sfx2::cTokenSeperator));
[ + - ][ + - ]
711 : : const ::rtl::OUString sFileName(
712 [ + - ]: 4 : sFileNameBuf.makeStringAndClear());
713 [ + - ][ + - ]: 4 : pSectionData->SetLinkFileName(sFileName);
[ + - ]
714 [ - + ]: 4 : if (sFileName.getLength() < 3)
715 : : {
716 : 0 : pSectionData->SetType(CONTENT_SECTION);
717 : 4 : }
718 : 4 : }
719 : : }
720 : 4 : break;
721 : : case WID_SECT_REGION:
722 : : {
723 : 4 : OUString sLink;
724 : 4 : pValues[nProperty] >>= sLink;
725 [ - + ]: 4 : if (m_bIsDescriptor)
726 : : {
727 : 0 : m_pProps->m_bDDE = sal_False;
728 : 0 : m_pProps->m_sSectionRegion = sLink;
729 : : }
730 : : else
731 : : {
732 [ + - + - ]: 8 : if (pSectionData->GetType() != FILE_LINK_SECTION &&
[ + - ]
733 : 4 : !sLink.isEmpty())
734 : : {
735 : 4 : pSectionData->SetType(FILE_LINK_SECTION);
736 : : }
737 [ + - ]: 4 : String sSectLink(pSectionData->GetLinkFileName());
738 [ + - ][ + - ]: 4 : while (3 < comphelper::string::getTokenCount(sSectLink, sfx2::cTokenSeperator))
[ - + ]
739 : : {
740 [ # # ]: 0 : sSectLink += sfx2::cTokenSeperator;
741 : : }
742 [ + - ][ + - ]: 4 : sSectLink.SetToken(2, sfx2::cTokenSeperator, sLink);
[ + - ]
743 [ + - ]: 4 : pSectionData->SetLinkFileName(sSectLink);
744 [ - + ]: 4 : if (sSectLink.Len() < 3)
745 : : {
746 : 0 : pSectionData->SetType(CONTENT_SECTION);
747 [ + - ]: 4 : }
748 : 4 : }
749 : : }
750 : 4 : break;
751 : : case WID_SECT_VISIBLE:
752 : : {
753 : 15 : sal_Bool bVal(sal_False);
754 [ - + ]: 15 : if (!(pValues[nProperty] >>= bVal))
755 : : {
756 [ # # ]: 0 : throw lang::IllegalArgumentException();
757 : : }
758 [ + + ]: 15 : if (m_bIsDescriptor)
759 : : {
760 : 11 : m_pProps->m_bHidden = !bVal;
761 : : }
762 : : else
763 : : {
764 : 4 : pSectionData->SetHidden(!bVal);
765 : : }
766 : : }
767 : 15 : break;
768 : : case WID_SECT_CURRENTLY_VISIBLE:
769 : : {
770 : 2 : sal_Bool bVal(sal_False);
771 [ - + ]: 2 : if (!(pValues[nProperty] >>= bVal))
772 : : {
773 [ # # ]: 0 : throw lang::IllegalArgumentException();
774 : : }
775 [ - + ]: 2 : if (m_bIsDescriptor)
776 : : {
777 : 0 : m_pProps->m_bCondHidden = !bVal;
778 : : }
779 : : else
780 : : {
781 [ - + ]: 2 : if (pSectionData->GetCondition().Len() != 0)
782 : : {
783 : 0 : pSectionData->SetCondHidden(!bVal);
784 : : }
785 : : }
786 : : }
787 : 2 : break;
788 : : case WID_SECT_PROTECTED:
789 : : {
790 : 43 : sal_Bool bVal(sal_False);
791 [ - + ]: 43 : if (!(pValues[nProperty] >>= bVal))
792 : : {
793 [ # # ]: 0 : throw lang::IllegalArgumentException();
794 : : }
795 [ + + ]: 43 : if (m_bIsDescriptor)
796 : : {
797 : 39 : m_pProps->m_bProtect = bVal;
798 : : }
799 : : else
800 : : {
801 : 4 : pSectionData->SetProtectFlag(bVal);
802 : : }
803 : : }
804 : 43 : break;
805 : : case WID_SECT_EDIT_IN_READONLY:
806 : : {
807 : 43 : sal_Bool bVal(sal_False);
808 [ - + ]: 43 : if (!(pValues[nProperty] >>= bVal))
809 : : {
810 [ # # ]: 0 : throw lang::IllegalArgumentException();
811 : : }
812 [ + + ]: 43 : if (m_bIsDescriptor)
813 : : {
814 : 39 : m_pProps->m_bEditInReadonly = bVal;
815 : : }
816 : : else
817 : : {
818 : 4 : pSectionData->SetEditInReadonlyFlag(bVal);
819 : : }
820 : : }
821 : 43 : break;
822 : : case WID_SECT_PASSWORD:
823 : : {
824 [ + - ]: 8 : uno::Sequence<sal_Int8> aSeq;
825 [ + - ]: 8 : pValues[nProperty] >>= aSeq;
826 [ + + ]: 8 : if (m_bIsDescriptor)
827 : : {
828 [ + - ]: 4 : m_pProps->m_Password = aSeq;
829 : : }
830 : : else
831 : : {
832 [ + - ]: 4 : pSectionData->SetPassword(aSeq);
833 [ + - ]: 8 : }
834 : : }
835 : 8 : break;
836 : : default:
837 : : {
838 [ + + ]: 119 : if (pFmt)
839 : : {
840 : 80 : const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
841 [ + - ][ + - ]: 80 : pItemSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), pEntry->nWID, pEntry->nWID));
842 [ + - ]: 80 : pItemSet->Put(rOldAttrSet);
843 : : m_rPropSet.setPropertyValue(*pEntry,
844 [ + + ]: 80 : pValues[nProperty], *pItemSet);
845 : : }
846 : : else
847 : : {
848 : 39 : SfxPoolItem* pPutItem = 0;
849 [ + - ]: 39 : if (RES_COL == pEntry->nWID)
850 : : {
851 [ + - ]: 39 : if (!m_pProps->m_pColItem.get())
852 : : {
853 [ + - ][ + - ]: 39 : m_pProps->m_pColItem.reset(new SwFmtCol);
854 : : }
855 : 39 : pPutItem = m_pProps->m_pColItem.get();
856 : : }
857 [ # # ]: 0 : else if (RES_BACKGROUND == pEntry->nWID)
858 : : {
859 [ # # ]: 0 : if (!m_pProps->m_pBrushItem.get())
860 : : {
861 : 0 : m_pProps->m_pBrushItem.reset(
862 [ # # ][ # # ]: 0 : new SvxBrushItem(RES_BACKGROUND));
863 : : }
864 : 0 : pPutItem = m_pProps->m_pBrushItem.get();
865 : : }
866 [ # # ]: 0 : else if (RES_FTN_AT_TXTEND == pEntry->nWID)
867 : : {
868 [ # # ]: 0 : if (!m_pProps->m_pFtnItem.get())
869 : : {
870 [ # # ][ # # ]: 0 : m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd);
871 : : }
872 : 0 : pPutItem = m_pProps->m_pFtnItem.get();
873 : : }
874 [ # # ]: 0 : else if (RES_END_AT_TXTEND == pEntry->nWID)
875 : : {
876 [ # # ]: 0 : if (!m_pProps->m_pEndItem.get())
877 : : {
878 [ # # ][ # # ]: 0 : m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd);
879 : : }
880 : 0 : pPutItem = m_pProps->m_pEndItem.get();
881 : : }
882 [ # # ]: 0 : else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
883 : : {
884 [ # # ]: 0 : if (!m_pProps->m_pXMLAttr.get())
885 : : {
886 : 0 : m_pProps->m_pXMLAttr.reset(
887 : : new SvXMLAttrContainerItem(
888 [ # # ][ # # ]: 0 : RES_UNKNOWNATR_CONTAINER));
889 : : }
890 : 0 : pPutItem = m_pProps->m_pXMLAttr.get();
891 : : }
892 [ # # ]: 0 : else if (RES_COLUMNBALANCE== pEntry->nWID)
893 : : {
894 [ # # ]: 0 : if (!m_pProps->m_pNoBalanceItem.get())
895 : : {
896 : 0 : m_pProps->m_pNoBalanceItem.reset(
897 [ # # ][ # # ]: 0 : new SwFmtNoBalancedColumns(RES_COLUMNBALANCE));
898 : : }
899 : 0 : pPutItem = m_pProps->m_pNoBalanceItem.get();
900 : : }
901 [ # # ]: 0 : else if (RES_FRAMEDIR == pEntry->nWID)
902 : : {
903 [ # # ]: 0 : if (!m_pProps->m_pFrameDirItem.get())
904 : : {
905 : 0 : m_pProps->m_pFrameDirItem.reset(
906 : : new SvxFrameDirectionItem(
907 [ # # ][ # # ]: 0 : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR));
908 : : }
909 : 0 : pPutItem = m_pProps->m_pFrameDirItem.get();
910 : : }
911 [ # # ]: 0 : else if (RES_LR_SPACE == pEntry->nWID)
912 : : {
913 [ # # ]: 0 : if (!m_pProps->m_pLRSpaceItem.get())
914 : : {
915 : 0 : m_pProps->m_pLRSpaceItem.reset(
916 [ # # ][ # # ]: 0 : new SvxLRSpaceItem( RES_LR_SPACE ));
917 : : }
918 : 0 : pPutItem = m_pProps->m_pLRSpaceItem.get();
919 : : }
920 [ + - ]: 39 : if (pPutItem)
921 : : {
922 : 39 : pPutItem->PutValue(pValues[nProperty],
923 [ + - ]: 39 : pEntry->nMemberId);
924 : : }
925 : : }
926 : : }
927 : : }
928 : : }
929 : :
930 : : lcl_UpdateSection(pFmt, pSectionData, pItemSet, bLinkModeChanged,
931 [ + - ][ + - ]: 228 : bLinkMode);
[ + - ]
932 : 216 : }
933 : :
934 : : void SAL_CALL
935 : 39 : SwXTextSection::setPropertyValues(
936 : : const uno::Sequence< ::rtl::OUString >& rPropertyNames,
937 : : const uno::Sequence< uno::Any >& rValues)
938 : : throw (beans::PropertyVetoException, lang::IllegalArgumentException,
939 : : lang::WrappedTargetException, uno::RuntimeException)
940 : : {
941 [ + - ]: 39 : SolarMutexGuard aGuard;
942 : :
943 : : // workaround for bad designed API
944 : : try
945 : : {
946 [ + - ]: 39 : m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
947 : : }
948 [ # # ]: 0 : catch (const beans::UnknownPropertyException &rException)
949 : : {
950 : : // wrap the original (here not allowed) exception in
951 : : // a WrappedTargetException that gets thrown instead.
952 [ # # ]: 0 : lang::WrappedTargetException aWExc;
953 [ # # ]: 0 : aWExc.TargetException <<= rException;
954 [ # # ]: 0 : throw aWExc;
955 [ + - ]: 39 : }
956 : 39 : }
957 : :
958 : 189 : void SwXTextSection::setPropertyValue(
959 : : const OUString& rPropertyName, const uno::Any& rValue)
960 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
961 : : lang::IllegalArgumentException, lang::WrappedTargetException,
962 : : uno::RuntimeException )
963 : : {
964 [ + - ]: 189 : SolarMutexGuard aGuard;
965 : :
966 [ + - ]: 189 : uno::Sequence< ::rtl::OUString > aPropertyNames(1);
967 [ + - ]: 189 : aPropertyNames.getArray()[0] = rPropertyName;
968 [ + - ]: 189 : uno::Sequence< uno::Any > aValues(1);
969 [ + - ]: 189 : aValues.getArray()[0] = rValue;
970 [ + - ][ + - ]: 189 : m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
[ + - ][ + + ]
971 : 177 : }
972 : :
973 : : uno::Sequence< uno::Any >
974 : 546 : SwXTextSection::Impl::GetPropertyValues_Impl(
975 : : const uno::Sequence< OUString > & rPropertyNames )
976 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
977 : : uno::RuntimeException)
978 : : {
979 : 546 : SwSectionFmt *const pFmt = GetSectionFmt();
980 [ # # ][ - + ]: 546 : if (!pFmt && !m_bIsDescriptor)
981 : : {
982 [ # # ]: 0 : throw uno::RuntimeException();
983 : : }
984 : :
985 : 546 : uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
986 [ + - ]: 546 : uno::Any* pRet = aRet.getArray();
987 [ + - ][ + - ]: 546 : SwSection *const pSect = (pFmt) ? pFmt->GetSection() : 0;
988 : 546 : const OUString* pPropertyNames = rPropertyNames.getConstArray();
989 : :
990 [ + + ]: 1216 : for (sal_Int32 nProperty = 0; nProperty < rPropertyNames.getLength();
991 : : nProperty++)
992 : : {
993 : : SfxItemPropertySimpleEntry const*const pEntry =
994 [ + - ]: 670 : m_rPropSet.getPropertyMap().getByName(pPropertyNames[nProperty]);
995 [ - + ]: 670 : if (!pEntry)
996 : : {
997 : : throw beans::UnknownPropertyException(
998 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
999 : 0 : + pPropertyNames[nProperty],
1000 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(& m_rThis));
[ # # ]
1001 : : }
1002 [ + + + + : 670 : switch(pEntry->nWID)
+ + + + +
- + - + +
+ + ]
1003 : : {
1004 : : case WID_SECT_CONDITION:
1005 : : {
1006 : : OUString uTmp( (m_bIsDescriptor)
1007 : 0 : ? m_pProps->m_sCondition
1008 [ - + ][ + - ]: 14 : : ::rtl::OUString(pSect->GetCondition()));
1009 [ + - ]: 14 : pRet[nProperty] <<= uTmp;
1010 : : }
1011 : 14 : break;
1012 : : case WID_SECT_DDE_TYPE:
1013 : : case WID_SECT_DDE_FILE:
1014 : : case WID_SECT_DDE_ELEMENT:
1015 : : {
1016 : 42 : ::rtl::OUString sRet;
1017 [ - + ]: 42 : if (m_bIsDescriptor)
1018 : : {
1019 [ # # ]: 0 : if (m_pProps->m_bDDE)
1020 : : {
1021 : 0 : sRet = m_pProps->m_sLinkFileName;
1022 : : }
1023 : : }
1024 [ + + ]: 42 : else if (DDE_LINK_SECTION == pSect->GetType())
1025 : : {
1026 [ + - ][ + - ]: 16 : sRet = pSect->GetLinkFileName();
1027 : : }
1028 : 42 : sal_Int32 nDummy(0);
1029 : : sRet = sRet.getToken(pEntry->nWID - WID_SECT_DDE_TYPE,
1030 : 42 : sfx2::cTokenSeperator, nDummy);
1031 [ + - ]: 42 : pRet[nProperty] <<= sRet;
1032 : : }
1033 : 42 : break;
1034 : : case WID_SECT_DDE_AUTOUPDATE:
1035 : : {
1036 : : // GetUpdateType() returns .._ALWAYS or .._ONCALL
1037 [ + - ][ + - ]: 10 : if (pSect && pSect->IsLinkType() && pSect->IsConnected()) // #i73247#
[ + - ][ + - ]
1038 : : {
1039 : : const sal_Bool bTemp =
1040 [ + - ]: 10 : (pSect->GetUpdateType() == sfx2::LINKUPDATE_ALWAYS);
1041 [ + - ]: 10 : pRet[nProperty] <<= bTemp;
1042 : : }
1043 : : }
1044 : 10 : break;
1045 : : case WID_SECT_LINK :
1046 : : {
1047 : 14 : text::SectionFileLink aLink;
1048 [ - + ]: 14 : if (m_bIsDescriptor)
1049 : : {
1050 [ # # ]: 0 : if (!m_pProps->m_bDDE)
1051 : : {
1052 : 0 : aLink.FileURL = m_pProps->m_sLinkFileName;
1053 : 0 : aLink.FilterName = m_pProps->m_sSectionFilter;
1054 : : }
1055 : : }
1056 [ + + ]: 14 : else if (FILE_LINK_SECTION == pSect->GetType())
1057 : : {
1058 [ + - ][ + - ]: 6 : ::rtl::OUString sRet( pSect->GetLinkFileName() );
1059 : 6 : sal_Int32 nIndex(0);
1060 : : aLink.FileURL =
1061 : 6 : sRet.getToken(0, sfx2::cTokenSeperator, nIndex);
1062 : : aLink.FilterName =
1063 : 6 : sRet.getToken(0, sfx2::cTokenSeperator, nIndex);
1064 : : }
1065 [ + - ]: 14 : pRet[nProperty] <<= aLink;
1066 : : }
1067 : 14 : break;
1068 : : case WID_SECT_REGION :
1069 : : {
1070 : 14 : ::rtl::OUString sRet;
1071 [ - + ]: 14 : if (m_bIsDescriptor)
1072 : : {
1073 : 0 : sRet = m_pProps->m_sSectionRegion;
1074 : : }
1075 [ + + ]: 14 : else if (FILE_LINK_SECTION == pSect->GetType())
1076 : : {
1077 [ + - ]: 6 : sRet = pSect->GetLinkFileName().GetToken(2,
1078 [ + - ][ + - ]: 6 : sfx2::cTokenSeperator);
[ + - ]
1079 : : }
1080 [ + - ]: 14 : pRet[nProperty] <<= sRet;
1081 : : }
1082 : 14 : break;
1083 : : case WID_SECT_VISIBLE :
1084 : : {
1085 : : const sal_Bool bTemp = (m_bIsDescriptor)
1086 [ - + ]: 14 : ? !m_pProps->m_bHidden : !pSect->IsHidden();
1087 [ + - ]: 14 : pRet[nProperty] <<= bTemp;
1088 : : }
1089 : 14 : break;
1090 : : case WID_SECT_CURRENTLY_VISIBLE:
1091 : : {
1092 : : const sal_Bool bTemp = (m_bIsDescriptor)
1093 [ - + ]: 4 : ? !m_pProps->m_bCondHidden : !pSect->IsCondHidden();
1094 [ + - ]: 4 : pRet[nProperty] <<= bTemp;
1095 : : }
1096 : 4 : break;
1097 : : case WID_SECT_PROTECTED:
1098 : : {
1099 : : const sal_Bool bTemp = (m_bIsDescriptor)
1100 [ - + ][ + - ]: 14 : ? m_pProps->m_bProtect : pSect->IsProtect();
1101 [ + - ]: 14 : pRet[nProperty] <<= bTemp;
1102 : : }
1103 : 14 : break;
1104 : : case WID_SECT_EDIT_IN_READONLY:
1105 : : {
1106 : : const sal_Bool bTemp = (m_bIsDescriptor)
1107 [ - + ][ + - ]: 74 : ? m_pProps->m_bEditInReadonly : pSect->IsEditInReadonly();
1108 [ + - ]: 74 : pRet[nProperty] <<= bTemp;
1109 : : }
1110 : 74 : break;
1111 : : case FN_PARAM_LINK_DISPLAY_NAME:
1112 : : {
1113 [ # # ]: 0 : if (pFmt)
1114 : : {
1115 : 0 : pRet[nProperty] <<=
1116 [ # # ][ # # ]: 0 : OUString(pFmt->GetSection()->GetSectionName());
[ # # ]
1117 : : }
1118 : : }
1119 : 0 : break;
1120 : : case WID_SECT_DOCUMENT_INDEX:
1121 : : {
1122 : : // search enclosing index
1123 : 64 : SwSection* pEnclosingSection = pSect;
1124 [ + + + + ]: 192 : while ((pEnclosingSection != NULL) &&
[ + + ]
1125 : 92 : (TOX_CONTENT_SECTION != pEnclosingSection->GetType()))
1126 : : {
1127 [ + - ]: 36 : pEnclosingSection = pEnclosingSection->GetParent();
1128 : : }
1129 [ + + ]: 64 : if (pEnclosingSection)
1130 : : {
1131 : : // convert section to TOXBase and get SwXDocumentIndex
1132 : : SwTOXBaseSection *const pTOXBaseSect =
1133 [ + - ][ + - ]: 56 : PTR_CAST(SwTOXBaseSection, pEnclosingSection);
[ + - ][ + - ]
[ + - ]
1134 : : const uno::Reference<text::XDocumentIndex> xIndex =
1135 : : SwXDocumentIndex::CreateXDocumentIndex(
1136 [ + - ]: 56 : *pTOXBaseSect->GetFmt()->GetDoc(), *pTOXBaseSect);
1137 [ + - ]: 56 : pRet[nProperty] <<= xIndex;
1138 : : }
1139 : : // else: no enclosing index found -> empty return value
1140 : : }
1141 : 64 : break;
1142 : : case WID_SECT_IS_GLOBAL_DOC_SECTION:
1143 : : {
1144 : : const sal_Bool bRet = (NULL == pFmt) ? sal_False :
1145 [ # # ][ # # ]: 0 : static_cast<sal_Bool>(NULL != pFmt->GetGlobalDocSection());
[ # # ]
1146 [ # # ]: 0 : pRet[nProperty] <<= bRet;
1147 : : }
1148 : 0 : break;
1149 : : case FN_UNO_ANCHOR_TYPES:
1150 : : case FN_UNO_TEXT_WRAP:
1151 : : case FN_UNO_ANCHOR_TYPE:
1152 : : ::sw::GetDefaultTextContentValue(
1153 [ + - ]: 12 : pRet[nProperty], OUString(), pEntry->nWID);
1154 : 12 : break;
1155 : : case FN_UNO_REDLINE_NODE_START:
1156 : : case FN_UNO_REDLINE_NODE_END:
1157 : : {
1158 [ - + ]: 64 : if (!pFmt)
1159 : 0 : break; // #i73247#
1160 [ + - ]: 64 : SwNode* pSectNode = pFmt->GetSectionNode();
1161 [ + + ]: 64 : if (FN_UNO_REDLINE_NODE_END == pEntry->nWID)
1162 : : {
1163 : 32 : pSectNode = pSectNode->EndOfSectionNode();
1164 : : }
1165 : : const SwRedlineTbl& rRedTbl =
1166 [ + - ]: 64 : pFmt->GetDoc()->GetRedlineTbl();
1167 [ - + ]: 64 : for (sal_uInt16 nRed = 0; nRed < rRedTbl.size(); nRed++)
1168 : : {
1169 [ # # ]: 0 : const SwRedline* pRedline = rRedTbl[nRed];
1170 : 0 : SwNode const*const pRedPointNode = pRedline->GetNode(sal_True);
1171 : 0 : SwNode const*const pRedMarkNode = pRedline->GetNode(sal_False);
1172 [ # # ][ # # ]: 0 : if ((pRedPointNode == pSectNode) ||
1173 : : (pRedMarkNode == pSectNode))
1174 : : {
1175 : : SwNode const*const pStartOfRedline =
1176 : : (SwNodeIndex(*pRedPointNode) <=
1177 [ # # ][ # # ]: 0 : SwNodeIndex(*pRedMarkNode))
[ # # ][ # # ]
1178 [ # # ]: 0 : ? pRedPointNode : pRedMarkNode;
1179 : 0 : const bool bIsStart = (pStartOfRedline == pSectNode);
1180 : 0 : pRet[nProperty] <<=
1181 : : SwXRedlinePortion::CreateRedlineProperties(
1182 [ # # ][ # # ]: 0 : *pRedline, bIsStart);
1183 : 0 : break;
1184 : : }
1185 : : }
1186 : : }
1187 : 64 : break;
1188 : : case WID_SECT_PASSWORD:
1189 : : {
1190 : 14 : pRet[nProperty] <<= (m_bIsDescriptor)
1191 [ - + ][ + - ]: 14 : ? m_pProps->m_Password : pSect->GetPassword();
1192 : : }
1193 : 14 : break;
1194 : : default:
1195 : : {
1196 [ + - ]: 316 : if (pFmt)
1197 : : {
1198 : : m_rPropSet.getPropertyValue(*pEntry,
1199 [ + - ]: 316 : pFmt->GetAttrSet(), pRet[nProperty]);
1200 : : }
1201 : : else
1202 : : {
1203 : 0 : const SfxPoolItem* pQueryItem = 0;
1204 [ # # ]: 0 : if (RES_COL == pEntry->nWID)
1205 : : {
1206 [ # # ]: 0 : if (!m_pProps->m_pColItem.get())
1207 : : {
1208 [ # # ][ # # ]: 0 : m_pProps->m_pColItem.reset(new SwFmtCol);
1209 : : }
1210 : 0 : pQueryItem = m_pProps->m_pColItem.get();
1211 : : }
1212 [ # # ]: 0 : else if (RES_BACKGROUND == pEntry->nWID)
1213 : : {
1214 [ # # ]: 0 : if (!m_pProps->m_pBrushItem.get())
1215 : : {
1216 : 0 : m_pProps->m_pBrushItem.reset(
1217 [ # # ][ # # ]: 0 : new SvxBrushItem(RES_BACKGROUND));
1218 : : }
1219 : 0 : pQueryItem = m_pProps->m_pBrushItem.get();
1220 : : }
1221 [ # # ]: 0 : else if (RES_FTN_AT_TXTEND == pEntry->nWID)
1222 : : {
1223 [ # # ]: 0 : if (!m_pProps->m_pFtnItem.get())
1224 : : {
1225 [ # # ][ # # ]: 0 : m_pProps->m_pFtnItem.reset(new SwFmtFtnAtTxtEnd);
1226 : : }
1227 : 0 : pQueryItem = m_pProps->m_pFtnItem.get();
1228 : : }
1229 [ # # ]: 0 : else if (RES_END_AT_TXTEND == pEntry->nWID)
1230 : : {
1231 [ # # ]: 0 : if (!m_pProps->m_pEndItem.get())
1232 : : {
1233 [ # # ][ # # ]: 0 : m_pProps->m_pEndItem.reset(new SwFmtEndAtTxtEnd);
1234 : : }
1235 : 0 : pQueryItem = m_pProps->m_pEndItem.get();
1236 : : }
1237 [ # # ]: 0 : else if (RES_UNKNOWNATR_CONTAINER== pEntry->nWID)
1238 : : {
1239 [ # # ]: 0 : if (!m_pProps->m_pXMLAttr.get())
1240 : : {
1241 : 0 : m_pProps->m_pXMLAttr.reset(
1242 [ # # ][ # # ]: 0 : new SvXMLAttrContainerItem);
1243 : : }
1244 : 0 : pQueryItem = m_pProps->m_pXMLAttr.get();
1245 : : }
1246 [ # # ]: 0 : else if (RES_COLUMNBALANCE== pEntry->nWID)
1247 : : {
1248 [ # # ]: 0 : if (!m_pProps->m_pNoBalanceItem.get())
1249 : : {
1250 : 0 : m_pProps->m_pNoBalanceItem.reset(
1251 [ # # ][ # # ]: 0 : new SwFmtNoBalancedColumns);
1252 : : }
1253 : 0 : pQueryItem = m_pProps->m_pNoBalanceItem.get();
1254 : : }
1255 [ # # ]: 0 : else if (RES_FRAMEDIR == pEntry->nWID)
1256 : : {
1257 [ # # ]: 0 : if (!m_pProps->m_pFrameDirItem.get())
1258 : : {
1259 : 0 : m_pProps->m_pFrameDirItem.reset(
1260 : : new SvxFrameDirectionItem(
1261 [ # # ][ # # ]: 0 : FRMDIR_ENVIRONMENT, RES_FRAMEDIR));
1262 : : }
1263 : 0 : pQueryItem = m_pProps->m_pFrameDirItem.get();
1264 : : }
1265 [ # # ]: 0 : else if (RES_LR_SPACE == pEntry->nWID)
1266 : : {
1267 [ # # ]: 0 : if (!m_pProps->m_pLRSpaceItem.get())
1268 : : {
1269 : 0 : m_pProps->m_pLRSpaceItem.reset(
1270 [ # # ][ # # ]: 0 : new SvxLRSpaceItem( RES_LR_SPACE ));
1271 : : }
1272 : 0 : pQueryItem = m_pProps->m_pLRSpaceItem.get();
1273 : : }
1274 [ # # ]: 0 : if (pQueryItem)
1275 : : {
1276 : 0 : pQueryItem->QueryValue(pRet[nProperty],
1277 [ # # ]: 0 : pEntry->nMemberId);
1278 : : }
1279 : : }
1280 : : }
1281 : : }
1282 : : }
1283 : 546 : return aRet;
1284 : : }
1285 : :
1286 : : uno::Sequence< uno::Any > SAL_CALL
1287 : 64 : SwXTextSection::getPropertyValues(
1288 : : const uno::Sequence< ::rtl::OUString >& rPropertyNames)
1289 : : throw (uno::RuntimeException)
1290 : : {
1291 [ + - ]: 64 : SolarMutexGuard aGuard;
1292 [ + - ]: 64 : uno::Sequence< uno::Any > aValues;
1293 : :
1294 : : // workaround for bad designed API
1295 : : try
1296 : : {
1297 [ + - ][ + - ]: 64 : aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
[ + - ]
1298 : : }
1299 : 0 : catch (beans::UnknownPropertyException &)
1300 : : {
1301 : : throw uno::RuntimeException(OUString(
1302 : : RTL_CONSTASCII_USTRINGPARAM("Unknown property exception caught")),
1303 [ # # # # : 0 : static_cast<cppu::OWeakObject *>(this));
# # ]
1304 : : }
1305 [ # # # ]: 0 : catch (lang::WrappedTargetException &)
1306 : : {
1307 : : throw uno::RuntimeException(OUString(
1308 : : RTL_CONSTASCII_USTRINGPARAM("WrappedTargetException caught")),
1309 [ # # # # : 0 : static_cast<cppu::OWeakObject *>(this));
# # ]
1310 : : }
1311 : :
1312 [ + - ]: 64 : return aValues;
1313 : : }
1314 : :
1315 : : uno::Any SAL_CALL
1316 : 482 : SwXTextSection::getPropertyValue(const OUString& rPropertyName)
1317 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1318 : : uno::RuntimeException)
1319 : : {
1320 [ + - ]: 482 : SolarMutexGuard aGuard;
1321 : :
1322 [ + - ]: 482 : uno::Sequence< ::rtl::OUString > aPropertyNames(1);
1323 [ + - ]: 482 : aPropertyNames.getArray()[0] = rPropertyName;
1324 [ + - ][ + - ]: 482 : return m_pImpl->GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
[ + - ][ + - ]
1325 : : }
1326 : :
1327 : 0 : void SAL_CALL SwXTextSection::addPropertiesChangeListener(
1328 : : const uno::Sequence< OUString >& /*aPropertyNames*/,
1329 : : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
1330 : : throw (uno::RuntimeException)
1331 : : {
1332 : : OSL_FAIL("SwXTextSection::addPropertiesChangeListener(): not implemented");
1333 : 0 : }
1334 : :
1335 : 0 : void SAL_CALL SwXTextSection::removePropertiesChangeListener(
1336 : : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
1337 : : throw (uno::RuntimeException)
1338 : : {
1339 : : OSL_FAIL("SwXTextSection::removePropertiesChangeListener(): not implemented");
1340 : 0 : }
1341 : :
1342 : 0 : void SAL_CALL SwXTextSection::firePropertiesChangeEvent(
1343 : : const uno::Sequence< OUString >& /*aPropertyNames*/,
1344 : : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
1345 : : throw(uno::RuntimeException)
1346 : : {
1347 : : OSL_FAIL("SwXTextSection::firePropertiesChangeEvent(): not implemented");
1348 : 0 : }
1349 : :
1350 : : void SAL_CALL
1351 : 0 : SwXTextSection::addPropertyChangeListener(
1352 : : const ::rtl::OUString& /*rPropertyName*/,
1353 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1354 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1355 : : uno::RuntimeException)
1356 : : {
1357 : : OSL_FAIL("SwXTextSection::addPropertyChangeListener(): not implemented");
1358 : 0 : }
1359 : :
1360 : : void SAL_CALL
1361 : 0 : SwXTextSection::removePropertyChangeListener(
1362 : : const ::rtl::OUString& /*rPropertyName*/,
1363 : : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1364 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1365 : : uno::RuntimeException)
1366 : : {
1367 : : OSL_FAIL("SwXTextSection::removePropertyChangeListener(): not implemented");
1368 : 0 : }
1369 : :
1370 : : void SAL_CALL
1371 : 0 : SwXTextSection::addVetoableChangeListener(
1372 : : const ::rtl::OUString& /*rPropertyName*/,
1373 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1374 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1375 : : uno::RuntimeException)
1376 : : {
1377 : : OSL_FAIL("SwXTextSection::addVetoableChangeListener(): not implemented");
1378 : 0 : }
1379 : :
1380 : : void SAL_CALL
1381 : 0 : SwXTextSection::removeVetoableChangeListener(
1382 : : const ::rtl::OUString& /*rPropertyName*/,
1383 : : const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1384 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1385 : : uno::RuntimeException)
1386 : : {
1387 : : OSL_FAIL("SwXTextSection::removeVetoableChangeListener(): not implemented");
1388 : 0 : }
1389 : :
1390 : : beans::PropertyState SAL_CALL
1391 : 2 : SwXTextSection::getPropertyState(const OUString& rPropertyName)
1392 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1393 : : {
1394 [ + - ]: 2 : SolarMutexGuard aGuard;
1395 : :
1396 [ + - ]: 2 : uno::Sequence< OUString > aNames(1);
1397 [ + - ]: 2 : aNames.getArray()[0] = rPropertyName;
1398 [ + - ][ + - ]: 2 : return getPropertyStates(aNames).getConstArray()[0];
[ + - ][ + - ]
1399 : : }
1400 : :
1401 : : uno::Sequence< beans::PropertyState > SAL_CALL
1402 : 68 : SwXTextSection::getPropertyStates(
1403 : : const uno::Sequence< OUString >& rPropertyNames)
1404 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1405 : : {
1406 [ + - ]: 68 : SolarMutexGuard aGuard;
1407 : :
1408 : 68 : SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
1409 [ # # ][ - + ]: 68 : if (!pFmt && !m_pImpl->m_bIsDescriptor)
[ - + ]
1410 : : {
1411 [ # # ]: 0 : throw uno::RuntimeException();
1412 : : }
1413 : :
1414 [ + - ]: 68 : uno::Sequence< beans::PropertyState > aStates(rPropertyNames.getLength());
1415 [ + - ]: 68 : beans::PropertyState *const pStates = aStates.getArray();
1416 : 68 : const OUString* pNames = rPropertyNames.getConstArray();
1417 [ + + ]: 1736 : for (sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
1418 : : {
1419 : 1668 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1420 : : SfxItemPropertySimpleEntry const*const pEntry =
1421 [ + - ]: 1668 : m_pImpl->m_rPropSet.getPropertyMap().getByName( pNames[i]);
1422 [ - + ]: 1668 : if (!pEntry)
1423 : : {
1424 : : throw beans::UnknownPropertyException(
1425 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1426 [ # # ][ # # ]: 0 : + pNames[i], static_cast< cppu::OWeakObject* >(this));
[ # # ]
1427 : : }
1428 [ + + ]: 1668 : switch (pEntry->nWID)
1429 : : {
1430 : : case WID_SECT_CONDITION:
1431 : : case WID_SECT_DDE_TYPE:
1432 : : case WID_SECT_DDE_FILE:
1433 : : case WID_SECT_DDE_ELEMENT:
1434 : : case WID_SECT_DDE_AUTOUPDATE:
1435 : : case WID_SECT_LINK:
1436 : : case WID_SECT_REGION :
1437 : : case WID_SECT_VISIBLE:
1438 : : case WID_SECT_PROTECTED:
1439 : : case WID_SECT_EDIT_IN_READONLY:
1440 : : case FN_PARAM_LINK_DISPLAY_NAME:
1441 : : case FN_UNO_ANCHOR_TYPES:
1442 : : case FN_UNO_TEXT_WRAP:
1443 : : case FN_UNO_ANCHOR_TYPE:
1444 : 64 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
1445 : 64 : break;
1446 : : default:
1447 : : {
1448 [ + - ]: 1604 : if (pFmt)
1449 : : {
1450 : 1604 : pStates[i] = m_pImpl->m_rPropSet.getPropertyState(
1451 [ + - ]: 3208 : pNames[i], pFmt->GetAttrSet());
1452 : : }
1453 : : else
1454 : : {
1455 [ # # ]: 0 : if (RES_COL == pEntry->nWID)
1456 : : {
1457 [ # # ]: 0 : if (!m_pImpl->m_pProps->m_pColItem.get())
1458 : : {
1459 : 0 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1460 : : }
1461 : : else
1462 : : {
1463 : 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
1464 : : }
1465 : : }
1466 : : else //if(RES_BACKGROUND == pEntry->nWID)
1467 : : {
1468 [ # # ]: 0 : if (!m_pImpl->m_pProps->m_pBrushItem.get())
1469 : : {
1470 : 0 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1471 : : }
1472 : : else
1473 : : {
1474 : 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
1475 : : }
1476 : : }
1477 : : }
1478 : : }
1479 : : }
1480 : : }
1481 [ + - ]: 68 : return aStates;
1482 : : }
1483 : :
1484 : : void SAL_CALL
1485 : 2 : SwXTextSection::setPropertyToDefault(const OUString& rPropertyName)
1486 : : throw (beans::UnknownPropertyException, uno::RuntimeException)
1487 : : {
1488 [ + - ]: 2 : SolarMutexGuard aGuard;
1489 : :
1490 : 2 : SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
1491 [ # # ][ - + ]: 2 : if (!pFmt && !m_pImpl->m_bIsDescriptor)
[ - + ]
1492 : : {
1493 [ # # ]: 0 : throw uno::RuntimeException();
1494 : : }
1495 : :
1496 : : SfxItemPropertySimpleEntry const*const pEntry =
1497 [ + - ]: 2 : m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1498 [ - + ]: 2 : if (!pEntry)
1499 : : {
1500 : : throw beans::UnknownPropertyException(
1501 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1502 [ # # ][ # # ]: 0 : + rPropertyName, static_cast< cppu::OWeakObject* >(this));
[ # # ]
1503 : : }
1504 [ - + ]: 2 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1505 : : {
1506 : : throw uno::RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM(
1507 : : "setPropertyToDefault: property is read-only: "))
1508 : : + rPropertyName,
1509 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(this));
[ # # ]
1510 : : }
1511 : :
1512 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
1513 : : ::std::auto_ptr<SwSectionData> const pSectionData(
1514 [ + - ][ + - ]: 2 : (pFmt) ? new SwSectionData(*pFmt->GetSection()) : 0);
[ + - ][ + - ]
1515 : :
1516 : 2 : ::std::auto_ptr<SfxItemSet> pNewAttrSet;
1517 : : SAL_WNODEPRECATED_DECLARATIONS_POP
1518 : 2 : bool bLinkModeChanged = false;
1519 : :
1520 [ - - - - : 2 : switch (pEntry->nWID)
- - - + ]
1521 : : {
1522 : : case WID_SECT_CONDITION:
1523 : : {
1524 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1525 : : {
1526 [ # # ]: 0 : m_pImpl->m_pProps->m_sCondition = aEmptyStr;
1527 : : }
1528 : : else
1529 : : {
1530 [ # # ]: 0 : pSectionData->SetCondition(aEmptyStr);
1531 : : }
1532 : : }
1533 : 0 : break;
1534 : : case WID_SECT_DDE_TYPE :
1535 : : case WID_SECT_DDE_FILE :
1536 : : case WID_SECT_DDE_ELEMENT :
1537 : : case WID_SECT_LINK :
1538 : : case WID_SECT_REGION :
1539 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1540 : : {
1541 : 0 : m_pImpl->m_pProps->m_bDDE = false;
1542 : 0 : m_pImpl->m_pProps->m_sLinkFileName = ::rtl::OUString();
1543 : 0 : m_pImpl->m_pProps->m_sSectionRegion = ::rtl::OUString();
1544 : 0 : m_pImpl->m_pProps->m_sSectionFilter = ::rtl::OUString();
1545 : : }
1546 : : else
1547 : : {
1548 : 0 : pSectionData->SetType(CONTENT_SECTION);
1549 : : }
1550 : 0 : break;
1551 : : case WID_SECT_DDE_AUTOUPDATE:
1552 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1553 : : {
1554 : 0 : m_pImpl->m_pProps->m_bUpdateType = true;
1555 : : }
1556 : : else
1557 : : {
1558 : 0 : bLinkModeChanged = true;
1559 : : }
1560 : 0 : break;
1561 : : case WID_SECT_VISIBLE :
1562 : : {
1563 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1564 : : {
1565 : 0 : m_pImpl->m_pProps->m_bHidden = false;
1566 : : }
1567 : : else
1568 : : {
1569 : 0 : pSectionData->SetHidden(false);
1570 : : }
1571 : : }
1572 : 0 : break;
1573 : : case WID_SECT_PROTECTED:
1574 : : {
1575 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1576 : : {
1577 : 0 : m_pImpl->m_pProps->m_bProtect = false;
1578 : : }
1579 : : else
1580 : : {
1581 : 0 : pSectionData->SetProtectFlag(false);
1582 : : }
1583 : : }
1584 : 0 : break;
1585 : : case WID_SECT_EDIT_IN_READONLY:
1586 : : {
1587 [ # # ]: 0 : if (m_pImpl->m_bIsDescriptor)
1588 : : {
1589 : 0 : m_pImpl->m_pProps->m_bEditInReadonly = false;
1590 : : }
1591 : : else
1592 : : {
1593 : 0 : pSectionData->SetEditInReadonlyFlag(false);
1594 : : }
1595 : : }
1596 : 0 : break;
1597 : :
1598 : : case FN_UNO_ANCHOR_TYPES:
1599 : : case FN_UNO_TEXT_WRAP:
1600 : : case FN_UNO_ANCHOR_TYPE:
1601 : 0 : break;
1602 : : default:
1603 : : {
1604 [ + - ]: 2 : if (pEntry->nWID <= SFX_WHICH_MAX)
1605 : : {
1606 [ + - ]: 2 : if (pFmt)
1607 : : {
1608 : 2 : const SfxItemSet& rOldAttrSet = pFmt->GetAttrSet();
1609 [ + - ][ + - ]: 2 : pNewAttrSet.reset( new SfxItemSet(*rOldAttrSet.GetPool(), pEntry->nWID, pEntry->nWID));
1610 [ + - ]: 2 : pNewAttrSet->ClearItem(pEntry->nWID);
1611 : : }
1612 : : else
1613 : : {
1614 [ # # ]: 0 : if (RES_COL == pEntry->nWID)
1615 : : {
1616 : 0 : m_pImpl->m_pProps->m_pColItem.reset();
1617 : : }
1618 [ # # ]: 0 : else if (RES_BACKGROUND == pEntry->nWID)
1619 : : {
1620 : 0 : m_pImpl->m_pProps->m_pBrushItem.reset();
1621 : : }
1622 : : }
1623 : : }
1624 : : }
1625 : : }
1626 : :
1627 [ + - ][ + - ]: 2 : lcl_UpdateSection(pFmt, pSectionData, pNewAttrSet, bLinkModeChanged);
[ + - ][ + - ]
1628 : 2 : }
1629 : :
1630 : : uno::Any SAL_CALL
1631 : 2 : SwXTextSection::getPropertyDefault(const OUString& rPropertyName)
1632 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
1633 : : uno::RuntimeException)
1634 : : {
1635 [ + - ]: 2 : SolarMutexGuard aGuard;
1636 : :
1637 : 2 : uno::Any aRet;
1638 : 2 : SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
1639 : : SfxItemPropertySimpleEntry const*const pEntry =
1640 [ + - ]: 2 : m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1641 [ - + ]: 2 : if (!pEntry)
1642 : : {
1643 : : throw beans::UnknownPropertyException(
1644 : : OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown property: "))
1645 : : + rPropertyName,
1646 [ # # ][ # # ]: 0 : static_cast<cppu::OWeakObject *>(this));
[ # # ]
1647 : : }
1648 : :
1649 [ - - - - : 2 : switch(pEntry->nWID)
- + ]
1650 : : {
1651 : : case WID_SECT_CONDITION:
1652 : : case WID_SECT_DDE_TYPE :
1653 : : case WID_SECT_DDE_FILE :
1654 : : case WID_SECT_DDE_ELEMENT :
1655 : : case WID_SECT_REGION :
1656 : : case FN_PARAM_LINK_DISPLAY_NAME:
1657 [ # # ]: 0 : aRet <<= OUString();
1658 : 0 : break;
1659 : : case WID_SECT_LINK :
1660 [ # # ]: 0 : aRet <<= text::SectionFileLink();
1661 : 0 : break;
1662 : : case WID_SECT_DDE_AUTOUPDATE:
1663 : : case WID_SECT_VISIBLE :
1664 : : {
1665 : 0 : sal_Bool bTemp = sal_True;
1666 [ # # ]: 0 : aRet.setValue( &bTemp, ::getCppuBooleanType());
1667 : : }
1668 : 0 : break;
1669 : : case WID_SECT_PROTECTED:
1670 : : case WID_SECT_EDIT_IN_READONLY:
1671 : : {
1672 : 0 : sal_Bool bTemp = sal_False;
1673 [ # # ]: 0 : aRet.setValue( &bTemp, ::getCppuBooleanType());
1674 : : }
1675 : 0 : break;
1676 : : case FN_UNO_ANCHOR_TYPES:
1677 : : case FN_UNO_TEXT_WRAP:
1678 : : case FN_UNO_ANCHOR_TYPE:
1679 [ # # ]: 0 : ::sw::GetDefaultTextContentValue(aRet, OUString(), pEntry->nWID);
1680 : 0 : break;
1681 : : default:
1682 [ + - ][ + - ]: 2 : if(pFmt && pEntry->nWID <= SFX_WHICH_MAX)
1683 : : {
1684 : 2 : SwDoc *const pDoc = pFmt->GetDoc();
1685 : : const SfxPoolItem& rDefItem =
1686 [ + - ]: 2 : pDoc->GetAttrPool().GetDefaultItem(pEntry->nWID);
1687 [ + - ]: 2 : rDefItem.QueryValue(aRet, pEntry->nMemberId);
1688 : : }
1689 : : }
1690 [ + - ]: 2 : return aRet;
1691 : : }
1692 : :
1693 : 24 : OUString SAL_CALL SwXTextSection::getName() throw (uno::RuntimeException)
1694 : : {
1695 [ + - ]: 24 : SolarMutexGuard aGuard;
1696 : :
1697 : 24 : ::rtl::OUString sRet;
1698 : 24 : SwSectionFmt const*const pFmt = m_pImpl->GetSectionFmt();
1699 [ + - ]: 24 : if(pFmt)
1700 : : {
1701 [ + - ][ + - ]: 24 : sRet = pFmt->GetSection()->GetSectionName();
1702 : : }
1703 [ # # ]: 0 : else if (m_pImpl->m_bIsDescriptor)
1704 : : {
1705 : 0 : sRet = m_pImpl->m_sName;
1706 : : }
1707 : : else
1708 : : {
1709 [ # # ]: 0 : throw uno::RuntimeException();
1710 : : }
1711 [ + - ]: 24 : return sRet;
1712 : : }
1713 : :
1714 : 53 : void SAL_CALL SwXTextSection::setName(const OUString& rName)
1715 : : throw (uno::RuntimeException)
1716 : : {
1717 [ + - ]: 53 : SolarMutexGuard aGuard;
1718 : :
1719 : 53 : SwSectionFmt *const pFmt = m_pImpl->GetSectionFmt();
1720 [ + + ]: 53 : if(pFmt)
1721 : : {
1722 [ + - ]: 14 : SwSection *const pSect = pFmt->GetSection();
1723 [ + - ]: 14 : SwSectionData aSection(*pSect);
1724 [ + - ]: 14 : String sNewName(rName);
1725 [ + - ]: 14 : aSection.SetSectionName(sNewName);
1726 : :
1727 : 14 : const SwSectionFmts& rFmts = pFmt->GetDoc()->GetSections();
1728 : 14 : sal_uInt16 nApplyPos = USHRT_MAX;
1729 [ + + ]: 42 : for( sal_uInt16 i = 0; i < rFmts.size(); i++ )
1730 : : {
1731 [ + - ][ + - ]: 28 : if(rFmts[i]->GetSection() == pSect)
[ + + ]
1732 : : {
1733 : 14 : nApplyPos = i;
1734 : : }
1735 [ + - ][ + - ]: 14 : else if (sNewName == rFmts[i]->GetSection()->GetSectionName())
[ + - ][ - + ]
1736 : : {
1737 [ # # ]: 0 : throw uno::RuntimeException();
1738 : : }
1739 : : }
1740 [ + - ]: 14 : if(nApplyPos != USHRT_MAX)
1741 : : {
1742 : : {
1743 [ + - ]: 14 : UnoActionContext aContext(pFmt->GetDoc());
1744 [ + - ][ + - ]: 14 : pFmt->GetDoc()->UpdateSection(nApplyPos, aSection);
1745 : : }
1746 : : {
1747 : : // temporarily remove actions to allow cursor update
1748 [ + - ][ + - ]: 14 : UnoActionRemoveContext aRemoveContext( pFmt->GetDoc() );
1749 : : }
1750 [ + - ][ + - ]: 14 : }
1751 : : }
1752 [ + - ]: 39 : else if (m_pImpl->m_bIsDescriptor)
1753 : : {
1754 : 39 : m_pImpl->m_sName = rName;
1755 : : }
1756 : : else
1757 : : {
1758 [ # # ]: 0 : throw uno::RuntimeException();
1759 [ + - ]: 53 : }
1760 : 53 : }
1761 : :
1762 : : OUString SAL_CALL
1763 : 0 : SwXTextSection::getImplementationName() throw (uno::RuntimeException)
1764 : : {
1765 : 0 : return C2U("SwXTextSection");
1766 : : }
1767 : :
1768 : : static char const*const g_ServicesTextSection[] =
1769 : : {
1770 : : "com.sun.star.text.TextContent",
1771 : : "com.sun.star.text.TextSection",
1772 : : "com.sun.star.document.LinkTarget",
1773 : : };
1774 : :
1775 : 2 : sal_Bool SAL_CALL SwXTextSection::supportsService(const OUString& rServiceName)
1776 : : throw (uno::RuntimeException)
1777 : : {
1778 : : return ::sw::SupportsServiceImpl(
1779 : : SAL_N_ELEMENTS(g_ServicesTextSection),
1780 : 2 : g_ServicesTextSection, rServiceName);
1781 : : }
1782 : :
1783 : : uno::Sequence< OUString > SAL_CALL
1784 : 0 : SwXTextSection::getSupportedServiceNames() throw (uno::RuntimeException)
1785 : : {
1786 : : return ::sw::GetSupportedServiceNamesImpl(
1787 : : SAL_N_ELEMENTS(g_ServicesTextSection),
1788 : 0 : g_ServicesTextSection);
1789 : : }
1790 : :
1791 : : // MetadatableMixin
1792 : 132 : ::sfx2::Metadatable* SwXTextSection::GetCoreObject()
1793 : : {
1794 : 132 : SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
1795 [ + - ]: 132 : return pSectionFmt;
1796 : : }
1797 : :
1798 : 0 : uno::Reference<frame::XModel> SwXTextSection::GetModel()
1799 : : {
1800 : 0 : SwSectionFmt *const pSectionFmt( m_pImpl->GetSectionFmt() );
1801 [ # # ]: 0 : if (pSectionFmt)
1802 : : {
1803 : 0 : SwDocShell const*const pShell( pSectionFmt->GetDoc()->GetDocShell() );
1804 [ # # ]: 0 : return (pShell) ? pShell->GetModel() : 0;
1805 : : }
1806 : 0 : return 0;
1807 : : }
1808 : :
1809 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|