1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <hintids.hxx>
24 #include <IDocumentChartDataProviderAccess.hxx>
25 #include <IDocumentFieldsAccess.hxx>
27 #include <unocoll.hxx>
28 #include <unosett.hxx>
29 #include <section.hxx>
34 #include <com/sun/star/text/XTextTable.hpp>
35 #include <o3tl/safeint.hxx>
36 #include <o3tl/string_view.hxx>
37 #include <svtools/unoimap.hxx>
38 #include <svtools/unoevent.hxx>
39 #include <svx/SvxXTextColumns.hxx>
41 #include <unostyle.hxx>
42 #include <unofield.hxx>
44 #include <unoframe.hxx>
45 #include <textboxhelper.hxx>
46 #include <unofootnote.hxx>
47 #include <unolinebreak.hxx>
48 #include <unoport.hxx>
49 #include <vcl/svapp.hxx>
50 #include <fmtcntnt.hxx>
51 #include <authfld.hxx>
52 #include <SwXTextDefaults.hxx>
53 #include <unochart.hxx>
54 #include <comphelper/sequence.hxx>
55 #include <cppuhelper/supportsservice.hxx>
56 #include <unosection.hxx>
57 #include <unoparagraph.hxx>
58 #include <unobookmark.hxx>
59 #include <unorefmark.hxx>
60 #include <unometa.hxx>
61 #include <unocontentcontrol.hxx>
64 #include <frameformats.hxx>
65 #include <com/sun/star/document/XCodeNameQuery.hpp>
66 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
67 #include <com/sun/star/form/XFormsSupplier.hpp>
68 #include <com/sun/star/script/ModuleInfo.hpp>
69 #include <com/sun/star/script/ModuleType.hpp>
70 #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
71 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
72 #include <vbahelper/vbaaccesshelper.hxx>
73 #include <basic/basmgr.hxx>
74 #include <comphelper/processfactory.hxx>
75 #include <cppuhelper/implbase.hxx>
76 #include <sfx2/event.hxx>
77 #include <sal/log.hxx>
78 #include <tools/debug.hxx>
80 using namespace ::com::sun::star
;
81 using namespace ::com::sun::star::document
;
82 using namespace ::com::sun::star::uno
;
83 using namespace ::com::sun::star::text
;
84 using namespace ::com::sun::star::container
;
85 using namespace ::com::sun::star::lang
;
87 #if HAVE_FEATURE_SCRIPTING
91 class SwVbaCodeNameProvider
: public ::cppu::WeakImplHelper
< document::XCodeNameQuery
>
93 SwDocShell
* mpDocShell
;
94 OUString msThisDocumentCodeName
;
96 explicit SwVbaCodeNameProvider( SwDocShell
* pDocShell
) : mpDocShell( pDocShell
) {}
99 OUString SAL_CALL
getCodeNameForContainer( const uno::Reference
< uno::XInterface
>& /*xIf*/ ) override
101 // #FIXME not implemented...
105 OUString SAL_CALL
getCodeNameForObject( const uno::Reference
< uno::XInterface
>& xIf
) override
107 // Initialise the code name
108 if ( msThisDocumentCodeName
.isEmpty() )
112 uno::Reference
< beans::XPropertySet
> xProps( mpDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
113 uno::Reference
< container::XNameAccess
> xLibContainer( xProps
->getPropertyValue(u
"BasicLibraries"_ustr
), uno::UNO_QUERY_THROW
);
114 OUString
sProjectName( u
"Standard"_ustr
);
115 if ( !mpDocShell
->GetBasicManager()->GetName().isEmpty() )
117 sProjectName
= mpDocShell
->GetBasicManager()->GetName();
119 uno::Reference
< container::XNameAccess
> xLib( xLibContainer
->getByName( sProjectName
), uno::UNO_QUERY_THROW
);
120 const uno::Sequence
< OUString
> sModuleNames
= xLib
->getElementNames();
121 uno::Reference
< script::vba::XVBAModuleInfo
> xVBAModuleInfo( xLib
, uno::UNO_QUERY
);
123 auto pModuleName
= std::find_if(sModuleNames
.begin(), sModuleNames
.end(), [&xVBAModuleInfo
](const OUString
& rName
) {
124 return xVBAModuleInfo
->hasModuleInfo(rName
)
125 && xVBAModuleInfo
->getModuleInfo(rName
).ModuleType
== script::ModuleType::DOCUMENT
; });
126 if (pModuleName
!= sModuleNames
.end())
127 msThisDocumentCodeName
= *pModuleName
;
129 catch( uno::Exception
& )
136 // need to find the page ( and index ) for this control
137 uno::Reference
< drawing::XDrawPageSupplier
> xSupplier( mpDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
138 uno::Reference
< container::XIndexAccess
> xIndex( xSupplier
->getDrawPage(), uno::UNO_QUERY_THROW
);
142 uno::Reference
< form::XFormsSupplier
> xFormSupplier( xIndex
, uno::UNO_QUERY_THROW
);
143 uno::Reference
< container::XIndexAccess
> xFormIndex( xFormSupplier
->getForms(), uno::UNO_QUERY_THROW
);
144 // get the www-standard container
145 uno::Reference
< container::XIndexAccess
> xFormControls( xFormIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
146 sal_Int32 nCntrls
= xFormControls
->getCount();
147 for( sal_Int32 cIndex
= 0; cIndex
< nCntrls
; ++cIndex
)
149 uno::Reference
< uno::XInterface
> xControl( xFormControls
->getByIndex( cIndex
), uno::UNO_QUERY_THROW
);
150 bool bMatched
= ( xControl
== xIf
);
153 sCodeName
= msThisDocumentCodeName
;
158 catch( uno::Exception
& )
162 // #TODO Probably should throw here ( if !bMatched )
169 typedef std::unordered_map
< OUString
, OUString
> StringHashMap
;
173 class SwVbaProjectNameProvider
: public ::cppu::WeakImplHelper
< container::XNameContainer
>
175 StringHashMap mTemplateToProject
;
177 SwVbaProjectNameProvider()
180 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
182 return ( mTemplateToProject
.find( aName
) != mTemplateToProject
.end() );
184 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
186 if ( !hasByName( aName
) )
187 throw container::NoSuchElementException();
188 return uno::Any( mTemplateToProject
.find( aName
)->second
);
190 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
192 return comphelper::mapKeysToSequence( mTemplateToProject
);
195 virtual void SAL_CALL
insertByName( const OUString
& aName
, const uno::Any
& aElement
) override
198 OUString sProjectName
;
199 aElement
>>= sProjectName
;
200 SAL_INFO("sw.uno", "Template cache inserting template name " << aName
201 << " with project " << sProjectName
);
202 mTemplateToProject
[ aName
] = sProjectName
;
205 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
207 if ( !hasByName( Name
) )
208 throw container::NoSuchElementException();
209 mTemplateToProject
.erase( Name
);
211 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const uno::Any
& aElement
) override
213 if ( !hasByName( aName
) )
214 throw container::NoSuchElementException();
215 insertByName( aName
, aElement
); // insert will overwrite
218 virtual css::uno::Type SAL_CALL
getElementType( ) override
220 return ::cppu::UnoType
<OUString
>::get();
222 virtual sal_Bool SAL_CALL
hasElements( ) override
225 return ( !mTemplateToProject
.empty() );
230 class SwVbaObjectForCodeNameProvider
: public ::cppu::WeakImplHelper
< container::XNameAccess
>
232 SwDocShell
* mpDocShell
;
234 explicit SwVbaObjectForCodeNameProvider( SwDocShell
* pDocShell
) : mpDocShell( pDocShell
)
236 // #FIXME #TODO is the code name for ThisDocument read anywhere?
239 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
241 // #FIXME #TODO we really need to be checking against the codename for
243 if ( aName
== "ThisDocument" )
248 css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
250 if ( !hasByName( aName
) )
251 throw container::NoSuchElementException();
252 uno::Sequence
< uno::Any
> aArgs
{ uno::Any(uno::Reference
< uno::XInterface
>()),
253 uno::Any(mpDocShell
->GetModel()) };
254 uno::Reference
< uno::XInterface
> xDocObj
= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell
, "ooo.vba.word.Document" , aArgs
);
256 "Creating Object ( ooo.vba.word.Document ) 0x" << xDocObj
.get());
257 return uno::Any( xDocObj
);
259 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
261 uno::Sequence
< OUString
> aNames
;
265 virtual css::uno::Type SAL_CALL
getElementType( ) override
{ return uno::Type(); }
266 virtual sal_Bool SAL_CALL
hasElements( ) override
{ return true; }
276 struct ProvNamesId_Type
284 // note: this thing is indexed as an array, so do not insert/remove entries!
285 const ProvNamesId_Type aProvNamesId
[] =
287 { "com.sun.star.text.TextTable", SwServiceType::TypeTextTable
},
288 { "com.sun.star.text.TextFrame", SwServiceType::TypeTextFrame
},
289 { "com.sun.star.text.GraphicObject", SwServiceType::TypeGraphic
},
290 { "com.sun.star.text.TextEmbeddedObject", SwServiceType::TypeOLE
},
291 { "com.sun.star.text.Bookmark", SwServiceType::TypeBookmark
},
292 { "com.sun.star.text.Footnote", SwServiceType::TypeFootnote
},
293 { "com.sun.star.text.Endnote", SwServiceType::TypeEndnote
},
294 { "com.sun.star.text.DocumentIndexMark", SwServiceType::TypeIndexMark
},
295 { "com.sun.star.text.DocumentIndex", SwServiceType::TypeIndex
},
296 { "com.sun.star.text.ReferenceMark", SwServiceType::ReferenceMark
},
297 { "com.sun.star.style.CharacterStyle", SwServiceType::StyleCharacter
},
298 { "com.sun.star.style.ParagraphStyle", SwServiceType::StyleParagraph
},
299 { "com.sun.star.style.FrameStyle", SwServiceType::StyleFrame
},
300 { "com.sun.star.style.PageStyle", SwServiceType::StylePage
},
301 { "com.sun.star.style.NumberingStyle", SwServiceType::StyleNumbering
},
302 { "com.sun.star.text.ContentIndexMark", SwServiceType::ContentIndexMark
},
303 { "com.sun.star.text.ContentIndex", SwServiceType::ContentIndex
},
304 { "com.sun.star.text.UserIndexMark", SwServiceType::UserIndexMark
},
305 { "com.sun.star.text.UserIndex", SwServiceType::UserIndex
},
306 { "com.sun.star.text.TextSection", SwServiceType::TextSection
},
307 { "com.sun.star.text.TextField.DateTime", SwServiceType::FieldTypeDateTime
},
308 { "com.sun.star.text.TextField.User", SwServiceType::FieldTypeUser
},
309 { "com.sun.star.text.TextField.SetExpression", SwServiceType::FieldTypeSetExp
},
310 { "com.sun.star.text.TextField.GetExpression", SwServiceType::FieldTypeGetExp
},
311 { "com.sun.star.text.TextField.FileName", SwServiceType::FieldTypeFileName
},
312 { "com.sun.star.text.TextField.PageNumber", SwServiceType::FieldTypePageNum
},
313 { "com.sun.star.text.TextField.Author", SwServiceType::FieldTypeAuthor
},
314 { "com.sun.star.text.TextField.Chapter", SwServiceType::FieldTypeChapter
},
315 { "", SwServiceType::FieldTypeDummy0
},
316 { "com.sun.star.text.TextField.GetReference", SwServiceType::FieldTypeGetReference
},
317 { "com.sun.star.text.TextField.ConditionalText", SwServiceType::FieldTypeConditionedText
},
318 { "com.sun.star.text.TextField.Annotation", SwServiceType::FieldTypeAnnotation
},
319 { "com.sun.star.text.TextField.Input", SwServiceType::FieldTypeInput
},
320 { "com.sun.star.text.TextField.Macro", SwServiceType::FieldTypeMacro
},
321 { "com.sun.star.text.TextField.DDE", SwServiceType::FieldTypeDDE
},
322 { "com.sun.star.text.TextField.HiddenParagraph", SwServiceType::FieldTypeHiddenPara
},
323 { "" /*com.sun.star.text.TextField.DocumentInfo"*/, SwServiceType::FieldTypeDocInfo
},
324 { "com.sun.star.text.TextField.TemplateName", SwServiceType::FieldTypeTemplateName
},
325 { "com.sun.star.text.TextField.ExtendedUser", SwServiceType::FieldTypeUserExt
},
326 { "com.sun.star.text.TextField.ReferencePageSet", SwServiceType::FieldTypeRefPageSet
},
327 { "com.sun.star.text.TextField.ReferencePageGet", SwServiceType::FieldTypeRefPageGet
},
328 { "com.sun.star.text.TextField.JumpEdit", SwServiceType::FieldTypeJumpEdit
},
329 { "com.sun.star.text.TextField.Script", SwServiceType::FieldTypeScript
},
330 { "com.sun.star.text.TextField.DatabaseNextSet", SwServiceType::FieldTypeDatabaseNextSet
},
331 { "com.sun.star.text.TextField.DatabaseNumberOfSet", SwServiceType::FieldTypeDatabaseNumSet
},
332 { "com.sun.star.text.TextField.DatabaseSetNumber", SwServiceType::FieldTypeDatabaseSetNum
},
333 { "com.sun.star.text.TextField.Database", SwServiceType::FieldTypeDatabase
},
334 { "com.sun.star.text.TextField.DatabaseName", SwServiceType::FieldTypeDatabaseName
},
335 { "com.sun.star.text.TextField.TableFormula", SwServiceType::FieldTypeTableFormula
},
336 { "com.sun.star.text.TextField.PageCount", SwServiceType::FieldTypePageCount
},
337 { "com.sun.star.text.TextField.ParagraphCount", SwServiceType::FieldTypeParagraphCount
},
338 { "com.sun.star.text.TextField.WordCount", SwServiceType::FieldTypeWordCount
},
339 { "com.sun.star.text.TextField.CharacterCount", SwServiceType::FieldTypeCharacterCount
},
340 { "com.sun.star.text.TextField.TableCount", SwServiceType::FieldTypeTableCount
},
341 { "com.sun.star.text.TextField.GraphicObjectCount", SwServiceType::FieldTypeGraphicObjectCount
},
342 { "com.sun.star.text.TextField.EmbeddedObjectCount", SwServiceType::FieldTypeEmbeddedObjectCount
},
343 { "com.sun.star.text.TextField.DocInfo.ChangeAuthor", SwServiceType::FieldTypeDocInfoChangeAuthor
},
344 { "com.sun.star.text.TextField.DocInfo.ChangeDateTime", SwServiceType::FieldTypeDocInfoChangeDateTime
},
345 { "com.sun.star.text.TextField.DocInfo.EditTime", SwServiceType::FieldTypeDocInfoEditTime
},
346 { "com.sun.star.text.TextField.DocInfo.Description", SwServiceType::FieldTypeDocInfoDescription
},
347 { "com.sun.star.text.TextField.DocInfo.CreateAuthor", SwServiceType::FieldTypeDocInfoCreateAuthor
},
348 { "com.sun.star.text.TextField.DocInfo.CreateDateTime", SwServiceType::FieldTypeDocInfoCreateDateTime
},
349 { "", SwServiceType::FieldTypeDummy0
},
350 { "", SwServiceType::FieldTypeDummy1
},
351 { "", SwServiceType::FieldTypeDummy2
},
352 { "", SwServiceType::FieldTypeDummy3
},
353 { "com.sun.star.text.TextField.DocInfo.Custom", SwServiceType::FieldTypeDocInfoCustom
},
354 { "com.sun.star.text.TextField.DocInfo.PrintAuthor", SwServiceType::FieldTypeDocInfoPrintAuthor
},
355 { "com.sun.star.text.TextField.DocInfo.PrintDateTime", SwServiceType::FieldTypeDocInfoPrintDateTime
},
356 { "com.sun.star.text.TextField.DocInfo.KeyWords", SwServiceType::FieldTypeDocInfoKeywords
},
357 { "com.sun.star.text.TextField.DocInfo.Subject", SwServiceType::FieldTypeDocInfoSubject
},
358 { "com.sun.star.text.TextField.DocInfo.Title", SwServiceType::FieldTypeDocInfoTitle
},
359 { "com.sun.star.text.TextField.DocInfo.Revision", SwServiceType::FieldTypeDocInfoRevision
},
360 { "com.sun.star.text.TextField.Bibliography", SwServiceType::FieldTypeBibliography
},
361 { "com.sun.star.text.TextField.CombinedCharacters", SwServiceType::FieldTypeCombinedCharacters
},
362 { "com.sun.star.text.TextField.DropDown", SwServiceType::FieldTypeDropdown
},
363 { "com.sun.star.text.textfield.MetadataField", SwServiceType::FieldTypeMetafield
},
364 { "", SwServiceType::FieldTypeDummy4
},
365 { "", SwServiceType::FieldTypeDummy5
},
366 { "", SwServiceType::FieldTypeDummy6
},
367 { "", SwServiceType::FieldTypeDummy7
},
368 { "com.sun.star.text.FieldMaster.User", SwServiceType::FieldMasterUser
},
369 { "com.sun.star.text.FieldMaster.DDE", SwServiceType::FieldMasterDDE
},
370 { "com.sun.star.text.FieldMaster.SetExpression", SwServiceType::FieldMasterSetExp
},
371 { "com.sun.star.text.FieldMaster.Database", SwServiceType::FieldMasterDatabase
},
372 { "com.sun.star.text.FieldMaster.Bibliography", SwServiceType::FieldMasterBibliography
},
373 { "", SwServiceType::FieldMasterDummy2
},
374 { "", SwServiceType::FieldMasterDummy3
},
375 { "", SwServiceType::FieldMasterDummy4
},
376 { "", SwServiceType::FieldMasterDummy5
},
377 { "com.sun.star.text.IllustrationsIndex", SwServiceType::IndexIllustrations
},
378 { "com.sun.star.text.ObjectIndex", SwServiceType::IndexObjects
},
379 { "com.sun.star.text.TableIndex", SwServiceType::IndexTables
},
380 { "com.sun.star.text.Bibliography", SwServiceType::IndexBibliography
},
381 { "com.sun.star.text.Paragraph", SwServiceType::Paragraph
},
382 { "com.sun.star.text.TextField.InputUser", SwServiceType::FieldTypeInputUser
},
383 { "com.sun.star.text.TextField.HiddenText", SwServiceType::FieldTypeHiddenText
},
384 { "com.sun.star.style.ConditionalParagraphStyle", SwServiceType::StyleConditionalParagraph
},
385 { "com.sun.star.text.NumberingRules", SwServiceType::NumberingRules
},
386 { "com.sun.star.text.TextColumns", SwServiceType::TextColumns
},
387 { "com.sun.star.text.IndexHeaderSection", SwServiceType::IndexHeaderSection
},
388 { "com.sun.star.text.Defaults", SwServiceType::Defaults
},
389 { "com.sun.star.image.ImageMapRectangleObject", SwServiceType::IMapRectangle
},
390 { "com.sun.star.image.ImageMapCircleObject", SwServiceType::IMapCircle
},
391 { "com.sun.star.image.ImageMapPolygonObject", SwServiceType::IMapPolygon
},
392 { "com.sun.star.text.TextGraphicObject", SwServiceType::TypeTextGraphic
},
393 { "com.sun.star.chart2.data.DataProvider", SwServiceType::Chart2DataProvider
},
394 { "com.sun.star.text.Fieldmark", SwServiceType::TypeFieldMark
},
395 { "com.sun.star.text.FormFieldmark", SwServiceType::TypeFormFieldMark
},
396 { "com.sun.star.text.InContentMetadata", SwServiceType::TypeMeta
},
397 { "ooo.vba.VBAObjectModuleObjectProvider", SwServiceType::VbaObjectProvider
},
398 { "ooo.vba.VBACodeNameProvider", SwServiceType::VbaCodeNameProvider
},
399 { "ooo.vba.VBAProjectNameProvider", SwServiceType::VbaProjectNameProvider
},
400 { "ooo.vba.VBAGlobals", SwServiceType::VbaGlobals
},
402 // case-correct versions of the service names (see #i67811)
403 { CSS_TEXT_TEXTFIELD_DATE_TIME
, SwServiceType::FieldTypeDateTime
},
404 { CSS_TEXT_TEXTFIELD_USER
, SwServiceType::FieldTypeUser
},
405 { CSS_TEXT_TEXTFIELD_SET_EXPRESSION
, SwServiceType::FieldTypeSetExp
},
406 { CSS_TEXT_TEXTFIELD_GET_EXPRESSION
, SwServiceType::FieldTypeGetExp
},
407 { CSS_TEXT_TEXTFIELD_FILE_NAME
, SwServiceType::FieldTypeFileName
},
408 { CSS_TEXT_TEXTFIELD_PAGE_NUMBER
, SwServiceType::FieldTypePageNum
},
409 { CSS_TEXT_TEXTFIELD_AUTHOR
, SwServiceType::FieldTypeAuthor
},
410 { CSS_TEXT_TEXTFIELD_CHAPTER
, SwServiceType::FieldTypeChapter
},
411 { CSS_TEXT_TEXTFIELD_GET_REFERENCE
, SwServiceType::FieldTypeGetReference
},
412 { CSS_TEXT_TEXTFIELD_CONDITIONAL_TEXT
, SwServiceType::FieldTypeConditionedText
},
413 { CSS_TEXT_TEXTFIELD_ANNOTATION
, SwServiceType::FieldTypeAnnotation
},
414 { CSS_TEXT_TEXTFIELD_INPUT
, SwServiceType::FieldTypeInput
},
415 { CSS_TEXT_TEXTFIELD_MACRO
, SwServiceType::FieldTypeMacro
},
416 { CSS_TEXT_TEXTFIELD_DDE
, SwServiceType::FieldTypeDDE
},
417 { CSS_TEXT_TEXTFIELD_HIDDEN_PARAGRAPH
, SwServiceType::FieldTypeHiddenPara
},
418 { CSS_TEXT_TEXTFIELD_TEMPLATE_NAME
, SwServiceType::FieldTypeTemplateName
},
419 { CSS_TEXT_TEXTFIELD_EXTENDED_USER
, SwServiceType::FieldTypeUserExt
},
420 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_SET
, SwServiceType::FieldTypeRefPageSet
},
421 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_GET
, SwServiceType::FieldTypeRefPageGet
},
422 { CSS_TEXT_TEXTFIELD_JUMP_EDIT
, SwServiceType::FieldTypeJumpEdit
},
423 { CSS_TEXT_TEXTFIELD_SCRIPT
, SwServiceType::FieldTypeScript
},
424 { CSS_TEXT_TEXTFIELD_DATABASE_NEXT_SET
, SwServiceType::FieldTypeDatabaseNextSet
},
425 { CSS_TEXT_TEXTFIELD_DATABASE_NUMBER_OF_SET
, SwServiceType::FieldTypeDatabaseNumSet
},
426 { CSS_TEXT_TEXTFIELD_DATABASE_SET_NUMBER
, SwServiceType::FieldTypeDatabaseSetNum
},
427 { CSS_TEXT_TEXTFIELD_DATABASE
, SwServiceType::FieldTypeDatabase
},
428 { CSS_TEXT_TEXTFIELD_DATABASE_NAME
, SwServiceType::FieldTypeDatabaseName
},
429 { CSS_TEXT_TEXTFIELD_TABLE_FORMULA
, SwServiceType::FieldTypeTableFormula
},
430 { CSS_TEXT_TEXTFIELD_PAGE_COUNT
, SwServiceType::FieldTypePageCount
},
431 { CSS_TEXT_TEXTFIELD_PARAGRAPH_COUNT
, SwServiceType::FieldTypeParagraphCount
},
432 { CSS_TEXT_TEXTFIELD_WORD_COUNT
, SwServiceType::FieldTypeWordCount
},
433 { CSS_TEXT_TEXTFIELD_CHARACTER_COUNT
, SwServiceType::FieldTypeCharacterCount
},
434 { CSS_TEXT_TEXTFIELD_TABLE_COUNT
, SwServiceType::FieldTypeTableCount
},
435 { CSS_TEXT_TEXTFIELD_GRAPHIC_OBJECT_COUNT
, SwServiceType::FieldTypeGraphicObjectCount
},
436 { CSS_TEXT_TEXTFIELD_EMBEDDED_OBJECT_COUNT
, SwServiceType::FieldTypeEmbeddedObjectCount
},
437 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_AUTHOR
, SwServiceType::FieldTypeDocInfoChangeAuthor
},
438 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_DATE_TIME
, SwServiceType::FieldTypeDocInfoChangeDateTime
},
439 { CSS_TEXT_TEXTFIELD_DOCINFO_EDIT_TIME
, SwServiceType::FieldTypeDocInfoEditTime
},
440 { CSS_TEXT_TEXTFIELD_DOCINFO_DESCRIPTION
, SwServiceType::FieldTypeDocInfoDescription
},
441 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_AUTHOR
, SwServiceType::FieldTypeDocInfoCreateAuthor
},
442 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_DATE_TIME
, SwServiceType::FieldTypeDocInfoCreateDateTime
},
443 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_AUTHOR
, SwServiceType::FieldTypeDocInfoPrintAuthor
},
444 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_DATE_TIME
, SwServiceType::FieldTypeDocInfoPrintDateTime
},
445 { CSS_TEXT_TEXTFIELD_DOCINFO_KEY_WORDS
, SwServiceType::FieldTypeDocInfoKeywords
},
446 { CSS_TEXT_TEXTFIELD_DOCINFO_SUBJECT
, SwServiceType::FieldTypeDocInfoSubject
},
447 { CSS_TEXT_TEXTFIELD_DOCINFO_TITLE
, SwServiceType::FieldTypeDocInfoTitle
},
448 { CSS_TEXT_TEXTFIELD_DOCINFO_REVISION
, SwServiceType::FieldTypeDocInfoRevision
},
449 { CSS_TEXT_TEXTFIELD_DOCINFO_CUSTOM
, SwServiceType::FieldTypeDocInfoCustom
},
450 { CSS_TEXT_TEXTFIELD_BIBLIOGRAPHY
, SwServiceType::FieldTypeBibliography
},
451 { CSS_TEXT_TEXTFIELD_COMBINED_CHARACTERS
, SwServiceType::FieldTypeCombinedCharacters
},
452 { CSS_TEXT_TEXTFIELD_DROP_DOWN
, SwServiceType::FieldTypeDropdown
},
453 { CSS_TEXT_TEXTFIELD_INPUT_USER
, SwServiceType::FieldTypeInputUser
},
454 { CSS_TEXT_TEXTFIELD_HIDDEN_TEXT
, SwServiceType::FieldTypeHiddenText
},
455 { CSS_TEXT_FIELDMASTER_USER
, SwServiceType::FieldMasterUser
},
456 { CSS_TEXT_FIELDMASTER_DDE
, SwServiceType::FieldMasterDDE
},
457 { CSS_TEXT_FIELDMASTER_SET_EXPRESSION
, SwServiceType::FieldMasterSetExp
},
458 { CSS_TEXT_FIELDMASTER_DATABASE
, SwServiceType::FieldMasterDatabase
},
459 { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY
, SwServiceType::FieldMasterBibliography
},
460 { "com.sun.star.style.TableStyle", SwServiceType::StyleTable
},
461 { "com.sun.star.style.CellStyle", SwServiceType::StyleCell
},
462 { "com.sun.star.text.LineBreak", SwServiceType::LineBreak
},
463 { "com.sun.star.text.ContentControl", SwServiceType::ContentControl
}
466 const SvEventDescription
* sw_GetSupportedMacroItems()
468 static const SvEventDescription aMacroDescriptionsImpl
[] =
470 { SvMacroItemId::OnMouseOver
, "OnMouseOver" },
471 { SvMacroItemId::OnMouseOut
, "OnMouseOut" },
472 { SvMacroItemId::NONE
, nullptr }
475 return aMacroDescriptionsImpl
;
478 OUString
SwXServiceProvider::GetProviderName(SwServiceType nObjectType
)
481 const sal_uInt16 nEntries
= SAL_N_ELEMENTS(aProvNamesId
);
482 if(static_cast<sal_uInt16
>(nObjectType
) < nEntries
)
483 sRet
= OUString::createFromAscii(aProvNamesId
[static_cast<sal_uInt16
>(nObjectType
)].pName
);
487 uno::Sequence
<OUString
> SwXServiceProvider::GetAllServiceNames()
489 const sal_uInt16 nEntries
= SAL_N_ELEMENTS(aProvNamesId
);
490 uno::Sequence
<OUString
> aRet(nEntries
);
491 OUString
* pArray
= aRet
.getArray();
493 for(const ProvNamesId_Type
& i
: aProvNamesId
)
495 OUString
sProv(OUString::createFromAscii(i
.pName
));
507 SwServiceType
SwXServiceProvider::GetProviderType(std::u16string_view rServiceName
)
509 for(const ProvNamesId_Type
& i
: aProvNamesId
)
511 if (o3tl::equalsAscii(rServiceName
, i
.pName
))
514 return SwServiceType::Invalid
;
517 uno::Reference
<uno::XInterface
>
518 SwXServiceProvider::MakeInstance(SwServiceType nObjectType
, SwDoc
& rDoc
)
520 SolarMutexGuard aGuard
;
521 uno::Reference
< uno::XInterface
> xRet
;
524 case SwServiceType::TypeTextTable
:
526 xRet
= getXWeak(SwXTextTable::CreateXTextTable(nullptr).get());
529 case SwServiceType::TypeTextFrame
:
531 xRet
= getXWeak(SwXTextFrame::CreateXTextFrame(rDoc
, nullptr).get());
534 case SwServiceType::TypeGraphic
:
535 case SwServiceType::TypeTextGraphic
/* #i47503# */ :
537 xRet
= getXWeak(SwXTextGraphicObject::CreateXTextGraphicObject(rDoc
, nullptr).get());
541 case SwServiceType::TypeOLE
:
543 xRet
= getXWeak(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(rDoc
, nullptr).get());
546 case SwServiceType::TypeBookmark
:
548 xRet
= getXWeak(SwXBookmark::CreateXBookmark(rDoc
, nullptr).get());
551 case SwServiceType::TypeFieldMark
:
553 xRet
= getXWeak(SwXFieldmark::CreateXFieldmark(rDoc
, nullptr).get());
556 case SwServiceType::TypeFormFieldMark
:
558 xRet
= getXWeak(SwXFieldmark::CreateXFieldmark(rDoc
, nullptr, true).get());
561 case SwServiceType::VbaObjectProvider
:
562 #if HAVE_FEATURE_SCRIPTING
564 xRet
= getXWeak(new SwVbaObjectForCodeNameProvider(rDoc
.GetDocShell()));
568 case SwServiceType::VbaCodeNameProvider
:
569 #if HAVE_FEATURE_SCRIPTING
571 if (rDoc
.GetDocShell() && ooo::vba::isAlienWordDoc(*rDoc
.GetDocShell()))
573 xRet
= getXWeak(new SwVbaCodeNameProvider(rDoc
.GetDocShell()));
578 case SwServiceType::VbaProjectNameProvider
:
579 #if HAVE_FEATURE_SCRIPTING
581 uno::Reference
< container::XNameContainer
> xProjProv
= rDoc
.GetVBATemplateToProjectCache();
582 if (!xProjProv
.is() && rDoc
.GetDocShell()
583 && ooo::vba::isAlienWordDoc(*rDoc
.GetDocShell()))
585 xProjProv
= new SwVbaProjectNameProvider
;
586 rDoc
.SetVBATemplateToProjectCache(xProjProv
);
592 case SwServiceType::VbaGlobals
:
593 #if HAVE_FEATURE_SCRIPTING
596 if (SwDocShell
* pShell
= rDoc
.GetDocShell())
598 BasicManager
*pBasicMan
= pShell
->GetBasicManager();
599 if (pBasicMan
&& !pBasicMan
->GetGlobalUNOConstant(u
"VBAGlobals"_ustr
, aGlobs
))
601 uno::Sequence
< uno::Any
> aArgs
{ uno::Any(pShell
->GetModel()) };
602 aGlobs
<<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( u
"ooo.vba.word.Globals"_ustr
, aArgs
);
603 pBasicMan
->SetGlobalUNOConstant( u
"VBAGlobals"_ustr
, aGlobs
);
611 case SwServiceType::TypeFootnote
:
612 xRet
= getXWeak(SwXFootnote::CreateXFootnote(rDoc
, nullptr).get());
614 case SwServiceType::TypeEndnote
:
615 xRet
= getXWeak(SwXFootnote::CreateXFootnote(rDoc
, nullptr, true).get());
617 case SwServiceType::ContentIndexMark
:
618 case SwServiceType::UserIndexMark
:
619 case SwServiceType::TypeIndexMark
:
621 TOXTypes eType
= TOX_INDEX
;
622 if(SwServiceType::ContentIndexMark
== nObjectType
)
624 else if(SwServiceType::UserIndexMark
== nObjectType
)
626 xRet
= getXWeak(SwXDocumentIndexMark::CreateXDocumentIndexMark(rDoc
, nullptr, eType
).get());
629 case SwServiceType::ContentIndex
:
630 case SwServiceType::UserIndex
:
631 case SwServiceType::TypeIndex
:
632 case SwServiceType::IndexIllustrations
:
633 case SwServiceType::IndexObjects
:
634 case SwServiceType::IndexTables
:
635 case SwServiceType::IndexBibliography
:
637 TOXTypes eType
= TOX_INDEX
;
638 if(SwServiceType::ContentIndex
== nObjectType
)
640 else if(SwServiceType::UserIndex
== nObjectType
)
642 else if(SwServiceType::IndexIllustrations
== nObjectType
)
644 eType
= TOX_ILLUSTRATIONS
;
646 else if(SwServiceType::IndexObjects
== nObjectType
)
650 else if(SwServiceType::IndexBibliography
== nObjectType
)
652 eType
= TOX_AUTHORITIES
;
654 else if(SwServiceType::IndexTables
== nObjectType
)
658 xRet
= getXWeak(SwXDocumentIndex::CreateXDocumentIndex(rDoc
, nullptr, eType
).get());
661 case SwServiceType::IndexHeaderSection
:
662 case SwServiceType::TextSection
:
663 xRet
= getXWeak(SwXTextSection::CreateXTextSection(nullptr,
664 (SwServiceType::IndexHeaderSection
== nObjectType
)).get());
667 case SwServiceType::ReferenceMark
:
668 xRet
= getXWeak(SwXReferenceMark::CreateXReferenceMark(rDoc
, nullptr).get());
670 case SwServiceType::StyleCharacter
:
671 case SwServiceType::StyleParagraph
:
672 case SwServiceType::StyleConditionalParagraph
:
673 case SwServiceType::StyleFrame
:
674 case SwServiceType::StylePage
:
675 case SwServiceType::StyleNumbering
:
676 case SwServiceType::StyleTable
:
677 case SwServiceType::StyleCell
:
679 SfxStyleFamily eFamily
= SfxStyleFamily::Char
;
682 case SwServiceType::StyleParagraph
:
683 eFamily
= SfxStyleFamily::Para
;
685 case SwServiceType::StyleConditionalParagraph
:
686 eFamily
= SfxStyleFamily::Para
;
687 xRet
= SwXStyleFamilies::CreateStyleCondParagraph(rDoc
);
689 case SwServiceType::StyleFrame
:
690 eFamily
= SfxStyleFamily::Frame
;
692 case SwServiceType::StylePage
:
693 eFamily
= SfxStyleFamily::Page
;
695 case SwServiceType::StyleNumbering
:
696 eFamily
= SfxStyleFamily::Pseudo
;
698 case SwServiceType::StyleTable
:
699 eFamily
= SfxStyleFamily::Table
;
701 case SwServiceType::StyleCell
:
702 eFamily
= SfxStyleFamily::Cell
;
707 xRet
= SwXStyleFamilies::CreateStyle(eFamily
, rDoc
);
710 case SwServiceType::FieldTypeDateTime
:
711 case SwServiceType::FieldTypeUser
:
712 case SwServiceType::FieldTypeSetExp
:
713 case SwServiceType::FieldTypeGetExp
:
714 case SwServiceType::FieldTypeFileName
:
715 case SwServiceType::FieldTypePageNum
:
716 case SwServiceType::FieldTypeAuthor
:
717 case SwServiceType::FieldTypeChapter
:
718 case SwServiceType::FieldTypeGetReference
:
719 case SwServiceType::FieldTypeConditionedText
:
720 case SwServiceType::FieldTypeInput
:
721 case SwServiceType::FieldTypeMacro
:
722 case SwServiceType::FieldTypeDDE
:
723 case SwServiceType::FieldTypeHiddenPara
:
724 case SwServiceType::FieldTypeDocInfo
:
725 case SwServiceType::FieldTypeTemplateName
:
726 case SwServiceType::FieldTypeUserExt
:
727 case SwServiceType::FieldTypeRefPageSet
:
728 case SwServiceType::FieldTypeRefPageGet
:
729 case SwServiceType::FieldTypeJumpEdit
:
730 case SwServiceType::FieldTypeScript
:
731 case SwServiceType::FieldTypeDatabaseNextSet
:
732 case SwServiceType::FieldTypeDatabaseNumSet
:
733 case SwServiceType::FieldTypeDatabaseSetNum
:
734 case SwServiceType::FieldTypeDatabase
:
735 case SwServiceType::FieldTypeDatabaseName
:
736 case SwServiceType::FieldTypePageCount
:
737 case SwServiceType::FieldTypeParagraphCount
:
738 case SwServiceType::FieldTypeWordCount
:
739 case SwServiceType::FieldTypeCharacterCount
:
740 case SwServiceType::FieldTypeTableCount
:
741 case SwServiceType::FieldTypeGraphicObjectCount
:
742 case SwServiceType::FieldTypeEmbeddedObjectCount
:
743 case SwServiceType::FieldTypeDocInfoChangeAuthor
:
744 case SwServiceType::FieldTypeDocInfoChangeDateTime
:
745 case SwServiceType::FieldTypeDocInfoEditTime
:
746 case SwServiceType::FieldTypeDocInfoDescription
:
747 case SwServiceType::FieldTypeDocInfoCreateAuthor
:
748 case SwServiceType::FieldTypeDocInfoCreateDateTime
:
749 case SwServiceType::FieldTypeDocInfoCustom
:
750 case SwServiceType::FieldTypeDocInfoPrintAuthor
:
751 case SwServiceType::FieldTypeDocInfoPrintDateTime
:
752 case SwServiceType::FieldTypeDocInfoKeywords
:
753 case SwServiceType::FieldTypeDocInfoSubject
:
754 case SwServiceType::FieldTypeDocInfoTitle
:
755 case SwServiceType::FieldTypeDocInfoRevision
:
756 case SwServiceType::FieldTypeBibliography
:
757 case SwServiceType::FieldTypeInputUser
:
758 case SwServiceType::FieldTypeHiddenText
:
759 case SwServiceType::FieldTypeCombinedCharacters
:
760 case SwServiceType::FieldTypeDropdown
:
761 case SwServiceType::FieldTypeTableFormula
:
762 // NOTE: the sw.SwXAutoTextEntry unoapi test depends on pDoc = 0
763 xRet
= getXWeak(SwXTextField::CreateXTextField(nullptr, nullptr, nObjectType
).get());
765 case SwServiceType::FieldTypeAnnotation
:
766 xRet
= getXWeak(SwXTextField::CreateXTextField(&rDoc
, nullptr, nObjectType
).get());
768 case SwServiceType::FieldMasterUser
:
769 case SwServiceType::FieldMasterDDE
:
770 case SwServiceType::FieldMasterSetExp
:
771 case SwServiceType::FieldMasterDatabase
:
773 SwFieldIds nResId
= SwFieldIds::Unknown
;
776 case SwServiceType::FieldMasterUser
: nResId
= SwFieldIds::User
; break;
777 case SwServiceType::FieldMasterDDE
: nResId
= SwFieldIds::Dde
; break;
778 case SwServiceType::FieldMasterSetExp
: nResId
= SwFieldIds::SetExp
; break;
779 case SwServiceType::FieldMasterDatabase
: nResId
= SwFieldIds::Database
; break;
782 xRet
= getXWeak(SwXFieldMaster::CreateXFieldMaster(&rDoc
, nullptr, nResId
).get());
785 case SwServiceType::FieldMasterBibliography
:
787 SwFieldType
* pType
= rDoc
.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::TableOfAuthorities
, OUString(), true);
790 SwAuthorityFieldType
aType(&rDoc
);
791 pType
= rDoc
.getIDocumentFieldsAccess().InsertFieldType(aType
);
793 xRet
= getXWeak(SwXFieldMaster::CreateXFieldMaster(&rDoc
, pType
).get());
796 case SwServiceType::Paragraph
:
797 xRet
= getXWeak(SwXParagraph::CreateXParagraph(rDoc
, nullptr, nullptr).get());
799 case SwServiceType::NumberingRules
:
800 xRet
= getXWeak(new SwXNumberingRules(rDoc
));
802 case SwServiceType::TextColumns
:
803 xRet
= SvxXTextColumns_createInstance();
805 case SwServiceType::Defaults
:
806 xRet
= getXWeak(new SwXTextDefaults(&rDoc
));
808 case SwServiceType::IMapRectangle
:
809 xRet
= SvUnoImageMapRectangleObject_createInstance( sw_GetSupportedMacroItems() );
811 case SwServiceType::IMapCircle
:
812 xRet
= SvUnoImageMapCircleObject_createInstance( sw_GetSupportedMacroItems() );
814 case SwServiceType::IMapPolygon
:
815 xRet
= SvUnoImageMapPolygonObject_createInstance( sw_GetSupportedMacroItems() );
817 case SwServiceType::Chart2DataProvider
:
819 // #i64497# If a chart is in a temporary document during clipboard
820 // paste, there should be no data provider, so that own data is used
821 // This should not happen during copy/paste, as this will unlink
822 // charts using table data.
823 SwDocShell
* pShell
= rDoc
.GetDocShell();
824 if (pShell
&& pShell
->GetCreateMode() != SfxObjectCreateMode::EMBEDDED
)
825 xRet
= getXWeak(rDoc
.getIDocumentChartDataProviderAccess().GetChartDataProvider( true /* create - if not yet available */ ));
828 "not creating chart data provider for embedded object");
831 case SwServiceType::TypeMeta
:
832 xRet
= getXWeak(SwXMeta::CreateXMeta(rDoc
, false).get());
834 case SwServiceType::FieldTypeMetafield
:
835 xRet
= getXWeak(SwXMeta::CreateXMeta(rDoc
, true).get());
837 case SwServiceType::LineBreak
:
838 xRet
= getXWeak(SwXLineBreak::CreateXLineBreak(nullptr).get());
840 case SwServiceType::ContentControl
:
841 xRet
= getXWeak(SwXContentControl::CreateXContentControl(rDoc
).get());
844 throw uno::RuntimeException();
849 //SMART_UNO_IMPLEMENTATION( SwXTextTables, UsrObject );
850 SwXTextTables::SwXTextTables(SwDoc
* pDc
) :
856 SwXTextTables::~SwXTextTables()
861 sal_Int32
SwXTextTables::getCount()
863 SolarMutexGuard aGuard
;
866 nRet
= static_cast<sal_Int32
>(GetDoc().GetTableFrameFormatCount(true));
870 uno::Any SAL_CALL
SwXTextTables::getByIndex(sal_Int32 nInputIndex
)
872 uno::Reference
<XTextTable
> xTable
= getTextTableByIndex(nInputIndex
);
878 rtl::Reference
<SwXTextTable
> SwXTextTables::getTextTableByIndex(sal_Int32 nInputIndex
)
880 SolarMutexGuard aGuard
;
883 throw IndexOutOfBoundsException();
885 size_t nIndex
= static_cast<size_t>(nInputIndex
);
886 for(SwTableFormat
* pFormat
: *GetDoc().GetTableFrameFormats())
888 if(!pFormat
->IsUsed())
894 return SwXTextTables::GetObject(*pFormat
);
897 throw IndexOutOfBoundsException();
900 uno::Any
SwXTextTables::getByName(const OUString
& rItemName
)
902 return uno::Any(uno::Reference
< XTextTable
>(getTextTableByName(rItemName
)));
905 rtl::Reference
<SwXTextTable
> SwXTextTables::getTextTableByName(std::u16string_view rItemName
)
907 SolarMutexGuard aGuard
;
909 const size_t nCount
= GetDoc().GetTableFrameFormatCount(true);
910 rtl::Reference
< SwXTextTable
> xTable
;
911 for( size_t i
= 0; i
< nCount
; ++i
)
913 SwFrameFormat
& rFormat
= GetDoc().GetTableFrameFormat(i
, true);
914 if (rItemName
== rFormat
.GetName())
916 xTable
= SwXTextTables::GetObject(rFormat
);
921 throw NoSuchElementException();
926 uno::Sequence
< OUString
> SwXTextTables::getElementNames()
928 SolarMutexGuard aGuard
;
929 const size_t nCount
= GetDoc().GetTableFrameFormatCount(true);
930 uno::Sequence
<OUString
> aSeq(static_cast<sal_Int32
>(nCount
));
933 OUString
* pArray
= aSeq
.getArray();
934 for( size_t i
= 0; i
< nCount
; ++i
)
936 SwFrameFormat
& rFormat
= GetDoc().GetTableFrameFormat(i
, true);
938 pArray
[i
] = rFormat
.GetName();
944 sal_Bool
SwXTextTables::hasByName(const OUString
& rName
)
946 SolarMutexGuard aGuard
;
949 const size_t nCount
= GetDoc().GetTableFrameFormatCount(true);
950 for( size_t i
= 0; i
< nCount
; ++i
)
952 SwFrameFormat
& rFormat
= GetDoc().GetTableFrameFormat(i
, true);
953 if (rName
== rFormat
.GetName())
963 SwXTextTables::getElementType( )
965 return cppu::UnoType
<XTextTable
>::get();
968 sal_Bool
SwXTextTables::hasElements()
970 SolarMutexGuard aGuard
;
971 return 0 != GetDoc().GetTableFrameFormatCount(true);
974 OUString
SwXTextTables::getImplementationName()
976 return u
"SwXTextTables"_ustr
;
979 sal_Bool
SwXTextTables::supportsService(const OUString
& rServiceName
)
981 return cppu::supportsService(this, rServiceName
);
984 uno::Sequence
< OUString
> SwXTextTables::getSupportedServiceNames()
986 return { u
"com.sun.star.text.TextTables"_ustr
};
989 rtl::Reference
<SwXTextTable
> SwXTextTables::GetObject(SwFrameFormat
& rFormat
)
991 return SwXTextTable::CreateXTextTable(& rFormat
);
996 template<FlyCntType T
> struct UnoFrameWrap_traits
{};
999 struct UnoFrameWrap_traits
<FLYCNTTYPE_FRM
>
1001 static uno::Any
wrapFrame(SwFrameFormat
& rFrameFormat
)
1003 uno::Reference
<text::XTextFrame
> const xRet(
1004 SwXTextFrame::CreateXTextFrame(*rFrameFormat
.GetDoc(), &rFrameFormat
));
1005 return uno::Any(xRet
);
1007 static bool filter(const SwNode
* const pNode
) { return !pNode
->IsNoTextNode(); };
1011 struct UnoFrameWrap_traits
<FLYCNTTYPE_GRF
>
1013 static uno::Any
wrapFrame(SwFrameFormat
& rFrameFormat
)
1015 uno::Reference
<text::XTextContent
> const xRet(
1016 SwXTextGraphicObject::CreateXTextGraphicObject(*rFrameFormat
.GetDoc(), &rFrameFormat
));
1017 return uno::Any(xRet
);
1019 static bool filter(const SwNode
* const pNode
) { return pNode
->IsGrfNode(); };
1023 struct UnoFrameWrap_traits
<FLYCNTTYPE_OLE
>
1025 static uno::Any
wrapFrame(SwFrameFormat
& rFrameFormat
)
1027 uno::Reference
<text::XTextContent
> const xRet(
1028 SwXTextEmbeddedObject::CreateXTextEmbeddedObject(*rFrameFormat
.GetDoc(), &rFrameFormat
));
1029 return uno::Any(xRet
);
1031 static bool filter(const SwNode
* const pNode
) { return pNode
->IsOLENode(); };
1034 template<FlyCntType T
>
1035 uno::Any
lcl_UnoWrapFrame(SwFrameFormat
* pFormat
)
1037 return UnoFrameWrap_traits
<T
>::wrapFrame(*pFormat
);
1040 // runtime adapter for lcl_UnoWrapFrame
1041 /// @throws uno::RuntimeException
1042 uno::Any
lcl_UnoWrapFrame(SwFrameFormat
* pFormat
, FlyCntType eType
)
1046 case FLYCNTTYPE_FRM
:
1047 return lcl_UnoWrapFrame
<FLYCNTTYPE_FRM
>(pFormat
);
1048 case FLYCNTTYPE_GRF
:
1049 return lcl_UnoWrapFrame
<FLYCNTTYPE_GRF
>(pFormat
);
1050 case FLYCNTTYPE_OLE
:
1051 return lcl_UnoWrapFrame
<FLYCNTTYPE_OLE
>(pFormat
);
1053 throw uno::RuntimeException();
1057 template<FlyCntType T
>
1058 class SwXFrameEnumeration
1059 : public SwSimpleEnumeration_Base
1062 std::vector
< Any
> m_aFrames
;
1064 virtual ~SwXFrameEnumeration() override
{};
1066 SwXFrameEnumeration(const SwDoc
& rDoc
);
1069 virtual sal_Bool SAL_CALL
hasMoreElements() override
;
1070 virtual Any SAL_CALL
nextElement() override
;
1073 virtual OUString SAL_CALL
getImplementationName() override
;
1074 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
1075 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
1079 template<FlyCntType T
>
1080 SwXFrameEnumeration
<T
>::SwXFrameEnumeration(const SwDoc
& rDoc
)
1082 SolarMutexGuard aGuard
;
1083 for(sw::SpzFrameFormat
* pFormat
: *rDoc
.GetSpzFrameFormats())
1086 if(pFormat
->Which() != RES_FLYFRMFMT
|| SwTextBoxHelper::isTextBox(pFormat
, RES_FLYFRMFMT
))
1088 const SwNodeIndex
* pIdx
= pFormat
->GetContent().GetContentIdx();
1089 if(!pIdx
|| !pIdx
->GetNodes().IsDocNodes())
1091 const SwNode
* pNd
= rDoc
.GetNodes()[ pIdx
->GetIndex() + 1 ];
1092 if(UnoFrameWrap_traits
<T
>::filter(pNd
))
1093 m_aFrames
.push_back(lcl_UnoWrapFrame
<T
>(pFormat
));
1097 template<FlyCntType T
>
1098 sal_Bool SwXFrameEnumeration
<T
>::hasMoreElements()
1100 SolarMutexGuard aGuard
;
1101 return !m_aFrames
.empty();
1104 template<FlyCntType T
>
1105 Any SwXFrameEnumeration
<T
>::nextElement()
1107 SolarMutexGuard aGuard
;
1108 if(m_aFrames
.empty())
1109 throw NoSuchElementException();
1111 Any aResult
= m_aFrames
.back();
1112 m_aFrames
.pop_back();
1116 template<FlyCntType T
>
1117 OUString SwXFrameEnumeration
<T
>::getImplementationName()
1119 return u
"SwXFrameEnumeration"_ustr
;
1122 template<FlyCntType T
>
1123 sal_Bool SwXFrameEnumeration
<T
>::supportsService(const OUString
& ServiceName
)
1125 return cppu::supportsService(this, ServiceName
);
1128 template<FlyCntType T
>
1129 Sequence
< OUString
> SwXFrameEnumeration
<T
>::getSupportedServiceNames()
1131 return { u
"com.sun.star.container.XEnumeration"_ustr
};
1134 OUString
SwXFrames::getImplementationName()
1136 return u
"SwXFrames"_ustr
;
1139 sal_Bool
SwXFrames::supportsService(const OUString
& rServiceName
)
1141 return cppu::supportsService(this, rServiceName
);
1144 Sequence
<OUString
> SwXFrames::getSupportedServiceNames()
1146 return { u
"com.sun.star.text.TextFrames"_ustr
};
1149 SwXFrames::SwXFrames(SwDoc
* _pDoc
, FlyCntType eSet
) :
1150 SwUnoCollection(_pDoc
),
1154 SwXFrames::~SwXFrames()
1157 uno::Reference
<container::XEnumeration
> SwXFrames::createEnumeration()
1159 SolarMutexGuard aGuard
;
1162 case FLYCNTTYPE_FRM
:
1163 return uno::Reference
< container::XEnumeration
>(
1164 new SwXFrameEnumeration
<FLYCNTTYPE_FRM
>(GetDoc()));
1165 case FLYCNTTYPE_GRF
:
1166 return uno::Reference
< container::XEnumeration
>(
1167 new SwXFrameEnumeration
<FLYCNTTYPE_GRF
>(GetDoc()));
1168 case FLYCNTTYPE_OLE
:
1169 return uno::Reference
< container::XEnumeration
>(
1170 new SwXFrameEnumeration
<FLYCNTTYPE_OLE
>(GetDoc()));
1172 throw uno::RuntimeException();
1176 sal_Int32
SwXFrames::getCount()
1178 SolarMutexGuard aGuard
;
1179 // Ignore TextBoxes for TextFrames.
1180 return static_cast<sal_Int32
>(GetDoc().GetFlyCount(m_eType
, /*bIgnoreTextBoxes=*/m_eType
== FLYCNTTYPE_FRM
));
1183 uno::Any
SwXFrames::getByIndex(sal_Int32 nIndex
)
1185 SolarMutexGuard aGuard
;
1187 throw IndexOutOfBoundsException();
1188 // Ignore TextBoxes for TextFrames.
1189 SwFrameFormat
* pFormat
= GetDoc().GetFlyNum(static_cast<size_t>(nIndex
), m_eType
, /*bIgnoreTextBoxes=*/m_eType
== FLYCNTTYPE_FRM
);
1191 throw IndexOutOfBoundsException();
1192 return lcl_UnoWrapFrame(pFormat
, m_eType
);
1195 uno::Any
SwXFrames::getByName(const OUString
& rName
)
1197 SolarMutexGuard aGuard
;
1198 const SwFrameFormat
* pFormat
;
1201 case FLYCNTTYPE_GRF
:
1202 pFormat
= GetDoc().FindFlyByName(rName
, SwNodeType::Grf
);
1204 case FLYCNTTYPE_OLE
:
1205 pFormat
= GetDoc().FindFlyByName(rName
, SwNodeType::Ole
);
1208 pFormat
= GetDoc().FindFlyByName(rName
, SwNodeType::Text
);
1212 throw NoSuchElementException();
1213 return lcl_UnoWrapFrame(const_cast<SwFrameFormat
*>(pFormat
), m_eType
);
1216 uno::Sequence
<OUString
> SwXFrames::getElementNames()
1218 SolarMutexGuard aGuard
;
1219 const Reference
<XEnumeration
> xEnum
= createEnumeration();
1220 std::vector
<OUString
> vNames
;
1221 while(xEnum
->hasMoreElements())
1223 Reference
<container::XNamed
> xNamed
;
1224 xEnum
->nextElement() >>= xNamed
;
1226 vNames
.push_back(xNamed
->getName());
1228 return ::comphelper::containerToSequence(vNames
);
1231 sal_Bool
SwXFrames::hasByName(const OUString
& rName
)
1233 SolarMutexGuard aGuard
;
1236 case FLYCNTTYPE_GRF
:
1237 return GetDoc().FindFlyByName(rName
, SwNodeType::Grf
) != nullptr;
1238 case FLYCNTTYPE_OLE
:
1239 return GetDoc().FindFlyByName(rName
, SwNodeType::Ole
) != nullptr;
1241 return GetDoc().FindFlyByName(rName
, SwNodeType::Text
) != nullptr;
1245 uno::Type SAL_CALL
SwXFrames::getElementType()
1247 SolarMutexGuard aGuard
;
1250 case FLYCNTTYPE_FRM
:
1251 return cppu::UnoType
<XTextFrame
>::get();
1252 case FLYCNTTYPE_GRF
:
1253 return cppu::UnoType
<XTextContent
>::get();
1254 case FLYCNTTYPE_OLE
:
1255 return cppu::UnoType
<XEmbeddedObjectSupplier
>::get();
1261 sal_Bool
SwXFrames::hasElements()
1263 SolarMutexGuard aGuard
;
1264 return GetDoc().GetFlyCount(m_eType
) > 0;
1268 OUString
SwXTextFrames::getImplementationName()
1270 return u
"SwXTextFrames"_ustr
;
1273 sal_Bool
SwXTextFrames::supportsService(const OUString
& rServiceName
)
1275 return cppu::supportsService(this, rServiceName
);
1278 Sequence
< OUString
> SwXTextFrames::getSupportedServiceNames()
1280 return { u
"com.sun.star.text.TextFrames"_ustr
};
1283 SwXTextFrames::SwXTextFrames(SwDoc
* _pDoc
) :
1284 SwXFrames(_pDoc
, FLYCNTTYPE_FRM
)
1288 SwXTextFrames::~SwXTextFrames()
1292 OUString
SwXTextGraphicObjects::getImplementationName()
1294 return u
"SwXTextGraphicObjects"_ustr
;
1297 sal_Bool
SwXTextGraphicObjects::supportsService(const OUString
& rServiceName
)
1299 return cppu::supportsService(this, rServiceName
);
1302 Sequence
< OUString
> SwXTextGraphicObjects::getSupportedServiceNames()
1304 return { u
"com.sun.star.text.TextGraphicObjects"_ustr
};
1307 SwXTextGraphicObjects::SwXTextGraphicObjects(SwDoc
* _pDoc
) :
1308 SwXFrames(_pDoc
, FLYCNTTYPE_GRF
)
1312 SwXTextGraphicObjects::~SwXTextGraphicObjects()
1316 OUString
SwXTextEmbeddedObjects::getImplementationName()
1318 return u
"SwXTextEmbeddedObjects"_ustr
;
1321 sal_Bool
SwXTextEmbeddedObjects::supportsService(const OUString
& rServiceName
)
1323 return cppu::supportsService(this, rServiceName
);
1326 Sequence
< OUString
> SwXTextEmbeddedObjects::getSupportedServiceNames()
1328 return { u
"com.sun.star.text.TextEmbeddedObjects"_ustr
};
1331 SwXTextEmbeddedObjects::SwXTextEmbeddedObjects(SwDoc
* _pDoc
) :
1332 SwXFrames(_pDoc
, FLYCNTTYPE_OLE
)
1336 SwXTextEmbeddedObjects::~SwXTextEmbeddedObjects()
1340 OUString
SwXTextSections::getImplementationName()
1342 return u
"SwXTextSections"_ustr
;
1345 sal_Bool
SwXTextSections::supportsService(const OUString
& rServiceName
)
1347 return cppu::supportsService(this, rServiceName
);
1350 Sequence
< OUString
> SwXTextSections::getSupportedServiceNames()
1352 return { u
"com.sun.star.text.TextSections"_ustr
};
1355 SwXTextSections::SwXTextSections(SwDoc
* _pDoc
) :
1356 SwUnoCollection(_pDoc
)
1360 SwXTextSections::~SwXTextSections()
1364 sal_Int32
SwXTextSections::getCount()
1366 SolarMutexGuard aGuard
;
1367 const SwSectionFormats
& rSectFormats
= GetDoc().GetSections();
1368 size_t nCount
= rSectFormats
.size();
1369 for(size_t i
= nCount
; i
; --i
)
1371 if( !rSectFormats
[i
- 1]->IsInNodesArr())
1377 uno::Any
SwXTextSections::getByIndex(sal_Int32 nIndex
)
1380 throw IndexOutOfBoundsException();
1381 size_t nIndex2
= nIndex
;
1382 SolarMutexGuard aGuard
;
1384 const SwSectionFormats
& rSectFormats
= GetDoc().GetSections();
1385 const size_t nCount
= rSectFormats
.size();
1386 for(size_t i
= 0; i
< nCount
; ++i
)
1388 if( !rSectFormats
[i
]->IsInNodesArr())
1390 else if (nIndex2
== i
)
1391 return Any(css::uno::Reference
< css::text::XTextSection
>(GetObject(*rSectFormats
[i
])));
1393 throw IndexOutOfBoundsException();
1396 uno::Any
SwXTextSections::getByName(const OUString
& rName
)
1398 SolarMutexGuard aGuard
;
1401 SwSectionFormats
& rFormats
= GetDoc().GetSections();
1402 uno::Reference
< XTextSection
> xSect
;
1403 for(size_t i
= 0; i
< rFormats
.size(); ++i
)
1405 SwSectionFormat
* pFormat
= rFormats
[i
];
1406 if (pFormat
->IsInNodesArr()
1407 && (rName
== pFormat
->GetSection()->GetSectionName()))
1409 xSect
= GetObject(*pFormat
);
1415 throw NoSuchElementException();
1420 uno::Sequence
< OUString
> SwXTextSections::getElementNames()
1422 SolarMutexGuard aGuard
;
1423 SwSectionFormats
& rSectFormats
= GetDoc().GetSections();
1424 size_t nCount
= rSectFormats
.size();
1425 for(size_t i
= nCount
; i
; --i
)
1427 if( !rSectFormats
[i
- 1]->IsInNodesArr())
1431 uno::Sequence
<OUString
> aSeq(nCount
);
1434 OUString
* pArray
= aSeq
.getArray();
1436 for( size_t i
= 0; i
< nCount
; ++i
, ++nIndex
)
1438 const SwSectionFormat
* pFormat
= rSectFormats
[nIndex
];
1439 while(!pFormat
->IsInNodesArr())
1441 pFormat
= rSectFormats
[++nIndex
];
1443 pArray
[i
] = pFormat
->GetSection()->GetSectionName();
1449 sal_Bool
SwXTextSections::hasByName(const OUString
& rName
)
1451 SolarMutexGuard aGuard
;
1455 SwSectionFormats
& rFormats
= GetDoc().GetSections();
1456 for(size_t i
= 0; i
< rFormats
.size(); ++i
)
1458 const SwSectionFormat
* pFormat
= rFormats
[i
];
1459 if (rName
== pFormat
->GetSection()->GetSectionName())
1468 // special handling for dbg_ methods
1469 if( !rName
.startsWith("dbg_"))
1470 throw uno::RuntimeException();
1475 uno::Type SAL_CALL
SwXTextSections::getElementType()
1477 return cppu::UnoType
<XTextSection
>::get();
1480 sal_Bool
SwXTextSections::hasElements()
1482 SolarMutexGuard aGuard
;
1485 SwSectionFormats
& rFormats
= GetDoc().GetSections();
1486 nCount
= rFormats
.size();
1491 rtl::Reference
< SwXTextSection
> SwXTextSections::GetObject( SwSectionFormat
& rFormat
)
1493 return SwXTextSection::CreateXTextSection(&rFormat
);
1496 OUString
SwXBookmarks::getImplementationName()
1498 return u
"SwXBookmarks"_ustr
;
1501 sal_Bool
SwXBookmarks::supportsService(const OUString
& rServiceName
)
1503 return cppu::supportsService(this, rServiceName
);
1506 Sequence
< OUString
> SwXBookmarks::getSupportedServiceNames()
1508 return { u
"com.sun.star.text.Bookmarks"_ustr
};
1511 SwXBookmarks::SwXBookmarks(SwDoc
* _pDoc
) :
1512 SwUnoCollection(_pDoc
)
1515 SwXBookmarks::~SwXBookmarks()
1518 sal_Int32
SwXBookmarks::getCount()
1520 SolarMutexGuard aGuard
;
1523 IDocumentMarkAccess
* const pMarkAccess
= GetDoc().getIDocumentMarkAccess();
1524 for (auto ppMark
= pMarkAccess
->getBookmarksBegin();
1525 ppMark
!= pMarkAccess
->getBookmarksEnd(); ++ppMark
)
1527 if (IDocumentMarkAccess::MarkType::BOOKMARK
==
1528 IDocumentMarkAccess::GetType(**ppMark
))
1530 ++count
; // only count real bookmarks
1536 uno::Any
SwXBookmarks::getByIndex(sal_Int32 nIndex
)
1538 SolarMutexGuard aGuard
;
1539 auto& rDoc
= GetDoc();
1540 IDocumentMarkAccess
* const pMarkAccess
= rDoc
.getIDocumentMarkAccess();
1541 if(nIndex
< 0 || nIndex
>= pMarkAccess
->getBookmarksCount())
1542 throw IndexOutOfBoundsException();
1545 for (auto ppMark
= pMarkAccess
->getBookmarksBegin();
1546 ppMark
!= pMarkAccess
->getBookmarksEnd(); ++ppMark
)
1548 if (IDocumentMarkAccess::MarkType::BOOKMARK
==
1549 IDocumentMarkAccess::GetType(**ppMark
))
1551 if (count
== nIndex
)
1554 const uno::Reference
< text::XTextContent
> xRef
=
1555 SwXBookmark::CreateXBookmark(rDoc
, *ppMark
);
1559 ++count
; // only count real bookmarks
1562 throw IndexOutOfBoundsException();
1565 uno::Any
SwXBookmarks::getByName(const OUString
& rName
)
1567 SolarMutexGuard aGuard
;
1569 auto& rDoc
= GetDoc();
1570 IDocumentMarkAccess
* const pMarkAccess
= rDoc
.getIDocumentMarkAccess();
1571 auto ppBkmk
= pMarkAccess
->findBookmark(rName
);
1572 if(ppBkmk
== pMarkAccess
->getBookmarksEnd())
1573 throw NoSuchElementException();
1576 const uno::Reference
< text::XTextContent
> xRef
=
1577 SwXBookmark::CreateXBookmark(rDoc
, *ppBkmk
);
1582 uno::Sequence
< OUString
> SwXBookmarks::getElementNames()
1584 SolarMutexGuard aGuard
;
1586 std::vector
< OUString
> ret
;
1587 IDocumentMarkAccess
* const pMarkAccess
= GetDoc().getIDocumentMarkAccess();
1589 pMarkAccess
->getBookmarksBegin();
1590 ppMark
!= pMarkAccess
->getBookmarksEnd(); ++ppMark
)
1592 if (IDocumentMarkAccess::MarkType::BOOKMARK
==
1593 IDocumentMarkAccess::GetType(**ppMark
))
1595 ret
.push_back((*ppMark
)->GetName()); // only add real bookmarks
1598 return comphelper::containerToSequence(ret
);
1601 sal_Bool
SwXBookmarks::hasByName(const OUString
& rName
)
1603 SolarMutexGuard aGuard
;
1605 IDocumentMarkAccess
* const pMarkAccess
= GetDoc().getIDocumentMarkAccess();
1606 return pMarkAccess
->findBookmark(rName
) != pMarkAccess
->getBookmarksEnd();
1609 uno::Type SAL_CALL
SwXBookmarks::getElementType()
1611 return cppu::UnoType
<XTextContent
>::get();
1614 sal_Bool
SwXBookmarks::hasElements()
1616 SolarMutexGuard aGuard
;
1618 IDocumentMarkAccess
* const pMarkAccess
= GetDoc().getIDocumentMarkAccess();
1620 pMarkAccess
->getBookmarksBegin();
1621 ppMark
!= pMarkAccess
->getBookmarksEnd(); ++ppMark
)
1623 if (IDocumentMarkAccess::MarkType::BOOKMARK
==
1624 IDocumentMarkAccess::GetType(**ppMark
))
1632 SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc
* _pDoc
) :
1633 SwUnoCollection(_pDoc
)
1637 SwXNumberingRulesCollection::~SwXNumberingRulesCollection()
1641 sal_Int32
SwXNumberingRulesCollection::getCount()
1643 SolarMutexGuard aGuard
;
1644 return GetDoc().GetNumRuleTable().size();
1647 uno::Any
SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex
)
1650 throw IndexOutOfBoundsException();
1652 SolarMutexGuard aGuard
;
1654 if (SwDoc
& rDoc
= GetDoc(); o3tl::make_unsigned(nIndex
) < rDoc
.GetNumRuleTable().size())
1656 uno::Reference
<XIndexReplace
> xRef(
1657 new SwXNumberingRules(*rDoc
.GetNumRuleTable()[nIndex
], &rDoc
));
1658 return uno::Any(xRef
);
1661 throw IndexOutOfBoundsException();
1664 uno::Type SAL_CALL
SwXNumberingRulesCollection::getElementType()
1666 return cppu::UnoType
<XIndexReplace
>::get();
1669 sal_Bool
SwXNumberingRulesCollection::hasElements()
1671 SolarMutexGuard aGuard
;
1672 return !GetDoc().GetNumRuleTable().empty();
1675 OUString
SwXFootnotes::getImplementationName()
1677 return u
"SwXFootnotes"_ustr
;
1680 sal_Bool
SwXFootnotes::supportsService(const OUString
& rServiceName
)
1682 return cppu::supportsService(this, rServiceName
);
1685 Sequence
< OUString
> SwXFootnotes::getSupportedServiceNames()
1687 return { u
"com.sun.star.text.Footnotes"_ustr
};
1690 SwXFootnotes::SwXFootnotes(bool bEnd
, SwDoc
* _pDoc
)
1691 : SwUnoCollection(_pDoc
)
1696 SwXFootnotes::~SwXFootnotes()
1700 sal_Int32
SwXFootnotes::getCount()
1702 SolarMutexGuard aGuard
;
1703 sal_Int32 nCount
= 0;
1704 for (const SwTextFootnote
* pTextFootnote
: GetDoc().GetFootnoteIdxs())
1706 const SwFormatFootnote
& rFootnote
= pTextFootnote
->GetFootnote();
1707 if ( rFootnote
.IsEndNote() != m_bEndnote
)
1714 uno::Any
SwXFootnotes::getByIndex(sal_Int32 nIndex
)
1717 throw IndexOutOfBoundsException();
1718 return uno::Any(uno::Reference
< XFootnote
>(getFootnoteByIndex(nIndex
)));
1721 rtl::Reference
<SwXFootnote
> SwXFootnotes::getFootnoteByIndex(sal_Int32 nIndex
)
1723 SolarMutexGuard aGuard
;
1724 sal_Int32 nCount
= 0;
1726 auto& rDoc
= GetDoc();
1727 for (const SwTextFootnote
* pTextFootnote
: rDoc
.GetFootnoteIdxs())
1729 const SwFormatFootnote
& rFootnote
= pTextFootnote
->GetFootnote();
1730 if ( rFootnote
.IsEndNote() != m_bEndnote
)
1733 if(nCount
== nIndex
)
1734 return SwXFootnote::CreateXFootnote(rDoc
, &const_cast<SwFormatFootnote
&>(rFootnote
));
1737 throw IndexOutOfBoundsException();
1740 uno::Type SAL_CALL
SwXFootnotes::getElementType()
1742 return cppu::UnoType
<XFootnote
>::get();
1745 sal_Bool
SwXFootnotes::hasElements()
1747 SolarMutexGuard aGuard
;
1748 return !GetDoc().GetFootnoteIdxs().empty();
1751 rtl::Reference
<SwXFootnote
> SwXFootnotes::GetObject( SwDoc
& rDoc
, const SwFormatFootnote
& rFormat
)
1753 return SwXFootnote::CreateXFootnote(rDoc
, &const_cast<SwFormatFootnote
&>(rFormat
));
1756 OUString
SwXReferenceMarks::getImplementationName()
1758 return u
"SwXReferenceMarks"_ustr
;
1761 sal_Bool
SwXReferenceMarks::supportsService(const OUString
& rServiceName
)
1763 return cppu::supportsService(this, rServiceName
);
1766 Sequence
< OUString
> SwXReferenceMarks::getSupportedServiceNames()
1768 return { u
"com.sun.star.text.ReferenceMarks"_ustr
};
1771 SwXReferenceMarks::SwXReferenceMarks(SwDoc
* _pDoc
) :
1772 SwUnoCollection(_pDoc
)
1776 SwXReferenceMarks::~SwXReferenceMarks()
1780 sal_Int32
SwXReferenceMarks::getCount()
1782 SolarMutexGuard aGuard
;
1783 return GetDoc().GetRefMarks();
1786 uno::Any
SwXReferenceMarks::getByIndex(sal_Int32 nIndex
)
1788 if(0 <= nIndex
&& nIndex
< SAL_MAX_UINT16
)
1790 SolarMutexGuard aGuard
;
1791 auto& rDoc
= GetDoc();
1792 if (auto* const pMark
= const_cast<SwFormatRefMark
*>(rDoc
.GetRefMark(nIndex
)))
1794 uno::Reference
<XTextContent
>(SwXReferenceMark::CreateXReferenceMark(rDoc
, pMark
)));
1796 throw IndexOutOfBoundsException();
1799 uno::Any
SwXReferenceMarks::getByName(const OUString
& rName
)
1801 SolarMutexGuard aGuard
;
1802 auto& rDoc
= GetDoc();
1803 if (auto* const pMark
= const_cast<SwFormatRefMark
*>(rDoc
.GetRefMark(rName
)))
1805 uno::Reference
<XTextContent
>(SwXReferenceMark::CreateXReferenceMark(rDoc
, pMark
)));
1807 throw NoSuchElementException();
1810 uno::Sequence
< OUString
> SwXReferenceMarks::getElementNames()
1812 SolarMutexGuard aGuard
;
1814 std::vector
<OUString
> aStrings
;
1815 GetDoc().GetRefMarks(&aStrings
);
1817 return comphelper::containerToSequence(aStrings
);
1820 sal_Bool
SwXReferenceMarks::hasByName(const OUString
& rName
)
1822 SolarMutexGuard aGuard
;
1823 return nullptr != GetDoc().GetRefMark( rName
);
1826 uno::Type SAL_CALL
SwXReferenceMarks::getElementType()
1828 return cppu::UnoType
<XTextContent
>::get();
1831 sal_Bool
SwXReferenceMarks::hasElements()
1833 SolarMutexGuard aGuard
;
1834 return 0 != GetDoc().GetRefMarks();
1837 SwDoc
& SwUnoCollection::GetDoc() const
1839 DBG_TESTSOLARMUTEX();
1841 throw uno::RuntimeException();
1845 void SwUnoCollection::Invalidate()
1847 SolarMutexGuard aGuard
;
1851 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */