merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / unocore / unoredlines.cxx
blobe70935b55be145ecda1f255ba3f4012c276cf999
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoredlines.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <vos/mutex.hxx>
36 #include <vcl/svapp.hxx>
37 #include <unoredlines.hxx>
38 #include <unoredline.hxx>
39 #include <tools/debug.hxx>
40 #include <pagedesc.hxx>
41 #include "poolfmt.hxx"
42 #include <doc.hxx>
43 #include <docary.hxx>
44 #include <redline.hxx>
45 #include <com/sun/star/beans/XPropertySet.hpp>
47 using namespace ::com::sun::star;
48 using ::rtl::OUString;
50 /*-- 11.01.01 15:28:54---------------------------------------------------
52 -----------------------------------------------------------------------*/
53 SwXRedlines::SwXRedlines(SwDoc* _pDoc) :
54 SwUnoCollection(_pDoc)
57 /*-- 11.01.01 15:28:55---------------------------------------------------
59 -----------------------------------------------------------------------*/
60 SwXRedlines::~SwXRedlines()
63 /*-- 11.01.01 15:28:55---------------------------------------------------
65 -----------------------------------------------------------------------*/
66 sal_Int32 SwXRedlines::getCount( ) throw(uno::RuntimeException)
68 vos::OGuard aGuard(Application::GetSolarMutex());
69 if(!IsValid())
70 throw uno::RuntimeException();
71 const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
72 return rRedTbl.Count();
74 /*-- 11.01.01 15:28:55---------------------------------------------------
76 -----------------------------------------------------------------------*/
77 uno::Any SwXRedlines::getByIndex(sal_Int32 nIndex)
78 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
80 vos::OGuard aGuard(Application::GetSolarMutex());
81 if(!IsValid())
82 throw uno::RuntimeException();
83 const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
84 uno::Any aRet;
85 if(rRedTbl.Count() > nIndex && nIndex >= 0)
87 uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTbl.GetObject((USHORT)nIndex), *GetDoc() );
88 aRet <<= xRet;
90 else
91 throw lang::IndexOutOfBoundsException();
92 return aRet;
94 /*-- 11.01.01 15:28:55---------------------------------------------------
96 -----------------------------------------------------------------------*/
97 uno::Reference< container::XEnumeration > SwXRedlines::createEnumeration(void)
98 throw( uno::RuntimeException )
100 vos::OGuard aGuard(Application::GetSolarMutex());
101 if(!IsValid())
102 throw uno::RuntimeException();
103 return uno::Reference< container::XEnumeration >(new SwXRedlineEnumeration(*GetDoc()));
105 /*-- 11.01.01 15:28:55---------------------------------------------------
107 -----------------------------------------------------------------------*/
108 uno::Type SwXRedlines::getElementType( ) throw(uno::RuntimeException)
110 return ::getCppuType((uno::Reference<beans::XPropertySet>*)0);
112 /*-- 11.01.01 15:28:56---------------------------------------------------
114 -----------------------------------------------------------------------*/
115 sal_Bool SwXRedlines::hasElements( ) throw(uno::RuntimeException)
117 vos::OGuard aGuard(Application::GetSolarMutex());
118 if(!IsValid())
119 throw uno::RuntimeException();
120 const SwRedlineTbl& rRedTbl = GetDoc()->GetRedlineTbl();
121 return rRedTbl.Count() > 0;
123 /*-- 11.01.01 15:28:56---------------------------------------------------
125 -----------------------------------------------------------------------*/
126 OUString SwXRedlines::getImplementationName(void) throw( uno::RuntimeException )
128 return C2U("SwXRedlines");
130 /*-- 11.01.01 15:28:56---------------------------------------------------
132 -----------------------------------------------------------------------*/
133 BOOL SwXRedlines::supportsService(const rtl::OUString& /*ServiceName*/)
134 throw( uno::RuntimeException )
136 DBG_ERROR("not implemented");
137 return FALSE;
139 /*-- 11.01.01 15:28:57---------------------------------------------------
141 -----------------------------------------------------------------------*/
142 uno::Sequence< OUString > SwXRedlines::getSupportedServiceNames(void)
143 throw( uno::RuntimeException )
145 DBG_ERROR("not implemented");
146 return uno::Sequence< OUString >();
148 /*-- 11.01.01 15:28:57---------------------------------------------------
150 -----------------------------------------------------------------------*/
151 beans::XPropertySet* SwXRedlines::GetObject( SwRedline& rRedline, SwDoc& rDoc )
153 SwPageDesc* pStdDesc = rDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD);
154 SwClientIter aIter(*pStdDesc);
155 SwXRedline* pxRedline = (SwXRedline*)aIter.First( TYPE( SwXRedline ));
156 while(pxRedline)
158 if(pxRedline->GetRedline() == &rRedline)
159 break;
160 pxRedline = (SwXRedline*)aIter.Next();
162 if( !pxRedline )
163 pxRedline = new SwXRedline(rRedline, rDoc);
164 return pxRedline;
166 /*-- 12.01.01 15:06:10---------------------------------------------------
168 -----------------------------------------------------------------------*/
169 SwXRedlineEnumeration::SwXRedlineEnumeration(SwDoc& rDoc) :
170 pDoc(&rDoc),
171 nCurrentIndex(0)
173 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
175 /*-- 12.01.01 15:06:10---------------------------------------------------
177 -----------------------------------------------------------------------*/
178 SwXRedlineEnumeration::~SwXRedlineEnumeration()
181 /*-- 12.01.01 15:06:10---------------------------------------------------
183 -----------------------------------------------------------------------*/
184 BOOL SwXRedlineEnumeration::hasMoreElements(void) throw( uno::RuntimeException )
186 if(!pDoc)
187 throw uno::RuntimeException();
188 return pDoc->GetRedlineTbl().Count() > nCurrentIndex;
190 /*-- 12.01.01 15:06:10---------------------------------------------------
192 -----------------------------------------------------------------------*/
193 uno::Any SwXRedlineEnumeration::nextElement(void)
194 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
196 if(!pDoc)
197 throw uno::RuntimeException();
198 const SwRedlineTbl& rRedTbl = pDoc->GetRedlineTbl();
199 if(!(rRedTbl.Count() > nCurrentIndex))
200 throw container::NoSuchElementException();
201 uno::Reference <beans::XPropertySet> xRet = SwXRedlines::GetObject( *rRedTbl.GetObject(nCurrentIndex++), *pDoc );
202 uno::Any aRet;
203 aRet <<= xRet;
204 return aRet;
206 /*-- 12.01.01 15:06:10---------------------------------------------------
208 -----------------------------------------------------------------------*/
209 rtl::OUString SwXRedlineEnumeration::getImplementationName(void) throw( uno::RuntimeException )
211 return C2U("SwXRedlineEnumeration");
213 /*-- 12.01.01 15:06:10---------------------------------------------------
215 -----------------------------------------------------------------------*/
216 BOOL SwXRedlineEnumeration::supportsService(const rtl::OUString& /*ServiceName*/) throw( uno::RuntimeException )
218 return FALSE;
220 /*-- 12.01.01 15:06:11---------------------------------------------------
222 -----------------------------------------------------------------------*/
223 uno::Sequence< OUString > SwXRedlineEnumeration::getSupportedServiceNames(void) throw( uno::RuntimeException )
225 return uno::Sequence< OUString >();
227 /*-- 12.01.01 15:06:11---------------------------------------------------
229 -----------------------------------------------------------------------*/
230 void SwXRedlineEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
232 ClientModify(this, pOld, pNew);
233 if(!GetRegisteredIn())
234 pDoc = 0;