merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0514-field-patch-uno-fix.diff
blobefe06a199e5b3b965d7f92de7bce4e8730549694
1 diff --git sw/source/core/unocore/unocoll.cxx sw/source/core/unocore/unocoll.cxx
2 index abb24b5..f890609 100644
3 --- sw/source/core/unocore/unocoll.cxx
4 +++ sw/source/core/unocore/unocoll.cxx
5 @@ -1697,7 +1697,7 @@ sal_Int32 SwXBookmarks::getCount(void)
6 vos::OGuard aGuard(Application::GetSolarMutex());
7 if(!IsValid())
8 throw uno::RuntimeException();
9 - return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount();
10 + return GetDoc()->getIDocumentMarkAccess()->getMarksCount();
13 uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex)
14 @@ -1707,11 +1707,11 @@ uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex)
15 if(!IsValid())
16 throw uno::RuntimeException();
17 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
18 - if(nIndex < 0 || nIndex >= pMarkAccess->getBookmarksCount())
19 + if(nIndex < 0 || nIndex >= pMarkAccess->getMarksCount())
20 throw IndexOutOfBoundsException();
22 uno::Any aRet;
23 - ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get();
24 + ::sw::mark::IMark* pBkmk = pMarkAccess->getMarksBegin()[nIndex].get();
25 uno::Reference< XTextContent > xRef = GetObject(*pBkmk, GetDoc());
26 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
27 return aRet;
28 @@ -1725,8 +1725,8 @@ uno::Any SwXBookmarks::getByName(const rtl::OUString& rName)
29 throw uno::RuntimeException();
31 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
32 - IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findBookmark(rName);
33 - if(ppBkmk == pMarkAccess->getBookmarksEnd())
34 + IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark(rName);
35 + if(ppBkmk == pMarkAccess->getMarksEnd())
36 throw NoSuchElementException();
38 uno::Any aRet;
39 @@ -1743,10 +1743,10 @@ uno::Sequence< OUString > SwXBookmarks::getElementNames(void)
40 throw uno::RuntimeException();
42 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
43 - uno::Sequence<OUString> aSeq(pMarkAccess->getBookmarksCount());
44 + uno::Sequence<OUString> aSeq(pMarkAccess->getMarksCount());
45 sal_Int32 nCnt = 0;
46 - for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin();
47 - ppMark != pMarkAccess->getBookmarksEnd();)
48 + for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
49 + ppMark != pMarkAccess->getMarksEnd();)
50 aSeq[nCnt++] = (*ppMark++)->GetName();
51 return aSeq;
53 @@ -1759,7 +1759,7 @@ sal_Bool SwXBookmarks::hasByName(const OUString& rName)
54 throw uno::RuntimeException();
56 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
57 - return pMarkAccess->findBookmark(rName) != pMarkAccess->getBookmarksEnd();
58 + return pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd();
61 uno::Type SAL_CALL SwXBookmarks::getElementType()
62 @@ -1784,16 +1784,18 @@ SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc)
63 if(!pXBkmk)
65 // FIXME: These belong in XTextFieldsSupplier
66 - //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk))
67 - // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc);
68 - //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk))
69 - // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc);
70 - //else
71 - OSL_ENSURE(
72 - dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk),
73 - "<SwXBookmark::GetObject(..)>"
74 - "SwXBookmark requested for non-bookmark mark.");
75 - pXBkmk = new SwXBookmark(&rBkmk, pDoc);
76 + if (dynamic_cast< ::sw::mark::ICheckboxFieldmark* >(&rBkmk))
77 + pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc);
78 + else if (dynamic_cast< ::sw::mark::IFieldmark* >(&rBkmk))
79 + pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc);
80 + else
81 + {
82 + OSL_ENSURE(
83 + dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk),
84 + "<SwXBookmark::GetObject(..)>"
85 + "SwXBookmark requested for non-bookmark mark.");
86 + pXBkmk = new SwXBookmark(&rBkmk, pDoc);
87 + }
89 return pXBkmk;