merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / unocore / unocoll.cxx
bloba8eb936804b651f12bce7a9401d71f5c6e6047a5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unocoll.cxx,v $
10 * $Revision: 1.41 $
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 <swtypes.hxx>
36 #include <cmdid.h>
37 #include <hintids.hxx>
38 #ifndef _SVX_SVXIDS_HRC //autogen
39 #include <svx/svxids.hrc>
40 #endif
41 #include <doc.hxx>
42 #include <docary.hxx>
43 #include <fmtcol.hxx>
44 #include <poolfmt.hxx>
45 #include <unocoll.hxx>
46 #include <unosett.hxx>
47 #include <unoclbck.hxx>
48 #include <fmtanchr.hxx>
49 #include <ndtxt.hxx>
50 #include <section.hxx>
51 #include <IMark.hxx>
52 #include <ftnidx.hxx>
53 #include <fmtftn.hxx>
54 #include <txtftn.hxx>
55 #include <fmtpdsc.hxx>
56 #include <pagedesc.hxx>
57 #include <vos/mutex.hxx>
58 #include <com/sun/star/text/XTextTableCursor.hpp>
59 #include <com/sun/star/text/XTextTablesSupplier.hpp>
60 #include <com/sun/star/text/TableColumnSeparator.hpp>
61 #include <com/sun/star/text/XTextTable.hpp>
62 #include <svtools/PasswordHelper.hxx>
63 #include <svtools/unoimap.hxx>
64 #include <svtools/unoevent.hxx>
65 #include <unotbl.hxx>
66 #include <unostyle.hxx>
67 #include <unofield.hxx>
68 #include <unoidx.hxx>
69 #include <unoframe.hxx>
70 #include <vcl/svapp.hxx>
71 #include <authfld.hxx>
72 #include <SwXTextDefaults.hxx>
73 #include <unochart.hxx>
74 #include <comphelper/makesequence.hxx>
75 #include <comphelper/sequence.hxx>
76 #include <slist>
77 #include <iterator>
79 #include "unometa.hxx"
80 #include "docsh.hxx"
81 #include <com/sun/star/document/XCodeNameQuery.hpp>
82 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
83 #include <com/sun/star/form/XFormsSupplier.hpp>
84 #include <com/sun/star/script/ModuleInfo.hpp>
85 #include <com/sun/star/script/ModuleType.hpp>
86 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
87 #include <vbahelper/vbahelper.hxx>
88 #include <basic/basmgr.hxx>
90 using ::rtl::OUString;
91 using namespace ::com::sun::star;
92 using namespace ::com::sun::star::document;
93 using namespace ::com::sun::star::uno;
94 using namespace ::com::sun::star::text;
95 using namespace ::com::sun::star::container;
96 using namespace ::com::sun::star::lang;
98 class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
100 SwDocShell* mpDocShell;
101 rtl::OUString msThisDocumentCodeName;
102 public:
103 SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
104 // XCodeNameQuery
105 rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
107 // Initialise the code name
108 if ( msThisDocumentCodeName.getLength() == 0 )
112 uno::Reference< beans::XPropertySet > xProps( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
113 uno::Reference< container::XNameAccess > xLibContainer( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW );
114 rtl::OUString sProjectName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) );
115 if ( mpDocShell->GetBasicManager()->GetName().Len() )
116 sProjectName = mpDocShell->GetBasicManager()->GetName();
118 uno::Reference< container::XNameAccess > xStandard( xLibContainer->getByName( sProjectName ), uno::UNO_QUERY_THROW );
119 uno::Sequence< rtl::OUString > sModuleNames = xStandard->getElementNames();
120 for ( sal_Int32 i=0; i < sModuleNames.getLength(); ++i )
122 script::ModuleInfo mInfo;
123 if ( xStandard->getByName( sModuleNames[ i ] ) >>= mInfo )
125 if ( mInfo.ModuleType == script::ModuleType::Document )
127 msThisDocumentCodeName = sModuleNames[ i ];
128 break;
133 catch( uno::Exception& )
137 rtl::OUString sCodeName;
138 if ( mpDocShell )
140 OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
141 // need to find the page ( and index ) for this control
142 uno::Reference< drawing::XDrawPageSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
143 uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
144 sal_Int32 nLen = xIndex->getCount();
145 bool bMatched = false;
146 uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
149 uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex, uno::UNO_QUERY_THROW );
150 uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
151 // get the www-standard container
152 uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
153 sal_Int32 nCntrls = xFormControls->getCount();
154 for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
156 uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
157 bMatched = ( xControl == xIf );
158 if ( bMatched )
160 sCodeName = msThisDocumentCodeName;
161 break;
165 catch( uno::Exception& ) {}
167 // Probably should throw here ( if !bMatched )
168 return sCodeName;
172 typedef std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash > StringHashMap;
173 class SwVbaProjectNameProvider : public ::cppu::WeakImplHelper1< container::XNameContainer >
175 SwDocShell* mpDocShell;
176 StringHashMap mTemplateToProject;
177 public:
178 SwVbaProjectNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell )
181 virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
183 return ( mTemplateToProject.find( aName ) != mTemplateToProject.end() );
185 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
187 if ( !hasByName( aName ) )
188 throw container::NoSuchElementException();
189 return uno::makeAny( mTemplateToProject.find( aName )->second );
191 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException)
193 uno::Sequence< rtl::OUString > aElements( mTemplateToProject.size() );
194 StringHashMap::iterator it_end = mTemplateToProject.end();
195 sal_Int32 index = 0;
196 for ( StringHashMap::iterator it = mTemplateToProject.begin(); it != it_end; ++it, ++index )
197 aElements[ index ] = it->first;
198 return aElements;
201 virtual void SAL_CALL insertByName( const rtl::OUString& aName, const uno::Any& aElement ) throw ( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException, com::sun::star::lang::WrappedTargetException )
204 rtl::OUString sProjectName;
205 aElement >>= sProjectName;
206 OSL_TRACE("** Template cache inserting template name %s with project %s"
207 , rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr()
208 , rtl::OUStringToOString( sProjectName, RTL_TEXTENCODING_UTF8 ).getStr() );
209 mTemplateToProject[ aName ] = sProjectName;
212 virtual void SAL_CALL removeByName( const rtl::OUString& Name ) throw ( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException )
214 if ( !hasByName( Name ) )
215 throw container::NoSuchElementException();
216 mTemplateToProject.erase( Name );
218 virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const uno::Any& aElement ) throw ( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException )
220 if ( !hasByName( aName ) )
221 throw container::NoSuchElementException();
222 insertByName( aName, aElement ); // insert will overwrite
224 // XElemenAccess
225 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException)
227 return ::getCppuType((const rtl::OUString*)0);
229 virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException )
232 return ( mTemplateToProject.size() > 0 );
237 class SwVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
239 SwDocShell* mpDocShell;
240 public:
241 SwVbaObjectForCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell )
243 // #FIXME #TODO is the code name for ThisDocument read anywhere?
246 virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
248 // #FIXME #TODO we really need to be checking against the codename for
249 // ThisDocument
250 if ( aName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisDocument" ) ) ) )
251 return sal_True;
252 return sal_False;
254 ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
256 if ( !hasByName( aName ) )
257 throw container::NoSuchElementException();
258 uno::Sequence< uno::Any > aArgs( 2 );
259 aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
260 aArgs[1] = uno::Any( mpDocShell->GetModel() );
261 uno::Reference< uno::XInterface > xDocObj = ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.word.Document" , aArgs );
262 OSL_TRACE("Creating Object ( ooo.vba.word.Document ) 0x%x", xDocObj.get() );
263 return uno::makeAny( xDocObj );
265 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException)
267 uno::Sequence< rtl::OUString > aNames;
268 return aNames;
270 // XElemenAccess
271 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
272 virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; }
276 /******************************************************************************
278 ******************************************************************************/
279 struct ProvNamesId_Type
281 const char * pName;
282 sal_uInt16 nType;
285 // note: this thing is indexed as an array, so do not insert/remove entries!
286 const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
288 { "com.sun.star.text.TextTable", SW_SERVICE_TYPE_TEXTTABLE },
289 { "com.sun.star.text.TextFrame", SW_SERVICE_TYPE_TEXTFRAME },
290 { "com.sun.star.text.GraphicObject", SW_SERVICE_TYPE_GRAPHIC },
291 { "com.sun.star.text.TextEmbeddedObject", SW_SERVICE_TYPE_OLE },
292 { "com.sun.star.text.Bookmark", SW_SERVICE_TYPE_BOOKMARK },
293 { "com.sun.star.text.Footnote", SW_SERVICE_TYPE_FOOTNOTE },
294 { "com.sun.star.text.Endnote", SW_SERVICE_TYPE_ENDNOTE },
295 { "com.sun.star.text.DocumentIndexMark", SW_SERVICE_TYPE_INDEXMARK },
296 { "com.sun.star.text.DocumentIndex", SW_SERVICE_TYPE_INDEX },
297 { "com.sun.star.text.ReferenceMark", SW_SERVICE_REFERENCE_MARK },
298 { "com.sun.star.style.CharacterStyle", SW_SERVICE_STYLE_CHARACTER_STYLE },
299 { "com.sun.star.style.ParagraphStyle", SW_SERVICE_STYLE_PARAGRAPH_STYLE },
300 { "com.sun.star.style.FrameStyle", SW_SERVICE_STYLE_FRAME_STYLE },
301 { "com.sun.star.style.PageStyle", SW_SERVICE_STYLE_PAGE_STYLE },
302 { "com.sun.star.style.NumberingStyle", SW_SERVICE_STYLE_NUMBERING_STYLE },
303 { "com.sun.star.text.ContentIndexMark", SW_SERVICE_CONTENT_INDEX_MARK },
304 { "com.sun.star.text.ContentIndex", SW_SERVICE_CONTENT_INDEX },
305 { "com.sun.star.text.UserIndexMark", SW_SERVICE_USER_INDEX_MARK },
306 { "com.sun.star.text.UserIndex", SW_SERVICE_USER_INDEX },
307 { "com.sun.star.text.TextSection", SW_SERVICE_TEXT_SECTION },
308 { "com.sun.star.text.TextField.DateTime", SW_SERVICE_FIELDTYPE_DATETIME },
309 { "com.sun.star.text.TextField.User", SW_SERVICE_FIELDTYPE_USER },
310 { "com.sun.star.text.TextField.SetExpression", SW_SERVICE_FIELDTYPE_SET_EXP },
311 { "com.sun.star.text.TextField.GetExpression", SW_SERVICE_FIELDTYPE_GET_EXP },
312 { "com.sun.star.text.TextField.FileName", SW_SERVICE_FIELDTYPE_FILE_NAME },
313 { "com.sun.star.text.TextField.PageNumber", SW_SERVICE_FIELDTYPE_PAGE_NUM },
314 { "com.sun.star.text.TextField.Author", SW_SERVICE_FIELDTYPE_AUTHOR },
315 { "com.sun.star.text.TextField.Chapter", SW_SERVICE_FIELDTYPE_CHAPTER },
316 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
317 { "com.sun.star.text.TextField.GetReference", SW_SERVICE_FIELDTYPE_GET_REFERENCE },
318 { "com.sun.star.text.TextField.ConditionalText", SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
319 { "com.sun.star.text.TextField.Annotation", SW_SERVICE_FIELDTYPE_ANNOTATION },
320 { "com.sun.star.text.TextField.Input", SW_SERVICE_FIELDTYPE_INPUT },
321 { "com.sun.star.text.TextField.Macro", SW_SERVICE_FIELDTYPE_MACRO },
322 { "com.sun.star.text.TextField.DDE", SW_SERVICE_FIELDTYPE_DDE },
323 { "com.sun.star.text.TextField.HiddenParagraph", SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
324 { "" /*com.sun.star.text.TextField.DocumentInfo"*/, SW_SERVICE_FIELDTYPE_DOC_INFO },
325 { "com.sun.star.text.TextField.TemplateName", SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
326 { "com.sun.star.text.TextField.ExtendedUser", SW_SERVICE_FIELDTYPE_USER_EXT },
327 { "com.sun.star.text.TextField.ReferencePageSet", SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
328 { "com.sun.star.text.TextField.ReferencePageGet", SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
329 { "com.sun.star.text.TextField.JumpEdit", SW_SERVICE_FIELDTYPE_JUMP_EDIT },
330 { "com.sun.star.text.TextField.Script", SW_SERVICE_FIELDTYPE_SCRIPT },
331 { "com.sun.star.text.TextField.DatabaseNextSet", SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
332 { "com.sun.star.text.TextField.DatabaseNumberOfSet", SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
333 { "com.sun.star.text.TextField.DatabaseSetNumber", SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
334 { "com.sun.star.text.TextField.Database", SW_SERVICE_FIELDTYPE_DATABASE },
335 { "com.sun.star.text.TextField.DatabaseName", SW_SERVICE_FIELDTYPE_DATABASE_NAME },
336 { "com.sun.star.text.TextField.TableFormula", SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
337 { "com.sun.star.text.TextField.PageCount", SW_SERVICE_FIELDTYPE_PAGE_COUNT },
338 { "com.sun.star.text.TextField.ParagraphCount", SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
339 { "com.sun.star.text.TextField.WordCount", SW_SERVICE_FIELDTYPE_WORD_COUNT },
340 { "com.sun.star.text.TextField.CharacterCount", SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
341 { "com.sun.star.text.TextField.TableCount", SW_SERVICE_FIELDTYPE_TABLE_COUNT },
342 { "com.sun.star.text.TextField.GraphicObjectCount", SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
343 { "com.sun.star.text.TextField.EmbeddedObjectCount", SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
344 { "com.sun.star.text.TextField.DocInfo.ChangeAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
345 { "com.sun.star.text.TextField.DocInfo.ChangeDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
346 { "com.sun.star.text.TextField.DocInfo.EditTime", SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
347 { "com.sun.star.text.TextField.DocInfo.Description", SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
348 { "com.sun.star.text.TextField.DocInfo.CreateAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
349 { "com.sun.star.text.TextField.DocInfo.CreateDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
350 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
351 { "", SW_SERVICE_FIELDTYPE_DUMMY_1 },
352 { "", SW_SERVICE_FIELDTYPE_DUMMY_2 },
353 { "", SW_SERVICE_FIELDTYPE_DUMMY_3 },
354 { "com.sun.star.text.TextField.DocInfo.Custom", SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
355 { "com.sun.star.text.TextField.DocInfo.PrintAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
356 { "com.sun.star.text.TextField.DocInfo.PrintDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
357 { "com.sun.star.text.TextField.DocInfo.KeyWords", SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
358 { "com.sun.star.text.TextField.DocInfo.Subject", SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
359 { "com.sun.star.text.TextField.DocInfo.Title", SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
360 { "com.sun.star.text.TextField.DocInfo.Revision", SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
361 { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
362 { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
363 { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN },
364 { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD },
365 { "", SW_SERVICE_FIELDTYPE_DUMMY_4 },
366 { "", SW_SERVICE_FIELDTYPE_DUMMY_5 },
367 { "", SW_SERVICE_FIELDTYPE_DUMMY_6 },
368 { "", SW_SERVICE_FIELDTYPE_DUMMY_7 },
369 { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER },
370 { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE },
371 { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP },
372 { "com.sun.star.text.FieldMaster.Database", SW_SERVICE_FIELDMASTER_DATABASE },
373 { "com.sun.star.text.FieldMaster.Bibliography", SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY },
374 { "", SW_SERVICE_FIELDMASTER_DUMMY2 },
375 { "", SW_SERVICE_FIELDMASTER_DUMMY3 },
376 { "", SW_SERVICE_FIELDMASTER_DUMMY4 },
377 { "", SW_SERVICE_FIELDMASTER_DUMMY5 },
378 { "com.sun.star.text.IllustrationsIndex", SW_SERVICE_INDEX_ILLUSTRATIONS },
379 { "com.sun.star.text.ObjectIndex", SW_SERVICE_INDEX_OBJECTS },
380 { "com.sun.star.text.TableIndex", SW_SERVICE_INDEX_TABLES },
381 { "com.sun.star.text.Bibliography", SW_SERVICE_INDEX_BIBLIOGRAPHY },
382 { "com.sun.star.text.Paragraph", SW_SERVICE_PARAGRAPH },
383 { "com.sun.star.text.TextField.InputUser", SW_SERVICE_FIELDTYPE_INPUT_USER },
384 { "com.sun.star.text.TextField.HiddenText", SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
385 { "com.sun.star.style.ConditionalParagraphStyle", SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE },
386 { "com.sun.star.text.NumberingRules", SW_SERVICE_NUMBERING_RULES },
387 { "com.sun.star.text.TextColumns", SW_SERVICE_TEXT_COLUMNS },
388 { "com.sun.star.text.IndexHeaderSection", SW_SERVICE_INDEX_HEADER_SECTION },
389 { "com.sun.star.text.Defaults", SW_SERVICE_DEFAULTS },
390 { "com.sun.star.image.ImageMapRectangleObject", SW_SERVICE_IMAP_RECTANGLE },
391 { "com.sun.star.image.ImageMapCircleObject", SW_SERVICE_IMAP_CIRCLE },
392 { "com.sun.star.image.ImageMapPolygonObject", SW_SERVICE_IMAP_POLYGON },
393 { "com.sun.star.text.TextGraphicObject", SW_SERVICE_TYPE_TEXT_GRAPHIC },
394 { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER },
395 { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK },
396 { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK },
397 { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META },
398 { "ooo.vba.VBAObjectModuleObjectProvider", SW_SERVICE_VBAOBJECTPROVIDER },
399 { "ooo.vba.VBACodeNameProvider", SW_SERVICE_VBACODENAMEPROVIDER },
400 { "ooo.vba.VBAProjectNameProvider", SW_SERVICE_VBAPROJECTNAMEPROVIDER },
402 // case-correct versions of the service names (see #i67811)
403 { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME },
404 { CSS_TEXT_TEXTFIELD_USER, SW_SERVICE_FIELDTYPE_USER },
405 { CSS_TEXT_TEXTFIELD_SET_EXPRESSION, SW_SERVICE_FIELDTYPE_SET_EXP },
406 { CSS_TEXT_TEXTFIELD_GET_EXPRESSION, SW_SERVICE_FIELDTYPE_GET_EXP },
407 { CSS_TEXT_TEXTFIELD_FILE_NAME, SW_SERVICE_FIELDTYPE_FILE_NAME },
408 { CSS_TEXT_TEXTFIELD_PAGE_NUMBER, SW_SERVICE_FIELDTYPE_PAGE_NUM },
409 { CSS_TEXT_TEXTFIELD_AUTHOR, SW_SERVICE_FIELDTYPE_AUTHOR },
410 { CSS_TEXT_TEXTFIELD_CHAPTER, SW_SERVICE_FIELDTYPE_CHAPTER },
411 { CSS_TEXT_TEXTFIELD_GET_REFERENCE, SW_SERVICE_FIELDTYPE_GET_REFERENCE },
412 { CSS_TEXT_TEXTFIELD_CONDITIONAL_TEXT, SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
413 { CSS_TEXT_TEXTFIELD_ANNOTATION, SW_SERVICE_FIELDTYPE_ANNOTATION },
414 { CSS_TEXT_TEXTFIELD_INPUT, SW_SERVICE_FIELDTYPE_INPUT },
415 { CSS_TEXT_TEXTFIELD_MACRO, SW_SERVICE_FIELDTYPE_MACRO },
416 { CSS_TEXT_TEXTFIELD_DDE, SW_SERVICE_FIELDTYPE_DDE },
417 { CSS_TEXT_TEXTFIELD_HIDDEN_PARAGRAPH, SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
418 { CSS_TEXT_TEXTFIELD_TEMPLATE_NAME, SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
419 { CSS_TEXT_TEXTFIELD_EXTENDED_USER, SW_SERVICE_FIELDTYPE_USER_EXT },
420 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_SET, SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
421 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_GET, SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
422 { CSS_TEXT_TEXTFIELD_JUMP_EDIT, SW_SERVICE_FIELDTYPE_JUMP_EDIT },
423 { CSS_TEXT_TEXTFIELD_SCRIPT, SW_SERVICE_FIELDTYPE_SCRIPT },
424 { CSS_TEXT_TEXTFIELD_DATABASE_NEXT_SET, SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
425 { CSS_TEXT_TEXTFIELD_DATABASE_NUMBER_OF_SET, SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
426 { CSS_TEXT_TEXTFIELD_DATABASE_SET_NUMBER, SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
427 { CSS_TEXT_TEXTFIELD_DATABASE, SW_SERVICE_FIELDTYPE_DATABASE },
428 { CSS_TEXT_TEXTFIELD_DATABASE_NAME, SW_SERVICE_FIELDTYPE_DATABASE_NAME },
429 { CSS_TEXT_TEXTFIELD_TABLE_FORMULA, SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
430 { CSS_TEXT_TEXTFIELD_PAGE_COUNT, SW_SERVICE_FIELDTYPE_PAGE_COUNT },
431 { CSS_TEXT_TEXTFIELD_PARAGRAPH_COUNT, SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
432 { CSS_TEXT_TEXTFIELD_WORD_COUNT, SW_SERVICE_FIELDTYPE_WORD_COUNT },
433 { CSS_TEXT_TEXTFIELD_CHARACTER_COUNT, SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
434 { CSS_TEXT_TEXTFIELD_TABLE_COUNT, SW_SERVICE_FIELDTYPE_TABLE_COUNT },
435 { CSS_TEXT_TEXTFIELD_GRAPHIC_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
436 { CSS_TEXT_TEXTFIELD_EMBEDDED_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
437 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
438 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
439 { CSS_TEXT_TEXTFIELD_DOCINFO_EDIT_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
440 { CSS_TEXT_TEXTFIELD_DOCINFO_DESCRIPTION, SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
441 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
442 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
443 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
444 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
445 { CSS_TEXT_TEXTFIELD_DOCINFO_KEY_WORDS, SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
446 { CSS_TEXT_TEXTFIELD_DOCINFO_SUBJECT, SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
447 { CSS_TEXT_TEXTFIELD_DOCINFO_TITLE, SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
448 { CSS_TEXT_TEXTFIELD_DOCINFO_REVISION, SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
449 { CSS_TEXT_TEXTFIELD_DOCINFO_CUSTOM, SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
450 { CSS_TEXT_TEXTFIELD_BIBLIOGRAPHY, SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
451 { CSS_TEXT_TEXTFIELD_COMBINED_CHARACTERS, SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
452 { CSS_TEXT_TEXTFIELD_DROP_DOWN, SW_SERVICE_FIELDTYPE_DROPDOWN },
453 { CSS_TEXT_TEXTFIELD_INPUT_USER, SW_SERVICE_FIELDTYPE_INPUT_USER },
454 { CSS_TEXT_TEXTFIELD_HIDDEN_TEXT, SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
455 { CSS_TEXT_FIELDMASTER_USER, SW_SERVICE_FIELDMASTER_USER },
456 { CSS_TEXT_FIELDMASTER_DDE, SW_SERVICE_FIELDMASTER_DDE },
457 { CSS_TEXT_FIELDMASTER_SET_EXPRESSION, SW_SERVICE_FIELDMASTER_SET_EXP },
458 { CSS_TEXT_FIELDMASTER_DATABASE, SW_SERVICE_FIELDMASTER_DATABASE },
459 { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY, SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY }
462 /* -----------------------------23.03.01 13:38--------------------------------
464 ---------------------------------------------------------------------------*/
465 const SvEventDescription* lcl_GetSupportedMacroItems()
467 static const SvEventDescription aMacroDescriptionsImpl[] =
469 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
470 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
471 { 0, NULL }
474 return aMacroDescriptionsImpl;
477 /******************************************************************
478 * SwXServiceProvider
479 ******************************************************************/
480 /*-- 13.01.99 13:31:44---------------------------------------------------
482 -----------------------------------------------------------------------*/
483 OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType)
485 vos::OGuard aGuard(Application::GetSolarMutex());
486 OUString sRet;
487 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
488 if(nObjectType < nEntries)
489 sRet = C2U(aProvNamesId[nObjectType].pName);
490 return sRet;
492 /* -----------------11.03.99 12:05-------------------
494 * --------------------------------------------------*/
495 uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames()
497 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
498 uno::Sequence<OUString> aRet(nEntries);
499 OUString* pArray = aRet.getArray();
500 sal_uInt16 n = 0;
501 for(sal_uInt16 i = 0; i < nEntries; i++)
503 String sProv(C2U(aProvNamesId[i].pName));
504 if(sProv.Len())
506 pArray[n] = sProv;
507 n++;
510 aRet.realloc(n);
511 return aRet;
515 /*-- 13.01.99 13:31:45---------------------------------------------------
517 -----------------------------------------------------------------------*/
518 sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName)
520 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
521 for(sal_uInt16 i = 0; i < nEntries; i++ )
523 if( COMPARE_EQUAL == rServiceName.compareToAscii(aProvNamesId[i].pName))
524 return aProvNamesId[i].nType;
526 return SW_SERVICE_INVALID;
528 /* -----------------13.01.99 14:37-------------------
530 * --------------------------------------------------*/
531 uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc* pDoc)
533 vos::OGuard aGuard(Application::GetSolarMutex());
534 uno::Reference< uno::XInterface > xRet;
535 switch(nObjectType)
537 case SW_SERVICE_TYPE_TEXTTABLE:
539 SwXTextTable* pTextTable = new SwXTextTable();
540 xRet = (cppu::OWeakObject*)pTextTable;
542 break;
543 case SW_SERVICE_TYPE_TEXTFRAME:
545 SwXTextFrame* pTextFrame = new SwXTextFrame( pDoc );
546 xRet = (cppu::OWeakObject*)(SwXFrame*)pTextFrame;
548 break;
549 case SW_SERVICE_TYPE_GRAPHIC :
550 case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ :
552 SwXTextGraphicObject* pGraphic = new SwXTextGraphicObject( pDoc );
553 xRet = (cppu::OWeakObject*)(SwXFrame*)pGraphic;
556 break;
557 case SW_SERVICE_TYPE_OLE :
559 SwXTextEmbeddedObject* pOle = new SwXTextEmbeddedObject( pDoc );
560 xRet = (cppu::OWeakObject*)(SwXFrame*)pOle;
562 break;
563 case SW_SERVICE_TYPE_BOOKMARK :
565 SwXBookmark* pBookmark = new SwXBookmark;
566 xRet = (cppu::OWeakObject*)pBookmark;
568 break;
569 case SW_SERVICE_TYPE_FIELDMARK :
571 SwXFieldmark* pFieldmark = new SwXFieldmark(false);
572 xRet = (cppu::OWeakObject*)pFieldmark;
574 break;
575 case SW_SERVICE_TYPE_FORMFIELDMARK :
577 SwXFieldmark* pFieldmark = new SwXFieldmark(true);
578 xRet = (cppu::OWeakObject*)pFieldmark;
580 break;
581 case SW_SERVICE_VBAOBJECTPROVIDER :
583 SwVbaObjectForCodeNameProvider* pObjProv = new SwVbaObjectForCodeNameProvider( pDoc->GetDocShell() );
584 xRet = (cppu::OWeakObject*)pObjProv;
586 break;
587 case SW_SERVICE_VBACODENAMEPROVIDER :
589 SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider( pDoc->GetDocShell() );
590 xRet = (cppu::OWeakObject*)pObjProv;
592 break;
593 case SW_SERVICE_VBAPROJECTNAMEPROVIDER :
595 uno::Reference< container::XNameContainer > xProjProv = pDoc->GetVBATemplateToProjectCache();
596 if ( !xProjProv.is() )
598 xProjProv = new SwVbaProjectNameProvider( pDoc->GetDocShell() );
599 pDoc->SetVBATemplateToProjectCache( xProjProv );
601 //xRet = (cppu::OWeakObject*)xProjProv;
602 xRet = xProjProv;
604 break;
605 case SW_SERVICE_TYPE_FOOTNOTE :
606 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_False);
607 break;
608 case SW_SERVICE_TYPE_ENDNOTE :
609 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_True);
610 break;
611 case SW_SERVICE_CONTENT_INDEX_MARK :
612 case SW_SERVICE_USER_INDEX_MARK :
613 case SW_SERVICE_TYPE_INDEXMARK:
615 TOXTypes eType = TOX_INDEX;
616 if(SW_SERVICE_CONTENT_INDEX_MARK== nObjectType)
617 eType = TOX_CONTENT;
618 else if(SW_SERVICE_USER_INDEX_MARK == nObjectType)
619 eType = TOX_USER;
620 xRet = (cppu::OWeakObject*)new SwXDocumentIndexMark(eType);
622 break;
623 case SW_SERVICE_CONTENT_INDEX :
624 case SW_SERVICE_USER_INDEX :
625 case SW_SERVICE_TYPE_INDEX :
626 case SW_SERVICE_INDEX_ILLUSTRATIONS:
627 case SW_SERVICE_INDEX_OBJECTS :
628 case SW_SERVICE_INDEX_TABLES:
629 case SW_SERVICE_INDEX_BIBLIOGRAPHY :
631 TOXTypes eType = TOX_INDEX;
632 if(SW_SERVICE_CONTENT_INDEX == nObjectType)
633 eType = TOX_CONTENT;
634 else if(SW_SERVICE_USER_INDEX == nObjectType)
635 eType = TOX_USER;
636 else if(SW_SERVICE_INDEX_ILLUSTRATIONS == nObjectType)
638 eType = TOX_ILLUSTRATIONS;
640 else if(SW_SERVICE_INDEX_OBJECTS == nObjectType)
642 eType = TOX_OBJECTS;
644 else if(SW_SERVICE_INDEX_BIBLIOGRAPHY == nObjectType)
646 eType = TOX_AUTHORITIES;
648 else if(SW_SERVICE_INDEX_TABLES == nObjectType)
650 eType = TOX_TABLES;
652 xRet = (cppu::OWeakObject*)new SwXDocumentIndex(eType, *pDoc);
654 break;
655 case SW_SERVICE_INDEX_HEADER_SECTION :
656 case SW_SERVICE_TEXT_SECTION :
657 xRet = SwXTextSectionClient::CreateXTextSection( 0, SW_SERVICE_INDEX_HEADER_SECTION == nObjectType);
659 break;
660 case SW_SERVICE_REFERENCE_MARK :
661 xRet = (cppu::OWeakObject*)new SwXReferenceMark(0, 0);
662 break;
663 case SW_SERVICE_STYLE_CHARACTER_STYLE:
664 case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
665 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
666 case SW_SERVICE_STYLE_FRAME_STYLE:
667 case SW_SERVICE_STYLE_PAGE_STYLE:
668 case SW_SERVICE_STYLE_NUMBERING_STYLE:
670 SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR;
671 switch(nObjectType)
673 case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
674 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
675 eFamily = SFX_STYLE_FAMILY_PARA;
676 break;
677 case SW_SERVICE_STYLE_FRAME_STYLE:
678 eFamily = SFX_STYLE_FAMILY_FRAME;
679 break;
680 case SW_SERVICE_STYLE_PAGE_STYLE:
681 eFamily = SFX_STYLE_FAMILY_PAGE;
682 break;
683 case SW_SERVICE_STYLE_NUMBERING_STYLE:
684 eFamily = SFX_STYLE_FAMILY_PSEUDO;
685 break;
687 SwXStyle* pNewStyle = SFX_STYLE_FAMILY_PAGE == eFamily ?
688 new SwXPageStyle(pDoc->GetDocShell()) :
689 eFamily == SFX_STYLE_FAMILY_FRAME ?
690 new SwXFrameStyle ( pDoc ):
691 new SwXStyle( pDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE);
692 xRet = (cppu::OWeakObject*)pNewStyle;
694 break;
695 // SW_SERVICE_DUMMY_5
696 // SW_SERVICE_DUMMY_6
697 // SW_SERVICE_DUMMY_7
698 // SW_SERVICE_DUMMY_8
699 // SW_SERVICE_DUMMY_9
700 case SW_SERVICE_FIELDTYPE_DATETIME:
701 case SW_SERVICE_FIELDTYPE_USER:
702 case SW_SERVICE_FIELDTYPE_SET_EXP:
703 case SW_SERVICE_FIELDTYPE_GET_EXP:
704 case SW_SERVICE_FIELDTYPE_FILE_NAME:
705 case SW_SERVICE_FIELDTYPE_PAGE_NUM:
706 case SW_SERVICE_FIELDTYPE_AUTHOR:
707 case SW_SERVICE_FIELDTYPE_CHAPTER:
708 case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
709 case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
710 case SW_SERVICE_FIELDTYPE_INPUT:
711 case SW_SERVICE_FIELDTYPE_MACRO:
712 case SW_SERVICE_FIELDTYPE_DDE:
713 case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
714 case SW_SERVICE_FIELDTYPE_DOC_INFO:
715 case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
716 case SW_SERVICE_FIELDTYPE_USER_EXT:
717 case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
718 case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
719 case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
720 case SW_SERVICE_FIELDTYPE_SCRIPT:
721 case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET:
722 case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET:
723 case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM:
724 case SW_SERVICE_FIELDTYPE_DATABASE:
725 case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
726 case SW_SERVICE_FIELDTYPE_PAGE_COUNT :
727 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT :
728 case SW_SERVICE_FIELDTYPE_WORD_COUNT :
729 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT :
730 case SW_SERVICE_FIELDTYPE_TABLE_COUNT :
731 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT :
732 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT :
733 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR :
734 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME :
735 case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME :
736 case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION :
737 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR :
738 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME :
739 case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM :
740 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR :
741 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME :
742 case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS :
743 case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT :
744 case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE :
745 case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
746 case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY:
747 case SW_SERVICE_FIELDTYPE_INPUT_USER :
748 case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT :
749 case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS :
750 case SW_SERVICE_FIELDTYPE_DROPDOWN :
751 case SW_SERVICE_FIELDTYPE_TABLE_FORMULA:
752 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType);
753 break;
754 case SW_SERVICE_FIELDTYPE_ANNOTATION:
755 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType, pDoc);
756 break;
757 case SW_SERVICE_FIELDMASTER_USER:
758 case SW_SERVICE_FIELDMASTER_DDE:
759 case SW_SERVICE_FIELDMASTER_SET_EXP :
760 case SW_SERVICE_FIELDMASTER_DATABASE:
762 sal_uInt16 nResId = USHRT_MAX;
763 switch(nObjectType)
765 case SW_SERVICE_FIELDMASTER_USER: nResId = RES_USERFLD; break;
766 case SW_SERVICE_FIELDMASTER_DDE: nResId = RES_DDEFLD; break;
767 case SW_SERVICE_FIELDMASTER_SET_EXP : nResId = RES_SETEXPFLD; break;
768 case SW_SERVICE_FIELDMASTER_DATABASE: nResId = RES_DBFLD; break;
770 xRet = (cppu::OWeakObject*)new SwXFieldMaster(pDoc, nResId);
772 break;
773 case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY:
775 SwFieldType* pType = pDoc->GetFldType(RES_AUTHORITY, aEmptyStr, sal_True);
776 if(!pType)
778 SwAuthorityFieldType aType(pDoc);
779 pType = pDoc->InsertFldType(aType);
781 else
783 SwClientIter aIter( *pType );
784 SwXFieldMaster* pMaster = (SwXFieldMaster*)aIter.First( TYPE( SwXFieldMaster ));
785 if(pMaster)
786 xRet = (cppu::OWeakObject*)pMaster;
788 if(!xRet.is())
789 xRet = (cppu::OWeakObject*)new SwXFieldMaster(*pType, pDoc);
791 break;
792 case SW_SERVICE_PARAGRAPH :
793 xRet = (cppu::OWeakObject*)new SwXParagraph();
794 break;
795 case SW_SERVICE_NUMBERING_RULES :
796 xRet = (cppu::OWeakObject*)new SwXNumberingRules(*pDoc);
797 break;
798 case SW_SERVICE_TEXT_COLUMNS :
799 xRet = (cppu::OWeakObject*)new SwXTextColumns(0);
800 break;
801 case SW_SERVICE_DEFAULTS:
802 xRet = (cppu::OWeakObject*)new SwXTextDefaults( pDoc );
803 break;
804 case SW_SERVICE_IMAP_RECTANGLE :
805 xRet = SvUnoImageMapRectangleObject_createInstance( lcl_GetSupportedMacroItems() );
806 break;
807 case SW_SERVICE_IMAP_CIRCLE :
808 xRet = SvUnoImageMapCircleObject_createInstance( lcl_GetSupportedMacroItems() );
809 break;
810 case SW_SERVICE_IMAP_POLYGON :
811 xRet = SvUnoImageMapPolygonObject_createInstance( lcl_GetSupportedMacroItems() );
812 break;
813 case SW_SERVICE_CHART2_DATA_PROVIDER :
814 // #i64497# If a chart is in a temporary document during clipoard
815 // paste, there should be no data provider, so that own data is used
816 // This should not happen during copy/paste, as this will unlink
817 // charts using table data.
818 OSL_ASSERT( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED );
819 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
820 xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ );
821 break;
822 case SW_SERVICE_TYPE_META:
823 xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) );
824 break;
825 case SW_SERVICE_FIELDTYPE_METAFIELD:
826 xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc));
827 break;
828 default:
829 throw uno::RuntimeException();
831 return xRet;
833 /******************************************************************
834 * SwXTextTables
835 ******************************************************************/
836 //SMART_UNO_IMPLEMENTATION( SwXTextTables, UsrObject );
838 /*-- 13.01.99 12:56:24---------------------------------------------------
840 -----------------------------------------------------------------------*/
841 SwXTextTables::SwXTextTables(SwDoc* pDc) :
842 SwUnoCollection(pDc)
846 /*-- 13.01.99 12:56:25---------------------------------------------------
848 -----------------------------------------------------------------------*/
849 SwXTextTables::~SwXTextTables()
853 /*-- 13.01.99 12:56:25---------------------------------------------------
855 -----------------------------------------------------------------------*/
856 sal_Int32 SwXTextTables::getCount(void) throw( uno::RuntimeException )
858 vos::OGuard aGuard(Application::GetSolarMutex());
859 sal_Int32 nRet = 0;
860 if(IsValid())
861 nRet = GetDoc()->GetTblFrmFmtCount(sal_True);
862 return nRet;
864 /*-- 13.01.99 12:56:26---------------------------------------------------
866 -----------------------------------------------------------------------*/
867 uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nIndex)
868 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
870 vos::OGuard aGuard(Application::GetSolarMutex());
871 uno::Any aRet;
872 if(IsValid())
874 if(0 <= nIndex && GetDoc()->GetTblFrmFmtCount(sal_True) > nIndex)
876 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt( static_cast< xub_StrLen >(nIndex), sal_True);
877 uno::Reference< XTextTable > xTbl = SwXTextTables::GetObject(rFmt);
878 aRet.setValue( &xTbl,
879 ::getCppuType((uno::Reference< XTextTable>*)0));
881 else
882 throw IndexOutOfBoundsException();
884 else
885 throw uno::RuntimeException();
886 return aRet;
888 /*-- 13.01.99 12:56:26---------------------------------------------------
890 -----------------------------------------------------------------------*/
891 uno::Any SwXTextTables::getByName(const OUString& rItemName)
892 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
894 vos::OGuard aGuard(Application::GetSolarMutex());
895 uno::Any aRet;
896 if(IsValid())
898 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
899 uno::Reference< XTextTable > xTbl;
900 for( sal_uInt16 i = 0; i < nCount; i++)
902 String aName(rItemName);
903 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
904 if(aName == rFmt.GetName())
906 xTbl = SwXTextTables::GetObject(rFmt);
907 aRet.setValue(&xTbl,
908 ::getCppuType(( uno::Reference< XTextTable >*)0));
909 break;
912 if(!xTbl.is())
913 throw NoSuchElementException();
915 else
916 throw uno::RuntimeException();
917 return aRet;
919 /*-- 13.01.99 12:56:26---------------------------------------------------
921 -----------------------------------------------------------------------*/
922 uno::Sequence< OUString > SwXTextTables::getElementNames(void)
923 throw( uno::RuntimeException )
925 vos::OGuard aGuard(Application::GetSolarMutex());
926 if(!IsValid())
927 throw uno::RuntimeException();
928 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
929 uno::Sequence<OUString> aSeq(nCount);
930 if(nCount)
932 OUString* pArray = aSeq.getArray();
933 for( sal_uInt16 i = 0; i < nCount; i++)
935 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
937 pArray[i] = OUString(rFmt.GetName());
940 return aSeq;
942 /*-- 13.01.99 12:56:27---------------------------------------------------
944 -----------------------------------------------------------------------*/
945 sal_Bool SwXTextTables::hasByName(const OUString& rName)
946 throw( uno::RuntimeException )
948 vos::OGuard aGuard(Application::GetSolarMutex());
949 sal_Bool bRet= sal_False;
950 if(IsValid())
952 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True);
953 for( sal_uInt16 i = 0; i < nCount; i++)
955 String aName(rName);
956 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True);
957 if(aName == rFmt.GetName())
959 bRet = sal_True;
960 break;
964 else
965 throw uno::RuntimeException();
966 return bRet;
968 /*-- 13.01.99 12:56:27---------------------------------------------------
970 -----------------------------------------------------------------------*/
971 uno::Type SAL_CALL
972 SwXTextTables::getElementType( )
973 throw(uno::RuntimeException)
975 return ::getCppuType((uno::Reference<XTextTable>*)0);
977 /*-- 13.01.99 12:56:27---------------------------------------------------
979 -----------------------------------------------------------------------*/
980 sal_Bool SwXTextTables::hasElements(void) throw( uno::RuntimeException )
982 vos::OGuard aGuard(Application::GetSolarMutex());
983 if(!IsValid())
984 throw uno::RuntimeException();
985 return 0 != GetDoc()->GetTblFrmFmtCount(sal_True);
987 /* -----------------25.10.99 16:01-------------------
989 --------------------------------------------------*/
990 OUString SwXTextTables::getImplementationName(void) throw( uno::RuntimeException )
992 return C2U("SwXTextTables");
994 /* -----------------25.10.99 16:01-------------------
996 --------------------------------------------------*/
997 sal_Bool SwXTextTables::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
999 return rServiceName == C2U("com.sun.star.text.TextTables");
1001 /* -----------------25.10.99 16:01-------------------
1003 --------------------------------------------------*/
1004 uno::Sequence< OUString > SwXTextTables::getSupportedServiceNames(void) throw( uno::RuntimeException )
1006 uno::Sequence< OUString > aRet(1);
1007 OUString* pArr = aRet.getArray();
1008 pArr[0] = C2U("com.sun.star.text.TextTables");
1009 return aRet;
1011 /*-- 13.01.99 12:56:28---------------------------------------------------
1013 -----------------------------------------------------------------------*/
1014 XTextTable* SwXTextTables::GetObject( SwFrmFmt& rFmt )
1016 vos::OGuard aGuard(Application::GetSolarMutex());
1017 SwXTextTable* pTbl = (SwXTextTable*)SwClientIter( rFmt ).
1018 First( TYPE( SwXTextTable ));
1019 if( !pTbl )
1020 pTbl = new SwXTextTable(rFmt);
1021 return pTbl ;
1025 /******************************************************************
1026 * SwXFrameEnumeration
1027 ******************************************************************/
1028 namespace
1030 template<FlyCntType T> struct UnoFrameWrap_traits {};
1032 template<>
1033 struct UnoFrameWrap_traits<FLYCNTTYPE_FRM>
1035 typedef SwXTextFrame core_frame_t;
1036 typedef XTextFrame uno_frame_t;
1037 static inline bool filter(const SwNode* const pNode) { return !pNode->IsNoTxtNode(); };
1040 template<>
1041 struct UnoFrameWrap_traits<FLYCNTTYPE_GRF>
1043 typedef SwXTextGraphicObject core_frame_t;
1044 typedef XTextContent uno_frame_t;
1045 static inline bool filter(const SwNode* const pNode) { return pNode->IsGrfNode(); };
1048 template<>
1049 struct UnoFrameWrap_traits<FLYCNTTYPE_OLE>
1051 typedef SwXTextEmbeddedObject core_frame_t;
1052 typedef XEmbeddedObjectSupplier uno_frame_t;
1053 static inline bool filter(const SwNode* const pNode) { return pNode->IsOLENode(); };
1056 template<FlyCntType T>
1057 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt)
1059 SwXFrame* pFrm = static_cast<SwXFrame*>(SwClientIter(*pFmt).First(TYPE(SwXFrame)));
1060 if(!pFrm)
1061 pFrm = new typename UnoFrameWrap_traits<T>::core_frame_t(*pFmt);
1062 Reference< typename UnoFrameWrap_traits<T>::uno_frame_t > xFrm =
1063 static_cast< typename UnoFrameWrap_traits<T>::core_frame_t* >(pFrm);
1064 return uno::makeAny(xFrm);
1067 // runtime adapter for lcl_UnoWrapFrame
1068 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt, FlyCntType eType) throw(uno::RuntimeException())
1070 switch(eType)
1072 case FLYCNTTYPE_FRM:
1073 return lcl_UnoWrapFrame<FLYCNTTYPE_FRM>(pFmt);
1074 case FLYCNTTYPE_GRF:
1075 return lcl_UnoWrapFrame<FLYCNTTYPE_GRF>(pFmt);
1076 case FLYCNTTYPE_OLE:
1077 return lcl_UnoWrapFrame<FLYCNTTYPE_OLE>(pFmt);
1078 default:
1079 throw uno::RuntimeException();
1083 template<FlyCntType T>
1084 class SwXFrameEnumeration : public SwSimpleEnumerationBaseClass
1086 private:
1087 typedef ::std::slist< Any > frmcontainer_t;
1088 frmcontainer_t m_aFrames;
1089 protected:
1090 virtual ~SwXFrameEnumeration() {};
1091 public:
1092 SwXFrameEnumeration(const SwDoc* const pDoc);
1094 //XEnumeration
1095 virtual sal_Bool SAL_CALL hasMoreElements(void) throw( RuntimeException );
1096 virtual Any SAL_CALL nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException );
1098 //XServiceInfo
1099 virtual OUString SAL_CALL getImplementationName(void) throw( RuntimeException );
1100 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException );
1101 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException );
1105 template<FlyCntType T>
1106 SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc)
1107 : m_aFrames()
1109 vos::OGuard aGuard(Application::GetSolarMutex());
1110 const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts();
1111 if(!pFmts->Count())
1112 return;
1113 // --> OD 2009-09-10 #i104937#
1114 // const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()];
1115 const USHORT nSize = pFmts->Count();
1116 // <--
1117 ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin());
1118 // --> OD 2009-09-10 #i104937#
1119 SwFrmFmt* pFmt( 0 );
1120 for( USHORT i = 0; i < nSize; ++i )
1121 // for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt)
1122 // <--
1124 // --> OD 2009-09-10 #i104937#
1125 pFmt = (*pFmts)[i];
1126 // <--
1127 if(pFmt->Which() != RES_FLYFRMFMT)
1128 continue;
1129 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx();
1130 if(!pIdx || !pIdx->GetNodes().IsDocNodes())
1131 continue;
1132 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
1133 if(UnoFrameWrap_traits<T>::filter(pNd))
1134 *pInserter++ = lcl_UnoWrapFrame<T>(pFmt);
1138 template<FlyCntType T>
1139 sal_Bool SwXFrameEnumeration<T>::hasMoreElements(void) throw( RuntimeException )
1141 vos::OGuard aGuard(Application::GetSolarMutex());
1142 return !m_aFrames.empty();
1145 template<FlyCntType T>
1146 Any SwXFrameEnumeration<T>::nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException )
1148 vos::OGuard aGuard(Application::GetSolarMutex());
1149 if(m_aFrames.empty())
1150 throw NoSuchElementException();
1151 Any aResult = *m_aFrames.begin();
1152 m_aFrames.pop_front();
1153 return aResult;
1156 template<FlyCntType T>
1157 OUString SwXFrameEnumeration<T>::getImplementationName(void) throw( RuntimeException )
1159 return C2U("SwXFrameEnumeration");
1162 template<FlyCntType T>
1163 sal_Bool SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException )
1165 return C2U("com.sun.star.container.XEnumeration") == ServiceName;
1168 template<FlyCntType T>
1169 Sequence< OUString > SwXFrameEnumeration<T>::getSupportedServiceNames(void) throw( RuntimeException )
1171 return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration"));
1174 /******************************************************************
1175 * SwXFrames
1176 ******************************************************************/
1177 OUString SwXFrames::getImplementationName(void) throw( RuntimeException )
1179 return C2U("SwXFrames");
1182 BOOL SwXFrames::supportsService(const OUString& rServiceName) throw( RuntimeException )
1184 return C2U("com.sun.star.text.TextFrames") == rServiceName;
1187 Sequence<OUString> SwXFrames::getSupportedServiceNames(void) throw( RuntimeException )
1189 return ::comphelper::makeSequence(C2U("com.sun.star.text.TextFrames"));
1192 SwXFrames::SwXFrames(SwDoc* _pDoc, FlyCntType eSet) :
1193 SwUnoCollection(_pDoc),
1194 eType(eSet)
1197 SwXFrames::~SwXFrames()
1200 uno::Reference<container::XEnumeration> SwXFrames::createEnumeration(void) throw(uno::RuntimeException)
1202 vos::OGuard aGuard(Application::GetSolarMutex());
1203 if(!IsValid())
1204 throw uno::RuntimeException();
1205 switch(eType)
1207 case FLYCNTTYPE_FRM:
1208 return uno::Reference< container::XEnumeration >(
1209 new SwXFrameEnumeration<FLYCNTTYPE_FRM>(GetDoc()));
1210 case FLYCNTTYPE_GRF:
1211 return uno::Reference< container::XEnumeration >(
1212 new SwXFrameEnumeration<FLYCNTTYPE_GRF>(GetDoc()));
1213 case FLYCNTTYPE_OLE:
1214 return uno::Reference< container::XEnumeration >(
1215 new SwXFrameEnumeration<FLYCNTTYPE_OLE>(GetDoc()));
1216 default:
1217 throw uno::RuntimeException();
1221 sal_Int32 SwXFrames::getCount(void) throw(uno::RuntimeException)
1223 vos::OGuard aGuard(Application::GetSolarMutex());
1224 if(!IsValid())
1225 throw uno::RuntimeException();
1226 return GetDoc()->GetFlyCount(eType);
1229 uno::Any SwXFrames::getByIndex(sal_Int32 nIndex)
1230 throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1232 vos::OGuard aGuard(Application::GetSolarMutex());
1233 if(!IsValid())
1234 throw uno::RuntimeException();
1235 if(nIndex < 0 || nIndex >= USHRT_MAX)
1236 throw IndexOutOfBoundsException();
1237 SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType);
1238 if(!pFmt)
1239 throw IndexOutOfBoundsException();
1240 return lcl_UnoWrapFrame(pFmt, eType);
1243 uno::Any SwXFrames::getByName(const OUString& rName)
1244 throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1246 vos::OGuard aGuard(Application::GetSolarMutex());
1247 if(!IsValid())
1248 throw uno::RuntimeException();
1249 const SwFrmFmt* pFmt;
1250 switch(eType)
1252 case FLYCNTTYPE_GRF:
1253 pFmt = GetDoc()->FindFlyByName(rName, ND_GRFNODE);
1254 break;
1255 case FLYCNTTYPE_OLE:
1256 pFmt = GetDoc()->FindFlyByName(rName, ND_OLENODE);
1257 break;
1258 default:
1259 pFmt = GetDoc()->FindFlyByName(rName, ND_TEXTNODE);
1260 break;
1262 if(!pFmt)
1263 throw NoSuchElementException();
1264 return lcl_UnoWrapFrame(const_cast<SwFrmFmt*>(pFmt), eType);
1267 uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeException )
1269 vos::OGuard aGuard(Application::GetSolarMutex());
1270 if(!IsValid())
1271 throw uno::RuntimeException();
1272 const Reference<XEnumeration> xEnum = createEnumeration();
1273 ::std::vector<OUString> vNames;
1274 while(xEnum->hasMoreElements())
1276 Reference<container::XNamed> xNamed;
1277 xEnum->nextElement() >>= xNamed;
1278 if(xNamed.is())
1279 vNames.push_back(xNamed->getName());
1281 return ::comphelper::containerToSequence(vNames);
1284 sal_Bool SwXFrames::hasByName(const OUString& rName) throw( uno::RuntimeException )
1286 vos::OGuard aGuard(Application::GetSolarMutex());
1287 if(!IsValid())
1288 throw uno::RuntimeException();
1289 switch(eType)
1291 case FLYCNTTYPE_GRF:
1292 return GetDoc()->FindFlyByName(rName, ND_GRFNODE) != NULL;
1293 case FLYCNTTYPE_OLE:
1294 return GetDoc()->FindFlyByName(rName, ND_OLENODE) != NULL;
1295 default:
1296 return GetDoc()->FindFlyByName(rName, ND_TEXTNODE) != NULL;
1300 uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException)
1302 vos::OGuard aGuard(Application::GetSolarMutex());
1303 switch(eType)
1305 case FLYCNTTYPE_FRM:
1306 return ::getCppuType((uno::Reference<XTextFrame>*)0);
1307 case FLYCNTTYPE_GRF:
1308 return ::getCppuType((uno::Reference<XTextContent>*)0);
1309 case FLYCNTTYPE_OLE:
1310 return ::getCppuType((uno::Reference<XEmbeddedObjectSupplier>*)0);
1311 default:
1312 return uno::Type();
1316 sal_Bool SwXFrames::hasElements(void) throw(uno::RuntimeException)
1318 vos::OGuard aGuard(Application::GetSolarMutex());
1319 if(!IsValid())
1320 throw uno::RuntimeException();
1321 return GetDoc()->GetFlyCount(eType) > 0;
1324 SwXFrame* SwXFrames::GetObject(SwFrmFmt& rFmt, FlyCntType eType)
1326 SwXFrame* pFrm = (SwXFrame*)SwClientIter(rFmt).First(TYPE(SwXFrame));
1327 if(pFrm) return pFrm;
1328 switch(eType)
1330 case FLYCNTTYPE_FRM:
1331 return new SwXTextFrame(rFmt);
1332 case FLYCNTTYPE_GRF:
1333 return new SwXTextGraphicObject(rFmt);
1334 case FLYCNTTYPE_OLE:
1335 return new SwXTextEmbeddedObject(rFmt);
1336 default:
1337 return NULL;
1341 /******************************************************************
1342 * SwXTextFrames
1343 ******************************************************************/
1344 /* -----------------------------06.04.00 12:44--------------------------------
1346 ---------------------------------------------------------------------------*/
1347 OUString SwXTextFrames::getImplementationName(void) throw( RuntimeException )
1349 return C2U("SwXTextFrames");
1351 /* -----------------------------06.04.00 12:44--------------------------------
1353 ---------------------------------------------------------------------------*/
1354 BOOL SwXTextFrames::supportsService(const OUString& rServiceName) throw( RuntimeException )
1356 return C2U("com.sun.star.text.TextFrames") == rServiceName;
1358 /* -----------------------------06.04.00 12:44--------------------------------
1360 ---------------------------------------------------------------------------*/
1361 Sequence< OUString > SwXTextFrames::getSupportedServiceNames(void) throw( RuntimeException )
1363 Sequence< OUString > aRet(1);
1364 OUString* pArray = aRet.getArray();
1365 pArray[0] = C2U("com.sun.star.text.TextFrames");
1366 return aRet;
1368 /*-- 14.01.99 08:06:16---------------------------------------------------
1370 -----------------------------------------------------------------------*/
1371 SwXTextFrames::SwXTextFrames(SwDoc* _pDoc) :
1372 SwXFrames(_pDoc, FLYCNTTYPE_FRM)
1375 /*-- 14.01.99 08:06:17---------------------------------------------------
1377 -----------------------------------------------------------------------*/
1378 SwXTextFrames::~SwXTextFrames()
1382 /******************************************************************
1383 * SwXTextGraphicObjects
1384 ******************************************************************/
1385 //SMART_UNO_IMPLEMENTATION( SwXTextGraphicObjects, UsrObject );
1387 /* -----------------------------06.04.00 12:44--------------------------------
1389 ---------------------------------------------------------------------------*/
1390 OUString SwXTextGraphicObjects::getImplementationName(void) throw( RuntimeException )
1392 return C2U("SwXTextGraphicObjects");
1394 /* -----------------------------06.04.00 12:44--------------------------------
1396 ---------------------------------------------------------------------------*/
1397 BOOL SwXTextGraphicObjects::supportsService(const OUString& rServiceName) throw( RuntimeException )
1399 return C2U("com.sun.star.text.TextGraphicObjects") == rServiceName;
1401 /* -----------------------------06.04.00 12:44--------------------------------
1403 ---------------------------------------------------------------------------*/
1404 Sequence< OUString > SwXTextGraphicObjects::getSupportedServiceNames(void) throw( RuntimeException )
1406 Sequence< OUString > aRet(1);
1407 OUString* pArray = aRet.getArray();
1408 pArray[0] = C2U("com.sun.star.text.TextGraphicObjects");
1409 return aRet;
1411 /*-- 14.01.99 08:45:53---------------------------------------------------
1413 -----------------------------------------------------------------------*/
1414 SwXTextGraphicObjects::SwXTextGraphicObjects(SwDoc* _pDoc) :
1415 SwXFrames(_pDoc, FLYCNTTYPE_GRF)
1418 /*-- 14.01.99 08:45:54---------------------------------------------------
1420 -----------------------------------------------------------------------*/
1421 SwXTextGraphicObjects::~SwXTextGraphicObjects()
1425 /******************************************************************
1426 * SwXTextEmbeddedObjects
1427 ******************************************************************/
1428 /* -----------------------------06.04.00 12:44--------------------------------
1430 ---------------------------------------------------------------------------*/
1431 OUString SwXTextEmbeddedObjects::getImplementationName(void) throw( RuntimeException )
1433 return C2U("SwXTextEmbeddedObjects");
1435 /* -----------------------------06.04.00 12:44--------------------------------
1437 ---------------------------------------------------------------------------*/
1438 BOOL SwXTextEmbeddedObjects::supportsService(const OUString& rServiceName) throw( RuntimeException )
1440 return C2U("com.sun.star.text.TextEmbeddedObjects") == rServiceName;
1442 /* -----------------------------06.04.00 12:44--------------------------------
1444 ---------------------------------------------------------------------------*/
1445 Sequence< OUString > SwXTextEmbeddedObjects::getSupportedServiceNames(void) throw( RuntimeException )
1447 Sequence< OUString > aRet(1);
1448 OUString* pArray = aRet.getArray();
1449 pArray[0] = C2U("com.sun.star.text.TextEmbeddedObjects");
1450 return aRet;
1452 /*-- 14.01.99 08:45:13---------------------------------------------------
1454 -----------------------------------------------------------------------*/
1455 SwXTextEmbeddedObjects::SwXTextEmbeddedObjects(SwDoc* _pDoc) :
1456 SwXFrames(_pDoc, FLYCNTTYPE_OLE)
1459 /*-- 14.01.99 08:45:31---------------------------------------------------
1461 -----------------------------------------------------------------------*/
1462 SwXTextEmbeddedObjects::~SwXTextEmbeddedObjects()
1466 /******************************************************************
1468 ******************************************************************/
1469 #define PASSWORD_STD_TIMEOUT 1000
1470 /* -----------------------------06.04.00 12:44--------------------------------
1472 ---------------------------------------------------------------------------*/
1473 OUString SwXTextSections::getImplementationName(void) throw( RuntimeException )
1475 return C2U("SwXTextSections");
1477 /* -----------------------------06.04.00 12:44--------------------------------
1479 ---------------------------------------------------------------------------*/
1480 BOOL SwXTextSections::supportsService(const OUString& rServiceName) throw( RuntimeException )
1482 return C2U("com.sun.star.text.TextSections") == rServiceName;
1484 /* -----------------------------06.04.00 12:44--------------------------------
1486 ---------------------------------------------------------------------------*/
1487 Sequence< OUString > SwXTextSections::getSupportedServiceNames(void) throw( RuntimeException )
1489 Sequence< OUString > aRet(1);
1490 OUString* pArray = aRet.getArray();
1491 pArray[0] = C2U("com.sun.star.text.TextSections");
1492 return aRet;
1494 /*-- 14.01.99 09:06:05---------------------------------------------------
1496 -----------------------------------------------------------------------*/
1497 SwXTextSections::SwXTextSections(SwDoc* _pDoc) :
1498 SwUnoCollection(_pDoc)
1501 /*-- 14.01.99 09:06:05---------------------------------------------------
1503 -----------------------------------------------------------------------*/
1504 SwXTextSections::~SwXTextSections()
1507 /*-- 14.01.99 09:06:05---------------------------------------------------
1509 -----------------------------------------------------------------------*/
1510 sal_Int32 SwXTextSections::getCount(void) throw( uno::RuntimeException )
1512 vos::OGuard aGuard(Application::GetSolarMutex());
1513 if(!IsValid())
1514 throw uno::RuntimeException();
1515 const SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1516 sal_uInt16 nCount = rSectFmts.Count();
1517 for(sal_uInt16 i = nCount; i; i--)
1519 if( !rSectFmts[i - 1]->IsInNodesArr())
1520 nCount--;
1522 return nCount;
1524 /*-- 14.01.99 09:06:06---------------------------------------------------
1526 -----------------------------------------------------------------------*/
1527 uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex)
1528 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1530 vos::OGuard aGuard(Application::GetSolarMutex());
1531 uno::Reference< XTextSection > xRet;
1532 if(IsValid())
1534 SwSectionFmts& rFmts = GetDoc()->GetSections();
1536 const SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1537 sal_uInt16 nCount = rSectFmts.Count();
1538 for(sal_uInt16 i = 0; i < nCount; i++)
1540 if( !rSectFmts[i]->IsInNodesArr())
1541 nIndex ++;
1542 else if(nIndex == i)
1543 break;
1544 if(nIndex == i)
1545 break;
1547 if(nIndex >= 0 && nIndex < rFmts.Count())
1549 SwSectionFmt* pFmt = rFmts[(sal_uInt16)nIndex];
1550 xRet = GetObject(*pFmt);
1552 else
1553 throw IndexOutOfBoundsException();
1555 else
1556 throw uno::RuntimeException();
1557 return makeAny(xRet);
1559 /*-- 14.01.99 09:06:06---------------------------------------------------
1561 -----------------------------------------------------------------------*/
1562 uno::Any SwXTextSections::getByName(const OUString& Name)
1563 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1565 vos::OGuard aGuard(Application::GetSolarMutex());
1566 uno::Any aRet;
1567 if(IsValid())
1569 String aName(Name);
1570 SwSectionFmts& rFmts = GetDoc()->GetSections();
1571 uno::Reference< XTextSection > xSect;
1572 for(sal_uInt16 i = 0; i < rFmts.Count(); i++)
1574 SwSectionFmt* pFmt = rFmts[i];
1575 if(pFmt->IsInNodesArr() && aName == pFmt->GetSection()->GetName())
1577 xSect = GetObject(*pFmt);
1578 aRet.setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0));
1579 break;
1582 if(!xSect.is())
1583 throw NoSuchElementException();
1585 else
1586 throw uno::RuntimeException();
1587 return aRet;
1589 /*-- 14.01.99 09:06:06---------------------------------------------------
1591 -----------------------------------------------------------------------*/
1592 uno::Sequence< OUString > SwXTextSections::getElementNames(void)
1593 throw( uno::RuntimeException )
1595 vos::OGuard aGuard(Application::GetSolarMutex());
1596 if(!IsValid())
1597 throw uno::RuntimeException();
1598 sal_uInt16 nCount = GetDoc()->GetSections().Count();
1599 SwSectionFmts& rSectFmts = GetDoc()->GetSections();
1600 for(sal_uInt16 i = nCount; i; i--)
1602 if( !rSectFmts[i - 1]->IsInNodesArr())
1603 nCount--;
1606 uno::Sequence<OUString> aSeq(nCount);
1607 if(nCount)
1609 SwSectionFmts& rFmts = GetDoc()->GetSections();
1610 OUString* pArray = aSeq.getArray();
1611 sal_uInt16 nIndex = 0;
1612 for( sal_uInt16 i = 0; i < nCount; i++, nIndex++)
1614 const SwSectionFmt* pFmt = rFmts[nIndex];
1615 while(!pFmt->IsInNodesArr())
1617 pFmt = rFmts[++nIndex];
1619 pArray[i] = pFmt->GetSection()->GetName();
1622 return aSeq;
1624 /*-- 14.01.99 09:06:06---------------------------------------------------
1626 -----------------------------------------------------------------------*/
1627 sal_Bool SwXTextSections::hasByName(const OUString& Name)
1628 throw( uno::RuntimeException )
1630 vos::OGuard aGuard(Application::GetSolarMutex());
1631 sal_Bool bRet = sal_False;
1632 String aName(Name);
1633 if(IsValid())
1635 SwSectionFmts& rFmts = GetDoc()->GetSections();
1636 for(sal_uInt16 i = 0; i < rFmts.Count(); i++)
1638 const SwSectionFmt* pFmt = rFmts[i];
1639 if(aName == pFmt->GetSection()->GetName())
1641 bRet = sal_True;
1642 break;
1646 else
1648 //Sonderbehandlung der dbg_ - Methoden
1649 if( COMPARE_EQUAL != aName.CompareToAscii("dbg_", 4))
1650 throw uno::RuntimeException();
1652 return bRet;
1654 /*-- 14.01.99 09:06:06---------------------------------------------------
1656 -----------------------------------------------------------------------*/
1657 uno::Type SAL_CALL SwXTextSections::getElementType() throw(uno::RuntimeException)
1659 return ::getCppuType((uno::Reference<XTextSection>*)0);
1661 /*-- 14.01.99 09:06:06---------------------------------------------------
1663 -----------------------------------------------------------------------*/
1664 sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException )
1666 vos::OGuard aGuard(Application::GetSolarMutex());
1667 sal_uInt16 nCount = 0;
1668 if(IsValid())
1670 SwSectionFmts& rFmts = GetDoc()->GetSections();
1671 nCount = rFmts.Count();
1673 else
1674 throw uno::RuntimeException();
1675 return nCount > 0;
1677 /*-- 14.01.99 09:06:07---------------------------------------------------
1679 -----------------------------------------------------------------------*/
1680 uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt )
1682 SwXTextSectionClient* pClient = (SwXTextSectionClient*)SwClientIter( rFmt ).
1683 First( TYPE( SwXTextSectionClient ));
1684 uno::Reference< XTextSection > xRet;
1685 if( pClient )
1686 xRet = pClient->GetXTextSection();
1687 // it is possible that the client is still registered but the reference is already invalid
1688 if( !xRet.is() )
1689 xRet = SwXTextSectionClient::CreateXTextSection(&rFmt);
1690 return xRet;
1693 OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException )
1695 return OUString::createFromAscii("SwXBookmarks");
1698 BOOL SwXBookmarks::supportsService(const OUString& rServiceName) throw( RuntimeException )
1700 return OUString::createFromAscii("com.sun.star.text.Bookmarks") == rServiceName;
1703 Sequence< OUString > SwXBookmarks::getSupportedServiceNames(void) throw( RuntimeException )
1705 Sequence< OUString > aRet(1);
1706 aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmarks");
1707 return aRet;
1710 SwXBookmarks::SwXBookmarks(SwDoc* _pDoc) :
1711 SwUnoCollection(_pDoc)
1714 SwXBookmarks::~SwXBookmarks()
1717 sal_Int32 SwXBookmarks::getCount(void)
1718 throw( uno::RuntimeException )
1720 vos::OGuard aGuard(Application::GetSolarMutex());
1721 if(!IsValid())
1722 throw uno::RuntimeException();
1723 return GetDoc()->getIDocumentMarkAccess()->getMarksCount();
1726 uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex)
1727 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1729 vos::OGuard aGuard(Application::GetSolarMutex());
1730 if(!IsValid())
1731 throw uno::RuntimeException();
1732 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1733 if(nIndex < 0 || nIndex >= pMarkAccess->getMarksCount())
1734 throw IndexOutOfBoundsException();
1736 uno::Any aRet;
1737 ::sw::mark::IMark* pBkmk = pMarkAccess->getMarksBegin()[nIndex].get();
1738 uno::Reference< XTextContent > xRef = GetObject(*pBkmk, GetDoc());
1739 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
1740 return aRet;
1743 uno::Any SwXBookmarks::getByName(const rtl::OUString& rName)
1744 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
1746 vos::OGuard aGuard(Application::GetSolarMutex());
1747 if(!IsValid())
1748 throw uno::RuntimeException();
1750 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1751 IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark(rName);
1752 if(ppBkmk == pMarkAccess->getMarksEnd())
1753 throw NoSuchElementException();
1755 uno::Any aRet;
1756 uno::Reference< XTextContent > xRef = SwXBookmarks::GetObject(*(ppBkmk->get()), GetDoc());
1757 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
1758 return aRet;
1761 uno::Sequence< OUString > SwXBookmarks::getElementNames(void)
1762 throw( uno::RuntimeException )
1764 vos::OGuard aGuard(Application::GetSolarMutex());
1765 if(!IsValid())
1766 throw uno::RuntimeException();
1768 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1769 uno::Sequence<OUString> aSeq(pMarkAccess->getMarksCount());
1770 sal_Int32 nCnt = 0;
1771 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
1772 ppMark != pMarkAccess->getMarksEnd();)
1773 aSeq[nCnt++] = (*ppMark++)->GetName();
1774 return aSeq;
1777 sal_Bool SwXBookmarks::hasByName(const OUString& rName)
1778 throw( uno::RuntimeException )
1780 vos::OGuard aGuard(Application::GetSolarMutex());
1781 if(!IsValid())
1782 throw uno::RuntimeException();
1784 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1785 return pMarkAccess->findMark(rName) != pMarkAccess->getMarksEnd();
1788 uno::Type SAL_CALL SwXBookmarks::getElementType()
1789 throw(uno::RuntimeException)
1791 return ::getCppuType((uno::Reference<XTextContent>*)0);
1794 sal_Bool SwXBookmarks::hasElements(void)
1795 throw( uno::RuntimeException )
1797 vos::OGuard aGuard(Application::GetSolarMutex());
1798 if(!IsValid())
1799 throw uno::RuntimeException();
1800 return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0;
1803 SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc)
1805 SwModify* const pModify = static_cast<SwModify*>(&rBkmk);
1806 SwXBookmark* pXBkmk = (SwXBookmark*)SwClientIter(*pModify).First(TYPE(SwXBookmark));
1807 if(!pXBkmk)
1809 // FIXME: These belong in XTextFieldsSupplier
1810 if (dynamic_cast< ::sw::mark::ICheckboxFieldmark* >(&rBkmk))
1811 pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc);
1812 else if (dynamic_cast< ::sw::mark::IFieldmark* >(&rBkmk))
1813 pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc);
1814 else
1816 OSL_ENSURE(
1817 dynamic_cast< ::sw::mark::IBookmark* >(&rBkmk),
1818 "<SwXBookmark::GetObject(..)>"
1819 "SwXBookmark requested for non-bookmark mark.");
1820 pXBkmk = new SwXBookmark(&rBkmk, pDoc);
1823 return pXBkmk;
1826 /******************************************************************
1828 ******************************************************************/
1830 SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc* _pDoc ) :
1831 SwUnoCollection(_pDoc)
1835 SwXNumberingRulesCollection::~SwXNumberingRulesCollection()
1839 sal_Int32 SwXNumberingRulesCollection::getCount(void) throw( uno::RuntimeException )
1841 vos::OGuard aGuard(Application::GetSolarMutex());
1842 if(!IsValid())
1843 throw uno::RuntimeException();
1844 return GetDoc()->GetNumRuleTbl().Count();
1847 uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex)
1848 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1850 vos::OGuard aGuard(Application::GetSolarMutex());
1851 uno::Any aRet;
1852 if(IsValid())
1854 uno::Reference< XIndexReplace > xRef;
1855 if ( nIndex < GetDoc()->GetNumRuleTbl().Count() )
1857 xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTbl()[ static_cast< USHORT >(nIndex) ] );
1858 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XIndexReplace>*)0));
1861 if(!xRef.is())
1862 throw IndexOutOfBoundsException();
1864 else
1865 throw uno::RuntimeException();
1866 return aRet;
1869 uno::Type SAL_CALL SwXNumberingRulesCollection::getElementType() throw(uno::RuntimeException)
1871 return ::getCppuType((uno::Reference<XIndexReplace>*)0);
1874 sal_Bool SwXNumberingRulesCollection::hasElements(void) throw( uno::RuntimeException )
1876 vos::OGuard aGuard(Application::GetSolarMutex());
1877 if(!IsValid())
1878 throw uno::RuntimeException();
1879 return GetDoc()->GetNumRuleTbl().Count() > 0;
1882 /* -----------------------------06.04.00 12:44--------------------------------
1884 ---------------------------------------------------------------------------*/
1885 OUString SwXFootnotes::getImplementationName(void) throw( RuntimeException )
1887 return C2U("SwXFootnotes");
1889 /* -----------------------------06.04.00 12:44--------------------------------
1891 ---------------------------------------------------------------------------*/
1892 BOOL SwXFootnotes::supportsService(const OUString& rServiceName) throw( RuntimeException )
1894 return C2U("com.sun.star.text.Footnotes") == rServiceName;
1896 /* -----------------------------06.04.00 12:44--------------------------------
1898 ---------------------------------------------------------------------------*/
1899 Sequence< OUString > SwXFootnotes::getSupportedServiceNames(void) throw( RuntimeException )
1901 Sequence< OUString > aRet(1);
1902 OUString* pArray = aRet.getArray();
1903 pArray[0] = C2U("com.sun.star.text.Footnotes");
1904 return aRet;
1906 /*-- 14.01.99 09:03:52---------------------------------------------------
1908 -----------------------------------------------------------------------*/
1909 SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc)
1910 : SwUnoCollection(_pDoc)
1911 , m_bEndnote(bEnd)
1914 /*-- 14.01.99 09:03:52---------------------------------------------------
1916 -----------------------------------------------------------------------*/
1917 SwXFootnotes::~SwXFootnotes()
1920 /*-- 14.01.99 09:03:53---------------------------------------------------
1922 -----------------------------------------------------------------------*/
1923 sal_Int32 SwXFootnotes::getCount(void) throw( uno::RuntimeException )
1925 vos::OGuard aGuard(Application::GetSolarMutex());
1926 if(!IsValid())
1927 throw uno::RuntimeException();
1928 sal_Int32 nCount = 0;
1929 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count();
1930 SwTxtFtn* pTxtFtn;
1931 for( n = 0; n < nFtnCnt; ++n )
1933 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ];
1934 const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
1935 if ( rFtn.IsEndNote() != m_bEndnote )
1936 continue;
1937 nCount++;
1939 return nCount;
1941 /*-- 14.01.99 09:03:53---------------------------------------------------
1943 -----------------------------------------------------------------------*/
1944 uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex)
1945 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
1947 vos::OGuard aGuard(Application::GetSolarMutex());
1948 uno::Any aRet;
1949 sal_Int32 nCount = 0;
1950 if(IsValid())
1952 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count();
1953 SwTxtFtn* pTxtFtn;
1954 uno::Reference< XFootnote > xRef;
1955 for( n = 0; n < nFtnCnt; ++n )
1957 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ];
1958 const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
1959 if ( rFtn.IsEndNote() != m_bEndnote )
1960 continue;
1962 if(nCount == nIndex)
1964 xRef = new SwXFootnote(GetDoc(), rFtn);
1965 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XFootnote>*)0));
1966 break;
1968 nCount++;
1970 if(!xRef.is())
1971 throw IndexOutOfBoundsException();
1973 else
1974 throw uno::RuntimeException();
1975 return aRet;
1977 /*-- 14.01.99 09:03:53---------------------------------------------------
1979 -----------------------------------------------------------------------*/
1980 uno::Type SAL_CALL SwXFootnotes::getElementType() throw(uno::RuntimeException)
1982 return ::getCppuType((uno::Reference<XFootnote>*)0);
1984 /*-- 14.01.99 09:03:54---------------------------------------------------
1986 -----------------------------------------------------------------------*/
1987 sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException )
1989 vos::OGuard aGuard(Application::GetSolarMutex());
1990 if(!IsValid())
1991 throw uno::RuntimeException();
1992 return GetDoc()->GetFtnIdxs().Count() > 0;
1994 /* -----------------------------05.09.00 12:48--------------------------------
1996 ---------------------------------------------------------------------------*/
1997 Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt )
1999 Reference<XTextContent> xContent = ((SwUnoCallBack*)rDoc.GetUnoCallBack())->
2000 GetFootnote(rFmt);
2001 if(!xContent.is())
2002 xContent = new SwXFootnote(&rDoc, rFmt);
2003 Reference<XFootnote> xRet(xContent, UNO_QUERY);
2004 return xRet;
2007 /******************************************************************
2009 ******************************************************************/
2010 /* -----------------------------06.04.00 12:44--------------------------------
2012 ---------------------------------------------------------------------------*/
2013 OUString SwXReferenceMarks::getImplementationName(void) throw( RuntimeException )
2015 return C2U("SwXReferenceMarks");
2017 /* -----------------------------06.04.00 12:44--------------------------------
2019 ---------------------------------------------------------------------------*/
2020 BOOL SwXReferenceMarks::supportsService(const OUString& rServiceName) throw( RuntimeException )
2022 return C2U("com.sun.star.text.ReferenceMarks") == rServiceName;
2024 /* -----------------------------06.04.00 12:44--------------------------------
2026 ---------------------------------------------------------------------------*/
2027 Sequence< OUString > SwXReferenceMarks::getSupportedServiceNames(void) throw( RuntimeException )
2029 Sequence< OUString > aRet(1);
2030 OUString* pArray = aRet.getArray();
2031 pArray[0] = C2U("com.sun.star.text.ReferenceMarks");
2032 return aRet;
2034 /*-- 14.01.99 09:03:16---------------------------------------------------
2036 -----------------------------------------------------------------------*/
2037 SwXReferenceMarks::SwXReferenceMarks(SwDoc* _pDoc) :
2038 SwUnoCollection(_pDoc)
2041 /*-- 14.01.99 09:03:16---------------------------------------------------
2043 -----------------------------------------------------------------------*/
2044 SwXReferenceMarks::~SwXReferenceMarks()
2047 /*-- 14.01.99 09:03:17---------------------------------------------------
2049 -----------------------------------------------------------------------*/
2050 sal_Int32 SwXReferenceMarks::getCount(void) throw( uno::RuntimeException )
2052 vos::OGuard aGuard(Application::GetSolarMutex());
2053 if(!IsValid())
2054 throw uno::RuntimeException();
2055 return GetDoc()->GetRefMarks();
2057 /*-- 14.01.99 09:03:17---------------------------------------------------
2059 -----------------------------------------------------------------------*/
2060 uno::Any SwXReferenceMarks::getByIndex(sal_Int32 nIndex)
2061 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException )
2063 vos::OGuard aGuard(Application::GetSolarMutex());
2064 uno::Any aRet;
2065 if(!IsValid())
2066 throw uno::RuntimeException();
2067 uno::Reference< XTextContent > xRef;
2068 if(0 <= nIndex && nIndex < USHRT_MAX)
2070 const SwFmtRefMark* pMark = GetDoc()->GetRefMark( (sal_uInt16) nIndex );
2071 if(pMark)
2073 xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark );
2074 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
2077 if(!xRef.is())
2078 throw IndexOutOfBoundsException();
2079 return aRet;
2081 /*-- 14.01.99 09:03:17---------------------------------------------------
2083 -----------------------------------------------------------------------*/
2084 uno::Any SwXReferenceMarks::getByName(const OUString& rName)
2085 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException )
2087 vos::OGuard aGuard(Application::GetSolarMutex());
2088 uno::Any aRet;
2089 if(IsValid())
2091 const SwFmtRefMark* pMark = GetDoc()->GetRefMark(rName);
2092 if(pMark)
2094 uno::Reference< XTextContent > xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark );
2095 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
2097 else
2098 throw NoSuchElementException();
2100 else
2101 throw uno::RuntimeException();
2102 return aRet;
2104 /*-- 14.01.99 09:03:17---------------------------------------------------
2106 -----------------------------------------------------------------------*/
2107 uno::Sequence< OUString > SwXReferenceMarks::getElementNames(void) throw( uno::RuntimeException )
2109 vos::OGuard aGuard(Application::GetSolarMutex());
2110 uno::Sequence<OUString> aRet;
2111 if(IsValid())
2113 SvStringsDtor aStrings;
2114 sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings );
2115 aRet.realloc(nCount);
2116 OUString* pNames = aRet.getArray();
2117 for(sal_uInt16 i = 0; i < nCount; i++)
2118 pNames[i] = *aStrings.GetObject(i);
2120 else
2121 throw uno::RuntimeException();
2122 return aRet;
2124 /*-- 14.01.99 09:03:17---------------------------------------------------
2126 -----------------------------------------------------------------------*/
2127 sal_Bool SwXReferenceMarks::hasByName(const OUString& rName) throw( uno::RuntimeException )
2129 vos::OGuard aGuard(Application::GetSolarMutex());
2130 if(!IsValid())
2131 throw uno::RuntimeException();
2132 return 0 != GetDoc()->GetRefMark( rName);
2134 /*-- 14.01.99 09:03:18---------------------------------------------------
2136 -----------------------------------------------------------------------*/
2137 uno::Type SAL_CALL SwXReferenceMarks::getElementType() throw(uno::RuntimeException)
2139 return ::getCppuType((uno::Reference<XTextContent>*)0);
2141 /*-- 14.01.99 09:03:18---------------------------------------------------
2143 -----------------------------------------------------------------------*/
2144 sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException )
2146 vos::OGuard aGuard(Application::GetSolarMutex());
2147 if(!IsValid())
2148 throw uno::RuntimeException();
2149 return 0 != GetDoc()->GetRefMarks();
2151 /*-- 14.01.99 09:03:19---------------------------------------------------
2153 -----------------------------------------------------------------------*/
2154 SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark )
2156 vos::OGuard aGuard(Application::GetSolarMutex());
2157 SwClientIter aIter( *pDoc->GetUnoCallBack() );
2158 SwXReferenceMark* pxMark = (SwXReferenceMark*)aIter.First( TYPE( SwXReferenceMark ));
2159 while(pxMark)
2161 if(pxMark->GetMark() == pMark)
2162 break;
2163 pxMark = (SwXReferenceMark*)aIter.Next();
2165 if( !pxMark )
2166 pxMark = new SwXReferenceMark(pDoc, pMark);
2167 return pxMark;
2169 /******************************************************************
2171 ******************************************************************/
2172 /*-----------------11.03.98 11:18-------------------
2173 Gueltigkeitspruefung
2174 --------------------------------------------------*/
2175 void SwUnoCollection::Invalidate()
2177 bObjectValid = sal_False;
2178 pDoc = 0;