Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <config_features.h>
21 :
22 : #include <swtypes.hxx>
23 : #include <cmdid.h>
24 : #include <hintids.hxx>
25 : #include <svx/svxids.hrc>
26 : #include <doc.hxx>
27 : #include <IDocumentChartDataProviderAccess.hxx>
28 : #include <IDocumentFieldsAccess.hxx>
29 : #include <docary.hxx>
30 : #include <fmtcol.hxx>
31 : #include <poolfmt.hxx>
32 : #include <unocoll.hxx>
33 : #include <unosett.hxx>
34 : #include <fmtanchr.hxx>
35 : #include <ndtxt.hxx>
36 : #include <section.hxx>
37 : #include <IMark.hxx>
38 : #include <ftnidx.hxx>
39 : #include <fmtftn.hxx>
40 : #include <txtftn.hxx>
41 : #include <fmtpdsc.hxx>
42 : #include <pagedesc.hxx>
43 : #include <osl/mutex.hxx>
44 : #include <com/sun/star/text/XTextTableCursor.hpp>
45 : #include <com/sun/star/text/XTextTablesSupplier.hpp>
46 : #include <com/sun/star/text/TableColumnSeparator.hpp>
47 : #include <com/sun/star/text/XTextTable.hpp>
48 : #include <svl/PasswordHelper.hxx>
49 : #include <svtools/unoimap.hxx>
50 : #include <svtools/unoevent.hxx>
51 : #include <unotbl.hxx>
52 : #include <unostyle.hxx>
53 : #include <unofield.hxx>
54 : #include <unoidx.hxx>
55 : #include <unoframe.hxx>
56 : #include <textboxhelper.hxx>
57 : #include <unofootnote.hxx>
58 : #include <vcl/svapp.hxx>
59 : #include <fmtcntnt.hxx>
60 : #include <authfld.hxx>
61 : #include <SwXTextDefaults.hxx>
62 : #include <unochart.hxx>
63 : #include <comphelper/makesequence.hxx>
64 : #include <comphelper/sequence.hxx>
65 : #include <cppuhelper/supportsservice.hxx>
66 : #include <list>
67 : #include <iterator>
68 : #include <unosection.hxx>
69 : #include <unoparagraph.hxx>
70 : #include <unobookmark.hxx>
71 : #include <unorefmark.hxx>
72 : #include <unometa.hxx>
73 : #include "docsh.hxx"
74 : #include <calbck.hxx>
75 : #include <com/sun/star/document/XCodeNameQuery.hpp>
76 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
77 : #include <com/sun/star/form/XFormsSupplier.hpp>
78 : #include <com/sun/star/script/ModuleInfo.hpp>
79 : #include <com/sun/star/script/ModuleType.hpp>
80 : #include <com/sun/star/script/ScriptEventDescriptor.hpp>
81 : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
82 : #include <vbahelper/vbaaccesshelper.hxx>
83 : #include <basic/basmgr.hxx>
84 : #include <comphelper/processfactory.hxx>
85 : #include <comphelper/sequence.hxx>
86 : #include <cppuhelper/implbase.hxx>
87 :
88 : using namespace ::com::sun::star;
89 : using namespace ::com::sun::star::document;
90 : using namespace ::com::sun::star::uno;
91 : using namespace ::com::sun::star::text;
92 : using namespace ::com::sun::star::container;
93 : using namespace ::com::sun::star::lang;
94 :
95 : #if HAVE_FEATURE_SCRIPTING
96 :
97 60 : class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper< document::XCodeNameQuery >
98 : {
99 : SwDocShell* mpDocShell;
100 : OUString msThisDocumentCodeName;
101 : public:
102 30 : explicit SwVbaCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
103 : // XCodeNameQuery
104 :
105 30 : OUString SAL_CALL getCodeNameForContainer( const uno::Reference< uno::XInterface >& /*xIf*/ ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE
106 : {
107 : // #FIXME not implemented...
108 30 : return OUString();
109 : }
110 :
111 30 : OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException, std::exception ) SAL_OVERRIDE
112 : {
113 : // Initialise the code name
114 30 : if ( msThisDocumentCodeName.isEmpty() )
115 : {
116 : try
117 : {
118 30 : uno::Reference< beans::XPropertySet > xProps( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
119 60 : uno::Reference< container::XNameAccess > xLibContainer( xProps->getPropertyValue("BasicLibraries"), uno::UNO_QUERY_THROW );
120 60 : OUString sProjectName( "Standard");
121 30 : if ( !mpDocShell->GetBasicManager()->GetName().isEmpty() )
122 : {
123 0 : sProjectName = mpDocShell->GetBasicManager()->GetName();
124 : }
125 60 : uno::Reference< container::XNameAccess > xLib( xLibContainer->getByName( sProjectName ), uno::UNO_QUERY_THROW );
126 60 : uno::Sequence< OUString > sModuleNames = xLib->getElementNames();
127 60 : uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
128 :
129 30 : for ( sal_Int32 i=0; i < sModuleNames.getLength(); ++i )
130 : {
131 0 : script::ModuleInfo mInfo;
132 :
133 0 : if ( xVBAModuleInfo->hasModuleInfo( sModuleNames[ i ] ) && xVBAModuleInfo->getModuleInfo( sModuleNames[ i ] ).ModuleType == script::ModuleType::DOCUMENT )
134 : {
135 0 : msThisDocumentCodeName = sModuleNames[ i ];
136 0 : break;
137 : }
138 30 : }
139 : }
140 0 : catch( uno::Exception& )
141 : {
142 : }
143 : }
144 30 : OUString sCodeName;
145 30 : if ( mpDocShell )
146 : {
147 : // need to find the page ( and index ) for this control
148 30 : uno::Reference< drawing::XDrawPageSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
149 60 : uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
150 :
151 : try
152 : {
153 30 : uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex, uno::UNO_QUERY_THROW );
154 60 : uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
155 : // get the www-standard container
156 60 : uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
157 30 : sal_Int32 nCntrls = xFormControls->getCount();
158 60 : for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
159 : {
160 60 : uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
161 60 : bool bMatched = ( xControl == xIf );
162 60 : if ( bMatched )
163 : {
164 30 : sCodeName = msThisDocumentCodeName;
165 30 : break;
166 : }
167 60 : }
168 : }
169 0 : catch( uno::Exception& )
170 : {
171 30 : }
172 : }
173 : // #TODO Probably should throw here ( if !bMatched )
174 30 : return sCodeName;
175 : }
176 : };
177 :
178 : typedef std::unordered_map< OUString, OUString, OUStringHash > StringHashMap;
179 :
180 198 : class SwVbaProjectNameProvider : public ::cppu::WeakImplHelper< container::XNameContainer >
181 : {
182 : StringHashMap mTemplateToProject;
183 : public:
184 99 : SwVbaProjectNameProvider()
185 99 : {
186 99 : }
187 0 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
188 : {
189 0 : return ( mTemplateToProject.find( aName ) != mTemplateToProject.end() );
190 : }
191 0 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
192 : {
193 0 : if ( !hasByName( aName ) )
194 0 : throw container::NoSuchElementException();
195 0 : return uno::makeAny( mTemplateToProject.find( aName )->second );
196 : }
197 0 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
198 : {
199 0 : uno::Sequence< OUString > aElements( mTemplateToProject.size() );
200 0 : StringHashMap::iterator it_end = mTemplateToProject.end();
201 0 : sal_Int32 index = 0;
202 0 : for ( StringHashMap::iterator it = mTemplateToProject.begin(); it != it_end; ++it, ++index )
203 0 : aElements[ index ] = it->first;
204 0 : return aElements;
205 : }
206 :
207 0 : virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw ( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException, com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
208 : {
209 :
210 0 : OUString sProjectName;
211 0 : aElement >>= sProjectName;
212 : SAL_INFO("sw.uno", "Template cache inserting template name " << aName
213 : << " with project " << sProjectName);
214 0 : mTemplateToProject[ aName ] = sProjectName;
215 0 : }
216 :
217 0 : virtual void SAL_CALL removeByName( const OUString& Name ) throw ( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
218 : {
219 0 : if ( !hasByName( Name ) )
220 0 : throw container::NoSuchElementException();
221 0 : mTemplateToProject.erase( Name );
222 0 : }
223 0 : virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw ( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
224 : {
225 0 : if ( !hasByName( aName ) )
226 0 : throw container::NoSuchElementException();
227 0 : insertByName( aName, aElement ); // insert will overwrite
228 0 : }
229 : // XElemenAccess
230 0 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
231 : {
232 0 : return ::cppu::UnoType<OUString>::get();
233 : }
234 0 : virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
235 : {
236 :
237 0 : return ( !mTemplateToProject.empty() );
238 : }
239 :
240 : };
241 :
242 2 : class SwVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper< container::XNameAccess >
243 : {
244 : SwDocShell* mpDocShell;
245 : public:
246 1 : explicit SwVbaObjectForCodeNameProvider( SwDocShell* pDocShell ) : mpDocShell( pDocShell )
247 : {
248 : // #FIXME #TODO is the code name for ThisDocument read anywhere?
249 1 : }
250 :
251 1 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE
252 : {
253 : // #FIXME #TODO we really need to be checking against the codename for
254 : // ThisDocument
255 1 : if ( aName == "ThisDocument" )
256 1 : return sal_True;
257 0 : return sal_False;
258 : }
259 :
260 1 : ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
261 : {
262 1 : if ( !hasByName( aName ) )
263 0 : throw container::NoSuchElementException();
264 1 : uno::Sequence< uno::Any > aArgs( 2 );
265 1 : aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
266 1 : aArgs[1] = uno::Any( mpDocShell->GetModel() );
267 2 : uno::Reference< uno::XInterface > xDocObj = ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.word.Document" , aArgs );
268 : SAL_INFO("sw.uno",
269 : "Creating Object ( ooo.vba.word.Document ) 0x" << xDocObj.get());
270 2 : return uno::makeAny( xDocObj );
271 : }
272 0 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE
273 : {
274 0 : uno::Sequence< OUString > aNames;
275 0 : return aNames;
276 : }
277 : // XElemenAccess
278 0 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE { return uno::Type(); }
279 0 : virtual sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE { return sal_True; }
280 :
281 : };
282 :
283 : #endif
284 :
285 : struct ProvNamesId_Type
286 : {
287 : const char * pName;
288 : sal_uInt16 nType;
289 : };
290 :
291 : // note: this thing is indexed as an array, so do not insert/remove entries!
292 : const ProvNamesId_Type aProvNamesId[] =
293 : {
294 : { "com.sun.star.text.TextTable", SW_SERVICE_TYPE_TEXTTABLE },
295 : { "com.sun.star.text.TextFrame", SW_SERVICE_TYPE_TEXTFRAME },
296 : { "com.sun.star.text.GraphicObject", SW_SERVICE_TYPE_GRAPHIC },
297 : { "com.sun.star.text.TextEmbeddedObject", SW_SERVICE_TYPE_OLE },
298 : { "com.sun.star.text.Bookmark", SW_SERVICE_TYPE_BOOKMARK },
299 : { "com.sun.star.text.Footnote", SW_SERVICE_TYPE_FOOTNOTE },
300 : { "com.sun.star.text.Endnote", SW_SERVICE_TYPE_ENDNOTE },
301 : { "com.sun.star.text.DocumentIndexMark", SW_SERVICE_TYPE_INDEXMARK },
302 : { "com.sun.star.text.DocumentIndex", SW_SERVICE_TYPE_INDEX },
303 : { "com.sun.star.text.ReferenceMark", SW_SERVICE_REFERENCE_MARK },
304 : { "com.sun.star.style.CharacterStyle", SW_SERVICE_STYLE_CHARACTER_STYLE },
305 : { "com.sun.star.style.ParagraphStyle", SW_SERVICE_STYLE_PARAGRAPH_STYLE },
306 : { "com.sun.star.style.FrameStyle", SW_SERVICE_STYLE_FRAME_STYLE },
307 : { "com.sun.star.style.PageStyle", SW_SERVICE_STYLE_PAGE_STYLE },
308 : { "com.sun.star.style.NumberingStyle", SW_SERVICE_STYLE_NUMBERING_STYLE },
309 : { "com.sun.star.text.ContentIndexMark", SW_SERVICE_CONTENT_INDEX_MARK },
310 : { "com.sun.star.text.ContentIndex", SW_SERVICE_CONTENT_INDEX },
311 : { "com.sun.star.text.UserIndexMark", SW_SERVICE_USER_INDEX_MARK },
312 : { "com.sun.star.text.UserIndex", SW_SERVICE_USER_INDEX },
313 : { "com.sun.star.text.TextSection", SW_SERVICE_TEXT_SECTION },
314 : { "com.sun.star.text.TextField.DateTime", SW_SERVICE_FIELDTYPE_DATETIME },
315 : { "com.sun.star.text.TextField.User", SW_SERVICE_FIELDTYPE_USER },
316 : { "com.sun.star.text.TextField.SetExpression", SW_SERVICE_FIELDTYPE_SET_EXP },
317 : { "com.sun.star.text.TextField.GetExpression", SW_SERVICE_FIELDTYPE_GET_EXP },
318 : { "com.sun.star.text.TextField.FileName", SW_SERVICE_FIELDTYPE_FILE_NAME },
319 : { "com.sun.star.text.TextField.PageNumber", SW_SERVICE_FIELDTYPE_PAGE_NUM },
320 : { "com.sun.star.text.TextField.Author", SW_SERVICE_FIELDTYPE_AUTHOR },
321 : { "com.sun.star.text.TextField.Chapter", SW_SERVICE_FIELDTYPE_CHAPTER },
322 : { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
323 : { "com.sun.star.text.TextField.GetReference", SW_SERVICE_FIELDTYPE_GET_REFERENCE },
324 : { "com.sun.star.text.TextField.ConditionalText", SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
325 : { "com.sun.star.text.TextField.Annotation", SW_SERVICE_FIELDTYPE_ANNOTATION },
326 : { "com.sun.star.text.TextField.Input", SW_SERVICE_FIELDTYPE_INPUT },
327 : { "com.sun.star.text.TextField.Macro", SW_SERVICE_FIELDTYPE_MACRO },
328 : { "com.sun.star.text.TextField.DDE", SW_SERVICE_FIELDTYPE_DDE },
329 : { "com.sun.star.text.TextField.HiddenParagraph", SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
330 : { "" /*com.sun.star.text.TextField.DocumentInfo"*/, SW_SERVICE_FIELDTYPE_DOC_INFO },
331 : { "com.sun.star.text.TextField.TemplateName", SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
332 : { "com.sun.star.text.TextField.ExtendedUser", SW_SERVICE_FIELDTYPE_USER_EXT },
333 : { "com.sun.star.text.TextField.ReferencePageSet", SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
334 : { "com.sun.star.text.TextField.ReferencePageGet", SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
335 : { "com.sun.star.text.TextField.JumpEdit", SW_SERVICE_FIELDTYPE_JUMP_EDIT },
336 : { "com.sun.star.text.TextField.Script", SW_SERVICE_FIELDTYPE_SCRIPT },
337 : { "com.sun.star.text.TextField.DatabaseNextSet", SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
338 : { "com.sun.star.text.TextField.DatabaseNumberOfSet", SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
339 : { "com.sun.star.text.TextField.DatabaseSetNumber", SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
340 : { "com.sun.star.text.TextField.Database", SW_SERVICE_FIELDTYPE_DATABASE },
341 : { "com.sun.star.text.TextField.DatabaseName", SW_SERVICE_FIELDTYPE_DATABASE_NAME },
342 : { "com.sun.star.text.TextField.TableFormula", SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
343 : { "com.sun.star.text.TextField.PageCount", SW_SERVICE_FIELDTYPE_PAGE_COUNT },
344 : { "com.sun.star.text.TextField.ParagraphCount", SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
345 : { "com.sun.star.text.TextField.WordCount", SW_SERVICE_FIELDTYPE_WORD_COUNT },
346 : { "com.sun.star.text.TextField.CharacterCount", SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
347 : { "com.sun.star.text.TextField.TableCount", SW_SERVICE_FIELDTYPE_TABLE_COUNT },
348 : { "com.sun.star.text.TextField.GraphicObjectCount", SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
349 : { "com.sun.star.text.TextField.EmbeddedObjectCount", SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
350 : { "com.sun.star.text.TextField.DocInfo.ChangeAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
351 : { "com.sun.star.text.TextField.DocInfo.ChangeDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
352 : { "com.sun.star.text.TextField.DocInfo.EditTime", SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
353 : { "com.sun.star.text.TextField.DocInfo.Description", SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
354 : { "com.sun.star.text.TextField.DocInfo.CreateAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
355 : { "com.sun.star.text.TextField.DocInfo.CreateDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
356 : { "", SW_SERVICE_FIELDTYPE_DUMMY_0 },
357 : { "", SW_SERVICE_FIELDTYPE_DUMMY_1 },
358 : { "", SW_SERVICE_FIELDTYPE_DUMMY_2 },
359 : { "", SW_SERVICE_FIELDTYPE_DUMMY_3 },
360 : { "com.sun.star.text.TextField.DocInfo.Custom", SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
361 : { "com.sun.star.text.TextField.DocInfo.PrintAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
362 : { "com.sun.star.text.TextField.DocInfo.PrintDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
363 : { "com.sun.star.text.TextField.DocInfo.KeyWords", SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
364 : { "com.sun.star.text.TextField.DocInfo.Subject", SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
365 : { "com.sun.star.text.TextField.DocInfo.Title", SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
366 : { "com.sun.star.text.TextField.DocInfo.Revision", SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
367 : { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
368 : { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
369 : { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN },
370 : { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD },
371 : { "", SW_SERVICE_FIELDTYPE_DUMMY_4 },
372 : { "", SW_SERVICE_FIELDTYPE_DUMMY_5 },
373 : { "", SW_SERVICE_FIELDTYPE_DUMMY_6 },
374 : { "", SW_SERVICE_FIELDTYPE_DUMMY_7 },
375 : { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER },
376 : { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE },
377 : { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP },
378 : { "com.sun.star.text.FieldMaster.Database", SW_SERVICE_FIELDMASTER_DATABASE },
379 : { "com.sun.star.text.FieldMaster.Bibliography", SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY },
380 : { "", SW_SERVICE_FIELDMASTER_DUMMY2 },
381 : { "", SW_SERVICE_FIELDMASTER_DUMMY3 },
382 : { "", SW_SERVICE_FIELDMASTER_DUMMY4 },
383 : { "", SW_SERVICE_FIELDMASTER_DUMMY5 },
384 : { "com.sun.star.text.IllustrationsIndex", SW_SERVICE_INDEX_ILLUSTRATIONS },
385 : { "com.sun.star.text.ObjectIndex", SW_SERVICE_INDEX_OBJECTS },
386 : { "com.sun.star.text.TableIndex", SW_SERVICE_INDEX_TABLES },
387 : { "com.sun.star.text.Bibliography", SW_SERVICE_INDEX_BIBLIOGRAPHY },
388 : { "com.sun.star.text.Paragraph", SW_SERVICE_PARAGRAPH },
389 : { "com.sun.star.text.TextField.InputUser", SW_SERVICE_FIELDTYPE_INPUT_USER },
390 : { "com.sun.star.text.TextField.HiddenText", SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
391 : { "com.sun.star.style.ConditionalParagraphStyle", SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE },
392 : { "com.sun.star.text.NumberingRules", SW_SERVICE_NUMBERING_RULES },
393 : { "com.sun.star.text.TextColumns", SW_SERVICE_TEXT_COLUMNS },
394 : { "com.sun.star.text.IndexHeaderSection", SW_SERVICE_INDEX_HEADER_SECTION },
395 : { "com.sun.star.text.Defaults", SW_SERVICE_DEFAULTS },
396 : { "com.sun.star.image.ImageMapRectangleObject", SW_SERVICE_IMAP_RECTANGLE },
397 : { "com.sun.star.image.ImageMapCircleObject", SW_SERVICE_IMAP_CIRCLE },
398 : { "com.sun.star.image.ImageMapPolygonObject", SW_SERVICE_IMAP_POLYGON },
399 : { "com.sun.star.text.TextGraphicObject", SW_SERVICE_TYPE_TEXT_GRAPHIC },
400 : { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER },
401 : { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK },
402 : { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK },
403 : { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META },
404 : { "ooo.vba.VBAObjectModuleObjectProvider", SW_SERVICE_VBAOBJECTPROVIDER },
405 : { "ooo.vba.VBACodeNameProvider", SW_SERVICE_VBACODENAMEPROVIDER },
406 : { "ooo.vba.VBAProjectNameProvider", SW_SERVICE_VBAPROJECTNAMEPROVIDER },
407 : { "ooo.vba.VBAGlobals", SW_SERVICE_VBAGLOBALS },
408 :
409 : // case-correct versions of the service names (see #i67811)
410 : { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME },
411 : { CSS_TEXT_TEXTFIELD_USER, SW_SERVICE_FIELDTYPE_USER },
412 : { CSS_TEXT_TEXTFIELD_SET_EXPRESSION, SW_SERVICE_FIELDTYPE_SET_EXP },
413 : { CSS_TEXT_TEXTFIELD_GET_EXPRESSION, SW_SERVICE_FIELDTYPE_GET_EXP },
414 : { CSS_TEXT_TEXTFIELD_FILE_NAME, SW_SERVICE_FIELDTYPE_FILE_NAME },
415 : { CSS_TEXT_TEXTFIELD_PAGE_NUMBER, SW_SERVICE_FIELDTYPE_PAGE_NUM },
416 : { CSS_TEXT_TEXTFIELD_AUTHOR, SW_SERVICE_FIELDTYPE_AUTHOR },
417 : { CSS_TEXT_TEXTFIELD_CHAPTER, SW_SERVICE_FIELDTYPE_CHAPTER },
418 : { CSS_TEXT_TEXTFIELD_GET_REFERENCE, SW_SERVICE_FIELDTYPE_GET_REFERENCE },
419 : { CSS_TEXT_TEXTFIELD_CONDITIONAL_TEXT, SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT },
420 : { CSS_TEXT_TEXTFIELD_ANNOTATION, SW_SERVICE_FIELDTYPE_ANNOTATION },
421 : { CSS_TEXT_TEXTFIELD_INPUT, SW_SERVICE_FIELDTYPE_INPUT },
422 : { CSS_TEXT_TEXTFIELD_MACRO, SW_SERVICE_FIELDTYPE_MACRO },
423 : { CSS_TEXT_TEXTFIELD_DDE, SW_SERVICE_FIELDTYPE_DDE },
424 : { CSS_TEXT_TEXTFIELD_HIDDEN_PARAGRAPH, SW_SERVICE_FIELDTYPE_HIDDEN_PARA },
425 : { CSS_TEXT_TEXTFIELD_TEMPLATE_NAME, SW_SERVICE_FIELDTYPE_TEMPLATE_NAME },
426 : { CSS_TEXT_TEXTFIELD_EXTENDED_USER, SW_SERVICE_FIELDTYPE_USER_EXT },
427 : { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_SET, SW_SERVICE_FIELDTYPE_REF_PAGE_SET },
428 : { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_GET, SW_SERVICE_FIELDTYPE_REF_PAGE_GET },
429 : { CSS_TEXT_TEXTFIELD_JUMP_EDIT, SW_SERVICE_FIELDTYPE_JUMP_EDIT },
430 : { CSS_TEXT_TEXTFIELD_SCRIPT, SW_SERVICE_FIELDTYPE_SCRIPT },
431 : { CSS_TEXT_TEXTFIELD_DATABASE_NEXT_SET, SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET },
432 : { CSS_TEXT_TEXTFIELD_DATABASE_NUMBER_OF_SET, SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET },
433 : { CSS_TEXT_TEXTFIELD_DATABASE_SET_NUMBER, SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM },
434 : { CSS_TEXT_TEXTFIELD_DATABASE, SW_SERVICE_FIELDTYPE_DATABASE },
435 : { CSS_TEXT_TEXTFIELD_DATABASE_NAME, SW_SERVICE_FIELDTYPE_DATABASE_NAME },
436 : { CSS_TEXT_TEXTFIELD_TABLE_FORMULA, SW_SERVICE_FIELDTYPE_TABLE_FORMULA },
437 : { CSS_TEXT_TEXTFIELD_PAGE_COUNT, SW_SERVICE_FIELDTYPE_PAGE_COUNT },
438 : { CSS_TEXT_TEXTFIELD_PARAGRAPH_COUNT, SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT },
439 : { CSS_TEXT_TEXTFIELD_WORD_COUNT, SW_SERVICE_FIELDTYPE_WORD_COUNT },
440 : { CSS_TEXT_TEXTFIELD_CHARACTER_COUNT, SW_SERVICE_FIELDTYPE_CHARACTER_COUNT },
441 : { CSS_TEXT_TEXTFIELD_TABLE_COUNT, SW_SERVICE_FIELDTYPE_TABLE_COUNT },
442 : { CSS_TEXT_TEXTFIELD_GRAPHIC_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT },
443 : { CSS_TEXT_TEXTFIELD_EMBEDDED_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT },
444 : { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR },
445 : { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME },
446 : { CSS_TEXT_TEXTFIELD_DOCINFO_EDIT_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME },
447 : { CSS_TEXT_TEXTFIELD_DOCINFO_DESCRIPTION, SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION },
448 : { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR },
449 : { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME },
450 : { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR },
451 : { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME },
452 : { CSS_TEXT_TEXTFIELD_DOCINFO_KEY_WORDS, SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS },
453 : { CSS_TEXT_TEXTFIELD_DOCINFO_SUBJECT, SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT },
454 : { CSS_TEXT_TEXTFIELD_DOCINFO_TITLE, SW_SERVICE_FIELDTYPE_DOCINFO_TITLE },
455 : { CSS_TEXT_TEXTFIELD_DOCINFO_REVISION, SW_SERVICE_FIELDTYPE_DOCINFO_REVISION },
456 : { CSS_TEXT_TEXTFIELD_DOCINFO_CUSTOM, SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM },
457 : { CSS_TEXT_TEXTFIELD_BIBLIOGRAPHY, SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY },
458 : { CSS_TEXT_TEXTFIELD_COMBINED_CHARACTERS, SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS },
459 : { CSS_TEXT_TEXTFIELD_DROP_DOWN, SW_SERVICE_FIELDTYPE_DROPDOWN },
460 : { CSS_TEXT_TEXTFIELD_INPUT_USER, SW_SERVICE_FIELDTYPE_INPUT_USER },
461 : { CSS_TEXT_TEXTFIELD_HIDDEN_TEXT, SW_SERVICE_FIELDTYPE_HIDDEN_TEXT },
462 : { CSS_TEXT_FIELDMASTER_USER, SW_SERVICE_FIELDMASTER_USER },
463 : { CSS_TEXT_FIELDMASTER_DDE, SW_SERVICE_FIELDMASTER_DDE },
464 : { CSS_TEXT_FIELDMASTER_SET_EXPRESSION, SW_SERVICE_FIELDMASTER_SET_EXP },
465 : { CSS_TEXT_FIELDMASTER_DATABASE, SW_SERVICE_FIELDMASTER_DATABASE },
466 : { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY, SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY }
467 : };
468 :
469 76 : const SvEventDescription* sw_GetSupportedMacroItems()
470 : {
471 : static const SvEventDescription aMacroDescriptionsImpl[] =
472 : {
473 : { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
474 : { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
475 : { 0, NULL }
476 : };
477 :
478 76 : return aMacroDescriptionsImpl;
479 : }
480 :
481 622 : OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType)
482 : {
483 622 : SolarMutexGuard aGuard;
484 622 : OUString sRet;
485 622 : const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
486 622 : if(nObjectType < nEntries)
487 622 : sRet = OUString::createFromAscii(aProvNamesId[nObjectType].pName);
488 622 : return sRet;
489 : }
490 :
491 20 : uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames()
492 : {
493 20 : const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
494 20 : uno::Sequence<OUString> aRet(nEntries);
495 20 : OUString* pArray = aRet.getArray();
496 20 : sal_uInt16 n = 0;
497 3440 : for(sal_uInt16 i = 0; i < nEntries; i++)
498 : {
499 3420 : OUString sProv(OUString::createFromAscii(aProvNamesId[i].pName));
500 3420 : if(!sProv.isEmpty())
501 : {
502 3140 : pArray[n] = sProv;
503 3140 : n++;
504 : }
505 3420 : }
506 20 : aRet.realloc(n);
507 20 : return aRet;
508 :
509 : }
510 :
511 66017 : sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName)
512 : {
513 66017 : const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
514 3276561 : for(sal_uInt16 i = 0; i < nEntries; i++ )
515 : {
516 3264477 : if (rServiceName.equalsAscii(aProvNamesId[i].pName))
517 53933 : return aProvNamesId[i].nType;
518 : }
519 12084 : return SW_SERVICE_INVALID;
520 : }
521 :
522 : uno::Reference<uno::XInterface>
523 54385 : SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc)
524 : {
525 54385 : SolarMutexGuard aGuard;
526 54385 : uno::Reference< uno::XInterface > xRet;
527 54385 : switch(nObjectType)
528 : {
529 : case SW_SERVICE_TYPE_TEXTTABLE:
530 : {
531 138 : xRet = SwXTextTable::CreateXTextTable(0);
532 : }
533 138 : break;
534 : case SW_SERVICE_TYPE_TEXTFRAME:
535 : {
536 768 : xRet = SwXTextFrame::CreateXTextFrame(rDoc, 0);
537 : }
538 768 : break;
539 : case SW_SERVICE_TYPE_GRAPHIC :
540 : case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ :
541 : {
542 474 : xRet = SwXTextGraphicObject::CreateXTextGraphicObject(rDoc, 0);
543 :
544 : }
545 474 : break;
546 : case SW_SERVICE_TYPE_OLE :
547 : {
548 409 : xRet = SwXTextEmbeddedObject::CreateXTextEmbeddedObject(rDoc, 0);
549 : }
550 409 : break;
551 : case SW_SERVICE_TYPE_BOOKMARK :
552 : {
553 4785 : xRet = SwXBookmark::CreateXBookmark(rDoc, 0);
554 : }
555 4785 : break;
556 : case SW_SERVICE_TYPE_FIELDMARK :
557 : {
558 97 : xRet = SwXFieldmark::CreateXFieldmark(rDoc, 0, false);
559 : }
560 97 : break;
561 : case SW_SERVICE_TYPE_FORMFIELDMARK :
562 : {
563 30 : xRet = SwXFieldmark::CreateXFieldmark(rDoc, 0, true);
564 : }
565 30 : break;
566 : case SW_SERVICE_VBAOBJECTPROVIDER :
567 : #if HAVE_FEATURE_SCRIPTING
568 : {
569 : SwVbaObjectForCodeNameProvider* pObjProv =
570 1 : new SwVbaObjectForCodeNameProvider(rDoc.GetDocShell());
571 1 : xRet = static_cast<cppu::OWeakObject*>(pObjProv);
572 : }
573 : #endif
574 1 : break;
575 : case SW_SERVICE_VBACODENAMEPROVIDER :
576 : #if HAVE_FEATURE_SCRIPTING
577 : {
578 254 : if (rDoc.GetDocShell() && ooo::vba::isAlienWordDoc(*rDoc.GetDocShell()))
579 : {
580 30 : SwVbaCodeNameProvider* pObjProv = new SwVbaCodeNameProvider(rDoc.GetDocShell());
581 30 : xRet = static_cast<cppu::OWeakObject*>(pObjProv);
582 : }
583 : }
584 : #endif
585 254 : break;
586 : case SW_SERVICE_VBAPROJECTNAMEPROVIDER :
587 : #if HAVE_FEATURE_SCRIPTING
588 : {
589 123 : uno::Reference< container::XNameContainer > xProjProv = rDoc.GetVBATemplateToProjectCache();
590 369 : if (!xProjProv.is() && rDoc.GetDocShell()
591 246 : && ooo::vba::isAlienWordDoc(*rDoc.GetDocShell()))
592 : {
593 99 : xProjProv = new SwVbaProjectNameProvider;
594 99 : rDoc.SetVBATemplateToProjectCache(xProjProv);
595 : }
596 123 : xRet = xProjProv;
597 : }
598 : #endif
599 123 : break;
600 : case SW_SERVICE_VBAGLOBALS :
601 : #if HAVE_FEATURE_SCRIPTING
602 : {
603 1 : uno::Any aGlobs;
604 1 : BasicManager *pBasicMan = rDoc.GetDocShell()->GetBasicManager();
605 1 : if (pBasicMan && !pBasicMan->GetGlobalUNOConstant("VBAGlobals", aGlobs))
606 : {
607 0 : uno::Sequence< uno::Any > aArgs(1);
608 0 : aArgs[ 0 ] <<= rDoc.GetDocShell()->GetModel();
609 0 : aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.word.Globals", aArgs );
610 0 : pBasicMan->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
611 : }
612 1 : aGlobs >>= xRet;
613 : }
614 : #endif
615 1 : break;
616 :
617 : case SW_SERVICE_TYPE_FOOTNOTE :
618 85 : xRet = SwXFootnote::CreateXFootnote(rDoc, 0, false);
619 85 : break;
620 : case SW_SERVICE_TYPE_ENDNOTE :
621 19 : xRet = SwXFootnote::CreateXFootnote(rDoc, 0, true);
622 19 : break;
623 : case SW_SERVICE_CONTENT_INDEX_MARK :
624 : case SW_SERVICE_USER_INDEX_MARK :
625 : case SW_SERVICE_TYPE_INDEXMARK:
626 : {
627 169 : TOXTypes eType = TOX_INDEX;
628 169 : if(SW_SERVICE_CONTENT_INDEX_MARK== nObjectType)
629 1 : eType = TOX_CONTENT;
630 168 : else if(SW_SERVICE_USER_INDEX_MARK == nObjectType)
631 0 : eType = TOX_USER;
632 169 : xRet = SwXDocumentIndexMark::CreateXDocumentIndexMark(rDoc, 0, eType);
633 : }
634 169 : break;
635 : case SW_SERVICE_CONTENT_INDEX :
636 : case SW_SERVICE_USER_INDEX :
637 : case SW_SERVICE_TYPE_INDEX :
638 : case SW_SERVICE_INDEX_ILLUSTRATIONS:
639 : case SW_SERVICE_INDEX_OBJECTS :
640 : case SW_SERVICE_INDEX_TABLES:
641 : case SW_SERVICE_INDEX_BIBLIOGRAPHY :
642 : {
643 119 : TOXTypes eType = TOX_INDEX;
644 119 : if(SW_SERVICE_CONTENT_INDEX == nObjectType)
645 63 : eType = TOX_CONTENT;
646 56 : else if(SW_SERVICE_USER_INDEX == nObjectType)
647 2 : eType = TOX_USER;
648 54 : else if(SW_SERVICE_INDEX_ILLUSTRATIONS == nObjectType)
649 : {
650 9 : eType = TOX_ILLUSTRATIONS;
651 : }
652 45 : else if(SW_SERVICE_INDEX_OBJECTS == nObjectType)
653 : {
654 2 : eType = TOX_OBJECTS;
655 : }
656 43 : else if(SW_SERVICE_INDEX_BIBLIOGRAPHY == nObjectType)
657 : {
658 18 : eType = TOX_AUTHORITIES;
659 : }
660 25 : else if(SW_SERVICE_INDEX_TABLES == nObjectType)
661 : {
662 2 : eType = TOX_TABLES;
663 : }
664 119 : xRet = SwXDocumentIndex::CreateXDocumentIndex(rDoc, 0, eType);
665 : }
666 119 : break;
667 : case SW_SERVICE_INDEX_HEADER_SECTION :
668 : case SW_SERVICE_TEXT_SECTION :
669 408 : xRet = SwXTextSection::CreateXTextSection(0,
670 204 : (SW_SERVICE_INDEX_HEADER_SECTION == nObjectType));
671 :
672 204 : break;
673 : case SW_SERVICE_REFERENCE_MARK :
674 36 : xRet = SwXReferenceMark::CreateXReferenceMark(rDoc, 0);
675 36 : break;
676 : case SW_SERVICE_STYLE_CHARACTER_STYLE:
677 : case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
678 : case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
679 : case SW_SERVICE_STYLE_FRAME_STYLE:
680 : case SW_SERVICE_STYLE_PAGE_STYLE:
681 : case SW_SERVICE_STYLE_NUMBERING_STYLE:
682 : {
683 40932 : SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR;
684 40932 : switch(nObjectType)
685 : {
686 : case SW_SERVICE_STYLE_PARAGRAPH_STYLE:
687 : case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE:
688 9726 : eFamily = SFX_STYLE_FAMILY_PARA;
689 9726 : break;
690 : case SW_SERVICE_STYLE_FRAME_STYLE:
691 38 : eFamily = SFX_STYLE_FAMILY_FRAME;
692 38 : break;
693 : case SW_SERVICE_STYLE_PAGE_STYLE:
694 436 : eFamily = SFX_STYLE_FAMILY_PAGE;
695 436 : break;
696 : case SW_SERVICE_STYLE_NUMBERING_STYLE:
697 18929 : eFamily = SFX_STYLE_FAMILY_PSEUDO;
698 18929 : break;
699 : }
700 : SwXStyle* pNewStyle = (SFX_STYLE_FAMILY_PAGE == eFamily)
701 436 : ? new SwXPageStyle(rDoc.GetDocShell())
702 : : (eFamily == SFX_STYLE_FAMILY_FRAME)
703 38 : ? new SwXFrameStyle(&rDoc)
704 41406 : : new SwXStyle(&rDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE);
705 40932 : xRet = static_cast<cppu::OWeakObject*>(pNewStyle);
706 : }
707 40932 : break;
708 : case SW_SERVICE_FIELDTYPE_DATETIME:
709 : case SW_SERVICE_FIELDTYPE_USER:
710 : case SW_SERVICE_FIELDTYPE_SET_EXP:
711 : case SW_SERVICE_FIELDTYPE_GET_EXP:
712 : case SW_SERVICE_FIELDTYPE_FILE_NAME:
713 : case SW_SERVICE_FIELDTYPE_PAGE_NUM:
714 : case SW_SERVICE_FIELDTYPE_AUTHOR:
715 : case SW_SERVICE_FIELDTYPE_CHAPTER:
716 : case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
717 : case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
718 : case SW_SERVICE_FIELDTYPE_INPUT:
719 : case SW_SERVICE_FIELDTYPE_MACRO:
720 : case SW_SERVICE_FIELDTYPE_DDE:
721 : case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
722 : case SW_SERVICE_FIELDTYPE_DOC_INFO:
723 : case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
724 : case SW_SERVICE_FIELDTYPE_USER_EXT:
725 : case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
726 : case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
727 : case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
728 : case SW_SERVICE_FIELDTYPE_SCRIPT:
729 : case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET:
730 : case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET:
731 : case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM:
732 : case SW_SERVICE_FIELDTYPE_DATABASE:
733 : case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
734 : case SW_SERVICE_FIELDTYPE_PAGE_COUNT :
735 : case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT :
736 : case SW_SERVICE_FIELDTYPE_WORD_COUNT :
737 : case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT :
738 : case SW_SERVICE_FIELDTYPE_TABLE_COUNT :
739 : case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT :
740 : case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT :
741 : case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR :
742 : case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME :
743 : case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME :
744 : case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION :
745 : case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR :
746 : case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME :
747 : case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM :
748 : case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR :
749 : case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME :
750 : case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS :
751 : case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT :
752 : case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE :
753 : case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
754 : case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY:
755 : case SW_SERVICE_FIELDTYPE_INPUT_USER :
756 : case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT :
757 : case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS :
758 : case SW_SERVICE_FIELDTYPE_DROPDOWN :
759 : case SW_SERVICE_FIELDTYPE_TABLE_FORMULA:
760 : // NOTE: the sw.SwXAutoTextEntry unoapi test depends on pDoc = 0
761 650 : xRet = SwXTextField::CreateXTextField(0, 0, nObjectType);
762 650 : break;
763 : case SW_SERVICE_FIELDTYPE_ANNOTATION:
764 75 : xRet = SwXTextField::CreateXTextField(&rDoc, 0, nObjectType);
765 75 : break;
766 : case SW_SERVICE_FIELDMASTER_USER:
767 : case SW_SERVICE_FIELDMASTER_DDE:
768 : case SW_SERVICE_FIELDMASTER_SET_EXP :
769 : case SW_SERVICE_FIELDMASTER_DATABASE:
770 : {
771 130 : sal_uInt16 nResId = USHRT_MAX;
772 130 : switch(nObjectType)
773 : {
774 28 : case SW_SERVICE_FIELDMASTER_USER: nResId = RES_USERFLD; break;
775 0 : case SW_SERVICE_FIELDMASTER_DDE: nResId = RES_DDEFLD; break;
776 30 : case SW_SERVICE_FIELDMASTER_SET_EXP : nResId = RES_SETEXPFLD; break;
777 72 : case SW_SERVICE_FIELDMASTER_DATABASE: nResId = RES_DBFLD; break;
778 : }
779 130 : xRet = SwXFieldMaster::CreateXFieldMaster(&rDoc, 0, nResId);
780 : }
781 130 : break;
782 : case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY:
783 : {
784 5 : SwFieldType* pType = rDoc.getIDocumentFieldsAccess().GetFieldType(RES_AUTHORITY, aEmptyOUStr, true);
785 5 : if(!pType)
786 : {
787 5 : SwAuthorityFieldType aType(&rDoc);
788 5 : pType = rDoc.getIDocumentFieldsAccess().InsertFieldType(aType);
789 : }
790 5 : xRet = SwXFieldMaster::CreateXFieldMaster(&rDoc, pType);
791 : }
792 5 : break;
793 : case SW_SERVICE_PARAGRAPH :
794 12 : xRet = SwXParagraph::CreateXParagraph(rDoc, 0);
795 12 : break;
796 : case SW_SERVICE_NUMBERING_RULES :
797 46 : xRet = static_cast<cppu::OWeakObject*>(new SwXNumberingRules(rDoc));
798 46 : break;
799 : case SW_SERVICE_TEXT_COLUMNS :
800 82 : xRet = static_cast<cppu::OWeakObject*>(new SwXTextColumns(0));
801 82 : break;
802 : case SW_SERVICE_DEFAULTS:
803 4640 : xRet = static_cast<cppu::OWeakObject*>(new SwXTextDefaults(&rDoc));
804 4640 : break;
805 : case SW_SERVICE_IMAP_RECTANGLE :
806 0 : xRet = SvUnoImageMapRectangleObject_createInstance( sw_GetSupportedMacroItems() );
807 0 : break;
808 : case SW_SERVICE_IMAP_CIRCLE :
809 0 : xRet = SvUnoImageMapCircleObject_createInstance( sw_GetSupportedMacroItems() );
810 0 : break;
811 : case SW_SERVICE_IMAP_POLYGON :
812 1 : xRet = SvUnoImageMapPolygonObject_createInstance( sw_GetSupportedMacroItems() );
813 1 : break;
814 : case SW_SERVICE_CHART2_DATA_PROVIDER :
815 : // #i64497# If a chart is in a temporary document during clipoard
816 : // paste, there should be no data provider, so that own data is used
817 : // This should not happen during copy/paste, as this will unlink
818 : // charts using table data.
819 3 : if (rDoc.GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED)
820 3 : xRet = static_cast<cppu::OWeakObject*>(rDoc.getIDocumentChartDataProviderAccess().GetChartDataProvider( true /* create - if not yet available */ ));
821 : else
822 : SAL_WARN("sw.uno",
823 : "not creating chart data provider for embedded object");
824 :
825 3 : break;
826 : case SW_SERVICE_TYPE_META:
827 71 : xRet = SwXMeta::CreateXMeta(rDoc, false);
828 71 : break;
829 : case SW_SERVICE_FIELDTYPE_METAFIELD:
830 26 : xRet = SwXMeta::CreateXMeta(rDoc, true);
831 26 : break;
832 : default:
833 0 : throw uno::RuntimeException();
834 : }
835 54385 : return xRet;
836 : }
837 :
838 : //SMART_UNO_IMPLEMENTATION( SwXTextTables, UsrObject );
839 166 : SwXTextTables::SwXTextTables(SwDoc* pDc) :
840 166 : SwUnoCollection(pDc)
841 : {
842 :
843 166 : }
844 :
845 332 : SwXTextTables::~SwXTextTables()
846 : {
847 :
848 332 : }
849 :
850 106 : sal_Int32 SwXTextTables::getCount() throw( uno::RuntimeException, std::exception )
851 : {
852 106 : SolarMutexGuard aGuard;
853 106 : sal_Int32 nRet = 0;
854 106 : if(IsValid())
855 106 : nRet = static_cast<sal_Int32>(GetDoc()->GetTableFrameFormatCount(true));
856 106 : return nRet;
857 : }
858 :
859 99 : uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nIndex)
860 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
861 : {
862 99 : SolarMutexGuard aGuard;
863 99 : uno::Any aRet;
864 99 : if(IsValid())
865 : {
866 99 : if(0 <= nIndex && GetDoc()->GetTableFrameFormatCount(true) > static_cast<size_t>(nIndex))
867 : {
868 98 : SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(nIndex, true);
869 98 : uno::Reference< XTextTable > xTable = SwXTextTables::GetObject(rFormat);
870 : aRet.setValue( &xTable,
871 98 : cppu::UnoType<XTextTable>::get());
872 : }
873 : else
874 1 : throw IndexOutOfBoundsException();
875 : }
876 : else
877 0 : throw uno::RuntimeException();
878 99 : return aRet;
879 : }
880 :
881 5 : uno::Any SwXTextTables::getByName(const OUString& rItemName)
882 : throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception )
883 : {
884 5 : SolarMutexGuard aGuard;
885 5 : uno::Any aRet;
886 5 : if(IsValid())
887 : {
888 5 : const size_t nCount = GetDoc()->GetTableFrameFormatCount(true);
889 5 : uno::Reference< XTextTable > xTable;
890 7 : for( size_t i = 0; i < nCount; ++i)
891 : {
892 6 : SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true);
893 6 : if (rItemName == rFormat.GetName())
894 : {
895 4 : xTable = SwXTextTables::GetObject(rFormat);
896 : aRet.setValue(&xTable,
897 4 : cppu::UnoType<XTextTable>::get());
898 4 : break;
899 : }
900 : }
901 5 : if(!xTable.is())
902 1 : throw NoSuchElementException();
903 : }
904 : else
905 0 : throw uno::RuntimeException();
906 5 : return aRet;
907 : }
908 :
909 1 : uno::Sequence< OUString > SwXTextTables::getElementNames()
910 : throw( uno::RuntimeException, std::exception )
911 : {
912 1 : SolarMutexGuard aGuard;
913 1 : if(!IsValid())
914 0 : throw uno::RuntimeException();
915 1 : const size_t nCount = GetDoc()->GetTableFrameFormatCount(true);
916 1 : uno::Sequence<OUString> aSeq(static_cast<sal_Int32>(nCount));
917 1 : if(nCount)
918 : {
919 1 : OUString* pArray = aSeq.getArray();
920 3 : for( size_t i = 0; i < nCount; ++i)
921 : {
922 2 : SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true);
923 :
924 2 : pArray[i] = rFormat.GetName();
925 : }
926 : }
927 1 : return aSeq;
928 : }
929 :
930 2 : sal_Bool SwXTextTables::hasByName(const OUString& rName)
931 : throw( uno::RuntimeException, std::exception )
932 : {
933 2 : SolarMutexGuard aGuard;
934 2 : bool bRet= false;
935 2 : if(IsValid())
936 : {
937 2 : const size_t nCount = GetDoc()->GetTableFrameFormatCount(true);
938 4 : for( size_t i = 0; i < nCount; ++i)
939 : {
940 3 : SwFrameFormat& rFormat = GetDoc()->GetTableFrameFormat(i, true);
941 3 : if (rName == rFormat.GetName())
942 : {
943 1 : bRet = true;
944 1 : break;
945 : }
946 : }
947 : }
948 : else
949 0 : throw uno::RuntimeException();
950 2 : return bRet;
951 : }
952 :
953 : uno::Type SAL_CALL
954 1 : SwXTextTables::getElementType( )
955 : throw(uno::RuntimeException, std::exception)
956 : {
957 1 : return cppu::UnoType<XTextTable>::get();
958 : }
959 :
960 1 : sal_Bool SwXTextTables::hasElements() throw( uno::RuntimeException, std::exception )
961 : {
962 1 : SolarMutexGuard aGuard;
963 1 : if(!IsValid())
964 0 : throw uno::RuntimeException();
965 1 : return 0 != GetDoc()->GetTableFrameFormatCount(true);
966 : }
967 :
968 0 : OUString SwXTextTables::getImplementationName() throw( uno::RuntimeException, std::exception )
969 : {
970 0 : return OUString("SwXTextTables");
971 : }
972 :
973 0 : sal_Bool SwXTextTables::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
974 : {
975 0 : return cppu::supportsService(this, rServiceName);
976 : }
977 :
978 0 : uno::Sequence< OUString > SwXTextTables::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
979 : {
980 0 : uno::Sequence< OUString > aRet(1);
981 0 : OUString* pArr = aRet.getArray();
982 0 : pArr[0] = "com.sun.star.text.TextTables";
983 0 : return aRet;
984 : }
985 :
986 284 : uno::Reference<text::XTextTable> SwXTextTables::GetObject(SwFrameFormat& rFormat)
987 : {
988 284 : return SwXTextTable::CreateXTextTable(& rFormat);
989 : }
990 :
991 : namespace
992 : {
993 : template<FlyCntType T> struct UnoFrameWrap_traits {};
994 :
995 : template<>
996 : struct UnoFrameWrap_traits<FLYCNTTYPE_FRM>
997 : {
998 : typedef SwXTextFrame core_frame_t;
999 : typedef XTextFrame uno_frame_t;
1000 223 : static inline uno::Any wrapFrame(SwFrameFormat & rFrameFormat)
1001 : {
1002 : uno::Reference<text::XTextFrame> const xRet(
1003 223 : SwXTextFrame::CreateXTextFrame(*rFrameFormat.GetDoc(), &rFrameFormat));
1004 223 : return uno::makeAny(xRet);
1005 : }
1006 227 : static inline bool filter(const SwNode* const pNode) { return !pNode->IsNoTextNode(); };
1007 : };
1008 :
1009 : template<>
1010 : struct UnoFrameWrap_traits<FLYCNTTYPE_GRF>
1011 : {
1012 : typedef SwXTextGraphicObject core_frame_t;
1013 : typedef XTextContent uno_frame_t;
1014 22 : static inline uno::Any wrapFrame(SwFrameFormat & rFrameFormat)
1015 : {
1016 : uno::Reference<text::XTextContent> const xRet(
1017 22 : SwXTextGraphicObject::CreateXTextGraphicObject(*rFrameFormat.GetDoc(), &rFrameFormat));
1018 22 : return uno::makeAny(xRet);
1019 : }
1020 226 : static inline bool filter(const SwNode* const pNode) { return pNode->IsGrfNode(); };
1021 : };
1022 :
1023 : template<>
1024 : struct UnoFrameWrap_traits<FLYCNTTYPE_OLE>
1025 : {
1026 : typedef SwXTextEmbeddedObject core_frame_t;
1027 : typedef XEmbeddedObjectSupplier uno_frame_t;
1028 155 : static inline uno::Any wrapFrame(SwFrameFormat & rFrameFormat)
1029 : {
1030 : uno::Reference<text::XTextContent> const xRet(
1031 155 : SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rFrameFormat.GetDoc(), &rFrameFormat));
1032 155 : return uno::makeAny(xRet);
1033 : }
1034 321 : static inline bool filter(const SwNode* const pNode) { return pNode->IsOLENode(); };
1035 : };
1036 :
1037 : template<FlyCntType T>
1038 400 : static uno::Any lcl_UnoWrapFrame(SwFrameFormat* pFormat)
1039 : {
1040 400 : return UnoFrameWrap_traits<T>::wrapFrame(*pFormat);
1041 : }
1042 :
1043 : // runtime adapter for lcl_UnoWrapFrame
1044 115 : static uno::Any lcl_UnoWrapFrame(SwFrameFormat* pFormat, FlyCntType eType) throw(uno::RuntimeException)
1045 : {
1046 115 : switch(eType)
1047 : {
1048 : case FLYCNTTYPE_FRM:
1049 43 : return lcl_UnoWrapFrame<FLYCNTTYPE_FRM>(pFormat);
1050 : case FLYCNTTYPE_GRF:
1051 3 : return lcl_UnoWrapFrame<FLYCNTTYPE_GRF>(pFormat);
1052 : case FLYCNTTYPE_OLE:
1053 69 : return lcl_UnoWrapFrame<FLYCNTTYPE_OLE>(pFormat);
1054 : default:
1055 0 : throw uno::RuntimeException();
1056 : }
1057 : }
1058 :
1059 : template<FlyCntType T>
1060 : class SwXFrameEnumeration
1061 : : public SwSimpleEnumeration_Base
1062 : {
1063 : private:
1064 : typedef ::std::list< Any > frmcontainer_t;
1065 : frmcontainer_t m_aFrames;
1066 : protected:
1067 1572 : virtual ~SwXFrameEnumeration() {};
1068 : public:
1069 : SwXFrameEnumeration(const SwDoc* const pDoc);
1070 :
1071 : //XEnumeration
1072 : virtual sal_Bool SAL_CALL hasMoreElements() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1073 : virtual Any SAL_CALL nextElement() throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
1074 :
1075 : //XServiceInfo
1076 : virtual OUString SAL_CALL getImplementationName() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1077 : virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1078 : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1079 : };
1080 : }
1081 :
1082 : template<FlyCntType T>
1083 786 : SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc)
1084 786 : : m_aFrames()
1085 : {
1086 786 : SolarMutexGuard aGuard;
1087 786 : const SwFrameFormats* const pFormats = pDoc->GetSpzFrameFormats();
1088 786 : if(pFormats->empty())
1089 1234 : return;
1090 : // #i104937#
1091 338 : const size_t nSize = pFormats->size();
1092 338 : ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin());
1093 : // #i104937#
1094 338 : SwFrameFormat* pFormat( 0 );
1095 :
1096 676 : std::set<const SwFrameFormat*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
1097 :
1098 1551 : for( size_t i = 0; i < nSize; ++i )
1099 : {
1100 : // #i104937#
1101 1213 : pFormat = (*pFormats)[i];
1102 1213 : if(pFormat->Which() != RES_FLYFRMFMT || aTextBoxes.find(pFormat) != aTextBoxes.end())
1103 439 : continue;
1104 774 : const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
1105 774 : if(!pIdx || !pIdx->GetNodes().IsDocNodes())
1106 0 : continue;
1107 774 : const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
1108 774 : if(UnoFrameWrap_traits<T>::filter(pNd))
1109 285 : *pInserter++ = lcl_UnoWrapFrame<T>(pFormat);
1110 338 : }
1111 : }
1112 :
1113 : template<FlyCntType T>
1114 1071 : sal_Bool SwXFrameEnumeration<T>::hasMoreElements() throw( RuntimeException, std::exception )
1115 : {
1116 1071 : SolarMutexGuard aGuard;
1117 1071 : return !m_aFrames.empty();
1118 : }
1119 :
1120 : template<FlyCntType T>
1121 285 : Any SwXFrameEnumeration<T>::nextElement() throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception )
1122 : {
1123 285 : SolarMutexGuard aGuard;
1124 285 : if(m_aFrames.empty())
1125 0 : throw NoSuchElementException();
1126 285 : Any aResult = *m_aFrames.begin();
1127 285 : m_aFrames.pop_front();
1128 285 : return aResult;
1129 : }
1130 :
1131 : template<FlyCntType T>
1132 0 : OUString SwXFrameEnumeration<T>::getImplementationName() throw( RuntimeException, std::exception )
1133 : {
1134 0 : return OUString("SwXFrameEnumeration");
1135 : }
1136 :
1137 : template<FlyCntType T>
1138 0 : sal_Bool SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception )
1139 : {
1140 0 : return cppu::supportsService(this, ServiceName);
1141 : }
1142 :
1143 : template<FlyCntType T>
1144 0 : Sequence< OUString > SwXFrameEnumeration<T>::getSupportedServiceNames() throw( RuntimeException, std::exception )
1145 : {
1146 0 : return ::comphelper::makeSequence(OUString("com.sun.star.container.XEnumeration"));
1147 : }
1148 :
1149 0 : OUString SwXFrames::getImplementationName() throw( RuntimeException, std::exception )
1150 : {
1151 0 : return OUString("SwXFrames");
1152 : }
1153 :
1154 0 : sal_Bool SwXFrames::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1155 : {
1156 0 : return cppu::supportsService(this, rServiceName);
1157 : }
1158 :
1159 0 : Sequence<OUString> SwXFrames::getSupportedServiceNames() throw( RuntimeException, std::exception )
1160 : {
1161 0 : return ::comphelper::makeSequence(OUString("com.sun.star.text.TextFrames"));
1162 : }
1163 :
1164 1231 : SwXFrames::SwXFrames(SwDoc* _pDoc, FlyCntType eSet) :
1165 : SwUnoCollection(_pDoc),
1166 1231 : eType(eSet)
1167 1231 : {}
1168 :
1169 1225 : SwXFrames::~SwXFrames()
1170 1225 : {}
1171 :
1172 786 : uno::Reference<container::XEnumeration> SwXFrames::createEnumeration() throw(uno::RuntimeException, std::exception)
1173 : {
1174 786 : SolarMutexGuard aGuard;
1175 786 : if(!IsValid())
1176 0 : throw uno::RuntimeException();
1177 786 : switch(eType)
1178 : {
1179 : case FLYCNTTYPE_FRM:
1180 : return uno::Reference< container::XEnumeration >(
1181 219 : new SwXFrameEnumeration<FLYCNTTYPE_FRM>(GetDoc()));
1182 : case FLYCNTTYPE_GRF:
1183 : return uno::Reference< container::XEnumeration >(
1184 218 : new SwXFrameEnumeration<FLYCNTTYPE_GRF>(GetDoc()));
1185 : case FLYCNTTYPE_OLE:
1186 : return uno::Reference< container::XEnumeration >(
1187 349 : new SwXFrameEnumeration<FLYCNTTYPE_OLE>(GetDoc()));
1188 : default:
1189 0 : throw uno::RuntimeException();
1190 786 : }
1191 : }
1192 :
1193 37 : sal_Int32 SwXFrames::getCount() throw(uno::RuntimeException, std::exception)
1194 : {
1195 37 : SolarMutexGuard aGuard;
1196 37 : if(!IsValid())
1197 0 : throw uno::RuntimeException();
1198 : // Ignore TextBoxes for TextFrames.
1199 37 : return static_cast<sal_Int32>(GetDoc()->GetFlyCount(eType, /*bIgnoreTextBoxes=*/eType == FLYCNTTYPE_FRM));
1200 : }
1201 :
1202 56 : uno::Any SwXFrames::getByIndex(sal_Int32 nIndex)
1203 : throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1204 : {
1205 56 : SolarMutexGuard aGuard;
1206 56 : if(!IsValid())
1207 0 : throw uno::RuntimeException();
1208 56 : if(nIndex < 0)
1209 0 : throw IndexOutOfBoundsException();
1210 : // Ignore TextBoxes for TextFrames.
1211 56 : SwFrameFormat* pFormat = GetDoc()->GetFlyNum(static_cast<size_t>(nIndex), eType, /*bIgnoreTextBoxes=*/eType == FLYCNTTYPE_FRM);
1212 56 : if(!pFormat)
1213 1 : throw IndexOutOfBoundsException();
1214 56 : return lcl_UnoWrapFrame(pFormat, eType);
1215 : }
1216 :
1217 64 : uno::Any SwXFrames::getByName(const OUString& rName)
1218 : throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception )
1219 : {
1220 64 : SolarMutexGuard aGuard;
1221 64 : if(!IsValid())
1222 0 : throw uno::RuntimeException();
1223 : const SwFrameFormat* pFormat;
1224 64 : switch(eType)
1225 : {
1226 : case FLYCNTTYPE_GRF:
1227 2 : pFormat = GetDoc()->FindFlyByName(rName, ND_GRFNODE);
1228 2 : break;
1229 : case FLYCNTTYPE_OLE:
1230 51 : pFormat = GetDoc()->FindFlyByName(rName, ND_OLENODE);
1231 51 : break;
1232 : default:
1233 11 : pFormat = GetDoc()->FindFlyByName(rName, ND_TEXTNODE);
1234 11 : break;
1235 : }
1236 64 : if(!pFormat)
1237 4 : throw NoSuchElementException();
1238 64 : return lcl_UnoWrapFrame(const_cast<SwFrameFormat*>(pFormat), eType);
1239 : }
1240 :
1241 135 : uno::Sequence<OUString> SwXFrames::getElementNames() throw( uno::RuntimeException, std::exception )
1242 : {
1243 135 : SolarMutexGuard aGuard;
1244 135 : if(!IsValid())
1245 0 : throw uno::RuntimeException();
1246 270 : const Reference<XEnumeration> xEnum = createEnumeration();
1247 270 : ::std::vector<OUString> vNames;
1248 333 : while(xEnum->hasMoreElements())
1249 : {
1250 63 : Reference<container::XNamed> xNamed;
1251 63 : xEnum->nextElement() >>= xNamed;
1252 63 : if(xNamed.is())
1253 63 : vNames.push_back(xNamed->getName());
1254 63 : }
1255 270 : return ::comphelper::containerToSequence(vNames);
1256 : }
1257 :
1258 1146 : sal_Bool SwXFrames::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception )
1259 : {
1260 1146 : SolarMutexGuard aGuard;
1261 1146 : if(!IsValid())
1262 0 : throw uno::RuntimeException();
1263 1146 : switch(eType)
1264 : {
1265 : case FLYCNTTYPE_GRF:
1266 381 : return GetDoc()->FindFlyByName(rName, ND_GRFNODE) != NULL;
1267 : case FLYCNTTYPE_OLE:
1268 378 : return GetDoc()->FindFlyByName(rName, ND_OLENODE) != NULL;
1269 : default:
1270 387 : return GetDoc()->FindFlyByName(rName, ND_TEXTNODE) != NULL;
1271 1146 : }
1272 : }
1273 :
1274 1 : uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException, std::exception)
1275 : {
1276 1 : SolarMutexGuard aGuard;
1277 1 : switch(eType)
1278 : {
1279 : case FLYCNTTYPE_FRM:
1280 1 : return cppu::UnoType<XTextFrame>::get();
1281 : case FLYCNTTYPE_GRF:
1282 0 : return cppu::UnoType<XTextContent>::get();
1283 : case FLYCNTTYPE_OLE:
1284 0 : return cppu::UnoType<XEmbeddedObjectSupplier>::get();
1285 : default:
1286 0 : return uno::Type();
1287 1 : }
1288 : }
1289 :
1290 1 : sal_Bool SwXFrames::hasElements() throw(uno::RuntimeException, std::exception)
1291 : {
1292 1 : SolarMutexGuard aGuard;
1293 1 : if(!IsValid())
1294 0 : throw uno::RuntimeException();
1295 1 : return GetDoc()->GetFlyCount(eType) > 0;
1296 : }
1297 :
1298 :
1299 0 : OUString SwXTextFrames::getImplementationName() throw( RuntimeException, std::exception )
1300 : {
1301 0 : return OUString("SwXTextFrames");
1302 : }
1303 :
1304 0 : sal_Bool SwXTextFrames::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1305 : {
1306 0 : return cppu::supportsService(this, rServiceName);
1307 : }
1308 :
1309 0 : Sequence< OUString > SwXTextFrames::getSupportedServiceNames() throw( RuntimeException, std::exception )
1310 : {
1311 0 : Sequence< OUString > aRet(1);
1312 0 : OUString* pArray = aRet.getArray();
1313 0 : pArray[0] = "com.sun.star.text.TextFrames";
1314 0 : return aRet;
1315 : }
1316 :
1317 404 : SwXTextFrames::SwXTextFrames(SwDoc* _pDoc) :
1318 404 : SwXFrames(_pDoc, FLYCNTTYPE_FRM)
1319 : {
1320 404 : }
1321 :
1322 804 : SwXTextFrames::~SwXTextFrames()
1323 : {
1324 804 : }
1325 :
1326 0 : OUString SwXTextGraphicObjects::getImplementationName() throw( RuntimeException, std::exception )
1327 : {
1328 0 : return OUString("SwXTextGraphicObjects");
1329 : }
1330 :
1331 0 : sal_Bool SwXTextGraphicObjects::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1332 : {
1333 0 : return cppu::supportsService(this, rServiceName);
1334 : }
1335 :
1336 0 : Sequence< OUString > SwXTextGraphicObjects::getSupportedServiceNames() throw( RuntimeException, std::exception )
1337 : {
1338 0 : Sequence< OUString > aRet(1);
1339 0 : OUString* pArray = aRet.getArray();
1340 0 : pArray[0] = "com.sun.star.text.TextGraphicObjects";
1341 0 : return aRet;
1342 : }
1343 :
1344 376 : SwXTextGraphicObjects::SwXTextGraphicObjects(SwDoc* _pDoc) :
1345 376 : SwXFrames(_pDoc, FLYCNTTYPE_GRF)
1346 : {
1347 376 : }
1348 :
1349 748 : SwXTextGraphicObjects::~SwXTextGraphicObjects()
1350 : {
1351 748 : }
1352 :
1353 0 : OUString SwXTextEmbeddedObjects::getImplementationName() throw( RuntimeException, std::exception )
1354 : {
1355 0 : return OUString("SwXTextEmbeddedObjects");
1356 : }
1357 :
1358 0 : sal_Bool SwXTextEmbeddedObjects::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1359 : {
1360 0 : return cppu::supportsService(this, rServiceName);
1361 : }
1362 :
1363 0 : Sequence< OUString > SwXTextEmbeddedObjects::getSupportedServiceNames() throw( RuntimeException, std::exception )
1364 : {
1365 0 : Sequence< OUString > aRet(1);
1366 0 : OUString* pArray = aRet.getArray();
1367 0 : pArray[0] = "com.sun.star.text.TextEmbeddedObjects";
1368 0 : return aRet;
1369 : }
1370 :
1371 451 : SwXTextEmbeddedObjects::SwXTextEmbeddedObjects(SwDoc* _pDoc) :
1372 451 : SwXFrames(_pDoc, FLYCNTTYPE_OLE)
1373 : {
1374 451 : }
1375 :
1376 898 : SwXTextEmbeddedObjects::~SwXTextEmbeddedObjects()
1377 : {
1378 898 : }
1379 :
1380 0 : OUString SwXTextSections::getImplementationName() throw( RuntimeException, std::exception )
1381 : {
1382 0 : return OUString("SwXTextSections");
1383 : }
1384 :
1385 0 : sal_Bool SwXTextSections::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1386 : {
1387 0 : return cppu::supportsService(this, rServiceName);
1388 : }
1389 :
1390 0 : Sequence< OUString > SwXTextSections::getSupportedServiceNames() throw( RuntimeException, std::exception )
1391 : {
1392 0 : Sequence< OUString > aRet(1);
1393 0 : OUString* pArray = aRet.getArray();
1394 0 : pArray[0] = "com.sun.star.text.TextSections";
1395 0 : return aRet;
1396 : }
1397 :
1398 64 : SwXTextSections::SwXTextSections(SwDoc* _pDoc) :
1399 64 : SwUnoCollection(_pDoc)
1400 : {
1401 64 : }
1402 :
1403 128 : SwXTextSections::~SwXTextSections()
1404 : {
1405 128 : }
1406 :
1407 75 : sal_Int32 SwXTextSections::getCount() throw( uno::RuntimeException, std::exception )
1408 : {
1409 75 : SolarMutexGuard aGuard;
1410 75 : if(!IsValid())
1411 0 : throw uno::RuntimeException();
1412 75 : const SwSectionFormats& rSectFormats = GetDoc()->GetSections();
1413 75 : size_t nCount = rSectFormats.size();
1414 115 : for(size_t i = nCount; i; --i)
1415 : {
1416 40 : if( !rSectFormats[i - 1]->IsInNodesArr())
1417 0 : nCount--;
1418 : }
1419 75 : return nCount;
1420 : }
1421 :
1422 46 : uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex)
1423 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1424 : {
1425 46 : SolarMutexGuard aGuard;
1426 92 : uno::Reference< XTextSection > xRet;
1427 46 : if(IsValid())
1428 : {
1429 46 : SwSectionFormats& rFormats = GetDoc()->GetSections();
1430 :
1431 46 : const SwSectionFormats& rSectFormats = GetDoc()->GetSections();
1432 46 : const size_t nCount = rSectFormats.size();
1433 214 : for(size_t i = 0; i < nCount; ++i)
1434 : {
1435 214 : if( !rSectFormats[i]->IsInNodesArr())
1436 0 : nIndex ++;
1437 214 : else if(static_cast<size_t>(nIndex) == i)
1438 46 : break;
1439 168 : if(static_cast<size_t>(nIndex) == i)
1440 0 : break;
1441 : }
1442 46 : if(nIndex >= 0 && static_cast<size_t>(nIndex) < rFormats.size())
1443 : {
1444 46 : SwSectionFormat* pFormat = rFormats[nIndex];
1445 46 : xRet = GetObject(*pFormat);
1446 : }
1447 : else
1448 0 : throw IndexOutOfBoundsException();
1449 : }
1450 : else
1451 0 : throw uno::RuntimeException();
1452 92 : return makeAny(xRet);
1453 : }
1454 :
1455 32 : uno::Any SwXTextSections::getByName(const OUString& rName)
1456 : throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception )
1457 : {
1458 32 : SolarMutexGuard aGuard;
1459 32 : uno::Any aRet;
1460 32 : if(IsValid())
1461 : {
1462 32 : SwSectionFormats& rFormats = GetDoc()->GetSections();
1463 32 : uno::Reference< XTextSection > xSect;
1464 272 : for(size_t i = 0; i < rFormats.size(); ++i)
1465 : {
1466 272 : SwSectionFormat* pFormat = rFormats[i];
1467 816 : if (pFormat->IsInNodesArr()
1468 1088 : && (rName == pFormat->GetSection()->GetSectionName()))
1469 : {
1470 32 : xSect = GetObject(*pFormat);
1471 32 : aRet.setValue(&xSect, cppu::UnoType<XTextSection>::get());
1472 32 : break;
1473 : }
1474 : }
1475 32 : if(!xSect.is())
1476 0 : throw NoSuchElementException();
1477 : }
1478 : else
1479 0 : throw uno::RuntimeException();
1480 32 : return aRet;
1481 : }
1482 :
1483 0 : uno::Sequence< OUString > SwXTextSections::getElementNames()
1484 : throw( uno::RuntimeException, std::exception )
1485 : {
1486 0 : SolarMutexGuard aGuard;
1487 0 : if(!IsValid())
1488 0 : throw uno::RuntimeException();
1489 0 : size_t nCount = GetDoc()->GetSections().size();
1490 0 : SwSectionFormats& rSectFormats = GetDoc()->GetSections();
1491 0 : for(size_t i = nCount; i; --i)
1492 : {
1493 0 : if( !rSectFormats[i - 1]->IsInNodesArr())
1494 0 : nCount--;
1495 : }
1496 :
1497 0 : uno::Sequence<OUString> aSeq(nCount);
1498 0 : if(nCount)
1499 : {
1500 0 : SwSectionFormats& rFormats = GetDoc()->GetSections();
1501 0 : OUString* pArray = aSeq.getArray();
1502 0 : size_t nIndex = 0;
1503 0 : for( size_t i = 0; i < nCount; ++i, ++nIndex)
1504 : {
1505 0 : const SwSectionFormat* pFormat = rFormats[nIndex];
1506 0 : while(!pFormat->IsInNodesArr())
1507 : {
1508 0 : pFormat = rFormats[++nIndex];
1509 : }
1510 0 : pArray[i] = pFormat->GetSection()->GetSectionName();
1511 : }
1512 : }
1513 0 : return aSeq;
1514 : }
1515 :
1516 0 : sal_Bool SwXTextSections::hasByName(const OUString& rName)
1517 : throw( uno::RuntimeException, std::exception )
1518 : {
1519 0 : SolarMutexGuard aGuard;
1520 0 : bool bRet = false;
1521 0 : if(IsValid())
1522 : {
1523 0 : SwSectionFormats& rFormats = GetDoc()->GetSections();
1524 0 : for(size_t i = 0; i < rFormats.size(); ++i)
1525 : {
1526 0 : const SwSectionFormat* pFormat = rFormats[i];
1527 0 : if (rName == pFormat->GetSection()->GetSectionName())
1528 : {
1529 0 : bRet = true;
1530 0 : break;
1531 : }
1532 : }
1533 : }
1534 : else
1535 : {
1536 : // special handling for dbg_ methods
1537 0 : if( !rName.startsWith("dbg_"))
1538 0 : throw uno::RuntimeException();
1539 : }
1540 0 : return bRet;
1541 : }
1542 :
1543 0 : uno::Type SAL_CALL SwXTextSections::getElementType() throw(uno::RuntimeException, std::exception)
1544 : {
1545 0 : return cppu::UnoType<XTextSection>::get();
1546 : }
1547 :
1548 0 : sal_Bool SwXTextSections::hasElements() throw( uno::RuntimeException, std::exception )
1549 : {
1550 0 : SolarMutexGuard aGuard;
1551 0 : size_t nCount = 0;
1552 0 : if(IsValid())
1553 : {
1554 0 : SwSectionFormats& rFormats = GetDoc()->GetSections();
1555 0 : nCount = rFormats.size();
1556 : }
1557 : else
1558 0 : throw uno::RuntimeException();
1559 0 : return nCount > 0;
1560 : }
1561 :
1562 168 : uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFormat& rFormat )
1563 : {
1564 168 : return SwXTextSection::CreateXTextSection(&rFormat);
1565 : }
1566 :
1567 0 : OUString SwXBookmarks::getImplementationName() throw( RuntimeException, std::exception )
1568 : {
1569 0 : return OUString("SwXBookmarks");
1570 : }
1571 :
1572 0 : sal_Bool SwXBookmarks::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1573 : {
1574 0 : return cppu::supportsService(this, rServiceName);
1575 : }
1576 :
1577 0 : Sequence< OUString > SwXBookmarks::getSupportedServiceNames() throw( RuntimeException, std::exception )
1578 : {
1579 0 : Sequence< OUString > aRet(1);
1580 0 : aRet[0] = "com.sun.star.text.Bookmarks";
1581 0 : return aRet;
1582 : }
1583 :
1584 12 : SwXBookmarks::SwXBookmarks(SwDoc* _pDoc) :
1585 12 : SwUnoCollection(_pDoc)
1586 12 : { }
1587 :
1588 24 : SwXBookmarks::~SwXBookmarks()
1589 24 : { }
1590 :
1591 2 : sal_Int32 SwXBookmarks::getCount()
1592 : throw( uno::RuntimeException, std::exception )
1593 : {
1594 2 : SolarMutexGuard aGuard;
1595 2 : if(!IsValid())
1596 0 : throw uno::RuntimeException();
1597 :
1598 2 : sal_Int32 count(0);
1599 2 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1600 21 : for (IDocumentMarkAccess::const_iterator_t ppMark =
1601 2 : pMarkAccess->getBookmarksBegin();
1602 14 : ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark)
1603 : {
1604 5 : if (IDocumentMarkAccess::MarkType::BOOKMARK ==
1605 5 : IDocumentMarkAccess::GetType(**ppMark))
1606 : {
1607 5 : ++count; // only count real bookmarks
1608 : }
1609 : }
1610 2 : return count;
1611 : }
1612 :
1613 4 : uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex)
1614 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1615 : {
1616 4 : SolarMutexGuard aGuard;
1617 4 : if(!IsValid())
1618 0 : throw uno::RuntimeException();
1619 4 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1620 4 : if(nIndex < 0 || nIndex >= pMarkAccess->getBookmarksCount())
1621 1 : throw IndexOutOfBoundsException();
1622 :
1623 3 : sal_Int32 count(0);
1624 15 : for (IDocumentMarkAccess::const_iterator_t ppMark =
1625 3 : pMarkAccess->getBookmarksBegin();
1626 10 : ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark)
1627 : {
1628 5 : if (IDocumentMarkAccess::MarkType::BOOKMARK ==
1629 5 : IDocumentMarkAccess::GetType(**ppMark))
1630 : {
1631 5 : if (count == nIndex)
1632 : {
1633 3 : uno::Any aRet;
1634 : const uno::Reference< text::XTextContent > xRef =
1635 6 : SwXBookmark::CreateXBookmark(*GetDoc(), ppMark->get());
1636 3 : aRet <<= xRef;
1637 9 : return aRet;
1638 : }
1639 2 : ++count; // only count real bookmarks
1640 : }
1641 : }
1642 3 : throw IndexOutOfBoundsException();
1643 : }
1644 :
1645 4847 : uno::Any SwXBookmarks::getByName(const OUString& rName)
1646 : throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception )
1647 : {
1648 4847 : SolarMutexGuard aGuard;
1649 4847 : if(!IsValid())
1650 0 : throw uno::RuntimeException();
1651 :
1652 4847 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1653 4847 : IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findBookmark(rName);
1654 4847 : if(ppBkmk == pMarkAccess->getBookmarksEnd())
1655 1 : throw NoSuchElementException();
1656 :
1657 4846 : uno::Any aRet;
1658 : const uno::Reference< text::XTextContent > xRef =
1659 9692 : SwXBookmark::CreateXBookmark(*GetDoc(), ppBkmk->get());
1660 4846 : aRet <<= xRef;
1661 9693 : return aRet;
1662 : }
1663 :
1664 6 : uno::Sequence< OUString > SwXBookmarks::getElementNames()
1665 : throw( uno::RuntimeException, std::exception )
1666 : {
1667 6 : SolarMutexGuard aGuard;
1668 6 : if(!IsValid())
1669 0 : throw uno::RuntimeException();
1670 :
1671 12 : ::std::vector< OUString > ret;
1672 6 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1673 14511 : for (IDocumentMarkAccess::const_iterator_t ppMark =
1674 6 : pMarkAccess->getBookmarksBegin();
1675 9674 : ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark)
1676 : {
1677 4831 : if (IDocumentMarkAccess::MarkType::BOOKMARK ==
1678 4831 : IDocumentMarkAccess::GetType(**ppMark))
1679 : {
1680 4831 : ret.push_back((*ppMark)->GetName()); // only add real bookmarks
1681 : }
1682 : }
1683 12 : return comphelper::containerToSequence(ret);
1684 : }
1685 :
1686 5 : sal_Bool SwXBookmarks::hasByName(const OUString& rName)
1687 : throw( uno::RuntimeException, std::exception )
1688 : {
1689 5 : SolarMutexGuard aGuard;
1690 5 : if(!IsValid())
1691 0 : throw uno::RuntimeException();
1692 :
1693 5 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1694 5 : return pMarkAccess->findBookmark(rName) != pMarkAccess->getBookmarksEnd();
1695 : }
1696 :
1697 1 : uno::Type SAL_CALL SwXBookmarks::getElementType()
1698 : throw(uno::RuntimeException, std::exception)
1699 : {
1700 1 : return cppu::UnoType<XTextContent>::get();
1701 : }
1702 :
1703 1 : sal_Bool SwXBookmarks::hasElements()
1704 : throw( uno::RuntimeException, std::exception )
1705 : {
1706 1 : SolarMutexGuard aGuard;
1707 1 : if(!IsValid())
1708 0 : throw uno::RuntimeException();
1709 :
1710 1 : IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess();
1711 3 : for (IDocumentMarkAccess::const_iterator_t ppMark =
1712 1 : pMarkAccess->getBookmarksBegin();
1713 2 : ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark)
1714 : {
1715 1 : if (IDocumentMarkAccess::MarkType::BOOKMARK ==
1716 1 : IDocumentMarkAccess::GetType(**ppMark))
1717 : {
1718 1 : return true;
1719 : }
1720 : }
1721 0 : return false;
1722 : }
1723 :
1724 55 : SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc* _pDoc ) :
1725 55 : SwUnoCollection(_pDoc)
1726 : {
1727 55 : }
1728 :
1729 110 : SwXNumberingRulesCollection::~SwXNumberingRulesCollection()
1730 : {
1731 110 : }
1732 :
1733 81 : sal_Int32 SwXNumberingRulesCollection::getCount() throw( uno::RuntimeException, std::exception )
1734 : {
1735 81 : SolarMutexGuard aGuard;
1736 81 : if(!IsValid())
1737 0 : throw uno::RuntimeException();
1738 81 : return GetDoc()->GetNumRuleTable().size();
1739 : }
1740 :
1741 158 : uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex)
1742 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1743 : {
1744 158 : SolarMutexGuard aGuard;
1745 158 : uno::Any aRet;
1746 158 : if(IsValid())
1747 : {
1748 158 : uno::Reference< XIndexReplace > xRef;
1749 158 : if ( static_cast<size_t>(nIndex) < GetDoc()->GetNumRuleTable().size() )
1750 : {
1751 158 : xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTable()[ nIndex ], GetDoc());
1752 158 : aRet.setValue(&xRef, cppu::UnoType<XIndexReplace>::get());
1753 : }
1754 :
1755 158 : if(!xRef.is())
1756 0 : throw IndexOutOfBoundsException();
1757 : }
1758 : else
1759 0 : throw uno::RuntimeException();
1760 158 : return aRet;
1761 : }
1762 :
1763 0 : uno::Type SAL_CALL SwXNumberingRulesCollection::getElementType() throw(uno::RuntimeException, std::exception)
1764 : {
1765 0 : return cppu::UnoType<XIndexReplace>::get();
1766 : }
1767 :
1768 0 : sal_Bool SwXNumberingRulesCollection::hasElements() throw( uno::RuntimeException, std::exception )
1769 : {
1770 0 : SolarMutexGuard aGuard;
1771 0 : if(!IsValid())
1772 0 : throw uno::RuntimeException();
1773 0 : return !GetDoc()->GetNumRuleTable().empty();
1774 : }
1775 :
1776 0 : OUString SwXFootnotes::getImplementationName() throw( RuntimeException, std::exception )
1777 : {
1778 0 : return OUString("SwXFootnotes");
1779 : }
1780 :
1781 0 : sal_Bool SwXFootnotes::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1782 : {
1783 0 : return cppu::supportsService(this, rServiceName);
1784 : }
1785 :
1786 0 : Sequence< OUString > SwXFootnotes::getSupportedServiceNames() throw( RuntimeException, std::exception )
1787 : {
1788 0 : Sequence< OUString > aRet(1);
1789 0 : OUString* pArray = aRet.getArray();
1790 0 : pArray[0] = "com.sun.star.text.Footnotes";
1791 0 : return aRet;
1792 : }
1793 :
1794 8 : SwXFootnotes::SwXFootnotes(bool bEnd, SwDoc* _pDoc)
1795 : : SwUnoCollection(_pDoc)
1796 8 : , m_bEndnote(bEnd)
1797 : {
1798 8 : }
1799 :
1800 16 : SwXFootnotes::~SwXFootnotes()
1801 : {
1802 16 : }
1803 :
1804 3 : sal_Int32 SwXFootnotes::getCount() throw( uno::RuntimeException, std::exception )
1805 : {
1806 3 : SolarMutexGuard aGuard;
1807 3 : if(!IsValid())
1808 0 : throw uno::RuntimeException();
1809 3 : sal_Int32 nCount = 0;
1810 3 : const size_t nFootnoteCnt = GetDoc()->GetFootnoteIdxs().size();
1811 : SwTextFootnote* pTextFootnote;
1812 6 : for( size_t n = 0; n < nFootnoteCnt; ++n )
1813 : {
1814 3 : pTextFootnote = GetDoc()->GetFootnoteIdxs()[ n ];
1815 3 : const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1816 3 : if ( rFootnote.IsEndNote() != m_bEndnote )
1817 0 : continue;
1818 3 : nCount++;
1819 : }
1820 3 : return nCount;
1821 : }
1822 :
1823 9 : uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex)
1824 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1825 : {
1826 9 : SolarMutexGuard aGuard;
1827 9 : uno::Any aRet;
1828 9 : sal_Int32 nCount = 0;
1829 9 : if(IsValid())
1830 : {
1831 9 : const size_t nFootnoteCnt = GetDoc()->GetFootnoteIdxs().size();
1832 : SwTextFootnote* pTextFootnote;
1833 9 : uno::Reference< XFootnote > xRef;
1834 10 : for( size_t n = 0; n < nFootnoteCnt; ++n )
1835 : {
1836 9 : pTextFootnote = GetDoc()->GetFootnoteIdxs()[ n ];
1837 9 : const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1838 9 : if ( rFootnote.IsEndNote() != m_bEndnote )
1839 0 : continue;
1840 :
1841 9 : if(nCount == nIndex)
1842 : {
1843 16 : xRef = SwXFootnote::CreateXFootnote(*GetDoc(),
1844 8 : &const_cast<SwFormatFootnote&>(rFootnote));
1845 8 : aRet <<= xRef;
1846 8 : break;
1847 : }
1848 1 : nCount++;
1849 : }
1850 9 : if(!xRef.is())
1851 1 : throw IndexOutOfBoundsException();
1852 : }
1853 : else
1854 0 : throw uno::RuntimeException();
1855 9 : return aRet;
1856 : }
1857 :
1858 1 : uno::Type SAL_CALL SwXFootnotes::getElementType() throw(uno::RuntimeException, std::exception)
1859 : {
1860 1 : return cppu::UnoType<XFootnote>::get();
1861 : }
1862 :
1863 1 : sal_Bool SwXFootnotes::hasElements() throw( uno::RuntimeException, std::exception )
1864 : {
1865 1 : SolarMutexGuard aGuard;
1866 1 : if(!IsValid())
1867 0 : throw uno::RuntimeException();
1868 1 : return !GetDoc()->GetFootnoteIdxs().empty();
1869 : }
1870 :
1871 22 : Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFormatFootnote& rFormat )
1872 : {
1873 22 : return SwXFootnote::CreateXFootnote(rDoc, &const_cast<SwFormatFootnote&>(rFormat));
1874 : }
1875 :
1876 0 : OUString SwXReferenceMarks::getImplementationName() throw( RuntimeException, std::exception )
1877 : {
1878 0 : return OUString("SwXReferenceMarks");
1879 : }
1880 :
1881 0 : sal_Bool SwXReferenceMarks::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception )
1882 : {
1883 0 : return cppu::supportsService(this, rServiceName);
1884 : }
1885 :
1886 0 : Sequence< OUString > SwXReferenceMarks::getSupportedServiceNames() throw( RuntimeException, std::exception )
1887 : {
1888 0 : Sequence< OUString > aRet(1);
1889 0 : OUString* pArray = aRet.getArray();
1890 0 : pArray[0] = "com.sun.star.text.ReferenceMarks";
1891 0 : return aRet;
1892 : }
1893 :
1894 1 : SwXReferenceMarks::SwXReferenceMarks(SwDoc* _pDoc) :
1895 1 : SwUnoCollection(_pDoc)
1896 : {
1897 1 : }
1898 :
1899 2 : SwXReferenceMarks::~SwXReferenceMarks()
1900 : {
1901 2 : }
1902 :
1903 1 : sal_Int32 SwXReferenceMarks::getCount() throw( uno::RuntimeException, std::exception )
1904 : {
1905 1 : SolarMutexGuard aGuard;
1906 1 : if(!IsValid())
1907 0 : throw uno::RuntimeException();
1908 1 : return GetDoc()->GetRefMarks();
1909 : }
1910 :
1911 4 : uno::Any SwXReferenceMarks::getByIndex(sal_Int32 nIndex)
1912 : throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException, std::exception )
1913 : {
1914 4 : SolarMutexGuard aGuard;
1915 4 : uno::Any aRet;
1916 4 : if(!IsValid())
1917 0 : throw uno::RuntimeException();
1918 8 : uno::Reference< XTextContent > xRef;
1919 4 : if(0 <= nIndex && nIndex < USHRT_MAX)
1920 : {
1921 : SwFormatRefMark *const pMark = const_cast<SwFormatRefMark*>(
1922 4 : GetDoc()->GetRefMark(static_cast<sal_uInt16>(nIndex)));
1923 4 : if(pMark)
1924 : {
1925 3 : xRef = SwXReferenceMark::CreateXReferenceMark(*GetDoc(), pMark);
1926 3 : aRet.setValue(&xRef, cppu::UnoType<XTextContent>::get());
1927 : }
1928 : }
1929 4 : if(!xRef.is())
1930 1 : throw IndexOutOfBoundsException();
1931 7 : return aRet;
1932 : }
1933 :
1934 2 : uno::Any SwXReferenceMarks::getByName(const OUString& rName)
1935 : throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException, std::exception )
1936 : {
1937 2 : SolarMutexGuard aGuard;
1938 2 : uno::Any aRet;
1939 2 : if(IsValid())
1940 : {
1941 : SwFormatRefMark *const pMark =
1942 2 : const_cast<SwFormatRefMark*>(GetDoc()->GetRefMark(rName));
1943 2 : if(pMark)
1944 : {
1945 : uno::Reference<XTextContent> const xRef =
1946 1 : SwXReferenceMark::CreateXReferenceMark(*GetDoc(), pMark);
1947 1 : aRet.setValue(&xRef, cppu::UnoType<XTextContent>::get());
1948 : }
1949 : else
1950 1 : throw NoSuchElementException();
1951 : }
1952 : else
1953 0 : throw uno::RuntimeException();
1954 2 : return aRet;
1955 : }
1956 :
1957 1 : uno::Sequence< OUString > SwXReferenceMarks::getElementNames() throw( uno::RuntimeException, std::exception )
1958 : {
1959 1 : SolarMutexGuard aGuard;
1960 1 : uno::Sequence<OUString> aRet;
1961 1 : if(IsValid())
1962 : {
1963 1 : std::vector<OUString> aStrings;
1964 1 : const sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings );
1965 1 : aRet.realloc(nCount);
1966 1 : OUString* pNames = aRet.getArray();
1967 3 : for(sal_uInt16 i = 0; i < nCount; i++)
1968 3 : pNames[i] = aStrings[i];
1969 : }
1970 : else
1971 0 : throw uno::RuntimeException();
1972 1 : return aRet;
1973 : }
1974 :
1975 2 : sal_Bool SwXReferenceMarks::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception )
1976 : {
1977 2 : SolarMutexGuard aGuard;
1978 2 : if(!IsValid())
1979 0 : throw uno::RuntimeException();
1980 2 : return 0 != GetDoc()->GetRefMark( rName);
1981 : }
1982 :
1983 1 : uno::Type SAL_CALL SwXReferenceMarks::getElementType() throw(uno::RuntimeException, std::exception)
1984 : {
1985 1 : return cppu::UnoType<XTextContent>::get();
1986 : }
1987 :
1988 1 : sal_Bool SwXReferenceMarks::hasElements() throw( uno::RuntimeException, std::exception )
1989 : {
1990 1 : SolarMutexGuard aGuard;
1991 1 : if(!IsValid())
1992 0 : throw uno::RuntimeException();
1993 1 : return 0 != GetDoc()->GetRefMarks();
1994 : }
1995 :
1996 8836 : void SwUnoCollection::Invalidate()
1997 : {
1998 8836 : bObjectValid = false;
1999 8836 : pDoc = 0;
2000 9013 : }
2001 :
2002 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|