1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <swtypes.hxx> 32 #include <cmdid.h> 33 #include <hintids.hxx> 34 #include <svx/svxids.hrc> 35 #include <doc.hxx> 36 #include <docary.hxx> 37 #include <fmtcol.hxx> 38 #include <poolfmt.hxx> 39 #include <unocoll.hxx> 40 #include <unosett.hxx> 41 #include <fmtanchr.hxx> 42 #include <ndtxt.hxx> 43 #include <section.hxx> 44 #include <IMark.hxx> 45 #include <ftnidx.hxx> 46 #include <fmtftn.hxx> 47 #include <txtftn.hxx> 48 #include <fmtpdsc.hxx> 49 #include <pagedesc.hxx> 50 #include <vos/mutex.hxx> 51 #include <com/sun/star/text/XTextTableCursor.hpp> 52 #include <com/sun/star/text/XTextTablesSupplier.hpp> 53 #include <com/sun/star/text/TableColumnSeparator.hpp> 54 #include <com/sun/star/text/XTextTable.hpp> 55 #include <svl/PasswordHelper.hxx> 56 #include <svtools/unoimap.hxx> 57 #include <svtools/unoevent.hxx> 58 #include <unotbl.hxx> 59 #include <unostyle.hxx> 60 #include <unofield.hxx> 61 #include <unoidx.hxx> 62 #include <unoframe.hxx> 63 #include <unofootnote.hxx> 64 #include <vcl/svapp.hxx> 65 #include <fmtcntnt.hxx> 66 #include <authfld.hxx> 67 #include <SwXTextDefaults.hxx> 68 #include <unochart.hxx> 69 #include <comphelper/makesequence.hxx> 70 #include <comphelper/sequence.hxx> 71 #include <slist> 72 #include <iterator> 73 #include <unosection.hxx> 74 #include <unoparagraph.hxx> 75 #include <unobookmark.hxx> 76 #include <unorefmark.hxx> 77 #include <unometa.hxx> 78 #include "docsh.hxx" 79 #include <switerator.hxx> 80 81 using ::rtl::OUString; 82 using namespace ::com::sun::star; 83 using namespace ::com::sun::star::document; 84 using namespace ::com::sun::star::uno; 85 using namespace ::com::sun::star::text; 86 using namespace ::com::sun::star::container; 87 using namespace ::com::sun::star::lang; 88 89 /****************************************************************************** 90 * 91 ******************************************************************************/ 92 struct ProvNamesId_Type 93 { 94 const char * pName; 95 sal_uInt16 nType; 96 }; 97 98 // note: this thing is indexed as an array, so do not insert/remove entries! 99 const ProvNamesId_Type __FAR_DATA aProvNamesId[] = 100 { 101 { "com.sun.star.text.TextTable", SW_SERVICE_TYPE_TEXTTABLE }, 102 { "com.sun.star.text.TextFrame", SW_SERVICE_TYPE_TEXTFRAME }, 103 { "com.sun.star.text.GraphicObject", SW_SERVICE_TYPE_GRAPHIC }, 104 { "com.sun.star.text.TextEmbeddedObject", SW_SERVICE_TYPE_OLE }, 105 { "com.sun.star.text.Bookmark", SW_SERVICE_TYPE_BOOKMARK }, 106 { "com.sun.star.text.Footnote", SW_SERVICE_TYPE_FOOTNOTE }, 107 { "com.sun.star.text.Endnote", SW_SERVICE_TYPE_ENDNOTE }, 108 { "com.sun.star.text.DocumentIndexMark", SW_SERVICE_TYPE_INDEXMARK }, 109 { "com.sun.star.text.DocumentIndex", SW_SERVICE_TYPE_INDEX }, 110 { "com.sun.star.text.ReferenceMark", SW_SERVICE_REFERENCE_MARK }, 111 { "com.sun.star.style.CharacterStyle", SW_SERVICE_STYLE_CHARACTER_STYLE }, 112 { "com.sun.star.style.ParagraphStyle", SW_SERVICE_STYLE_PARAGRAPH_STYLE }, 113 { "com.sun.star.style.FrameStyle", SW_SERVICE_STYLE_FRAME_STYLE }, 114 { "com.sun.star.style.PageStyle", SW_SERVICE_STYLE_PAGE_STYLE }, 115 { "com.sun.star.style.NumberingStyle", SW_SERVICE_STYLE_NUMBERING_STYLE }, 116 { "com.sun.star.text.ContentIndexMark", SW_SERVICE_CONTENT_INDEX_MARK }, 117 { "com.sun.star.text.ContentIndex", SW_SERVICE_CONTENT_INDEX }, 118 { "com.sun.star.text.UserIndexMark", SW_SERVICE_USER_INDEX_MARK }, 119 { "com.sun.star.text.UserIndex", SW_SERVICE_USER_INDEX }, 120 { "com.sun.star.text.TextSection", SW_SERVICE_TEXT_SECTION }, 121 { "com.sun.star.text.TextField.DateTime", SW_SERVICE_FIELDTYPE_DATETIME }, 122 { "com.sun.star.text.TextField.User", SW_SERVICE_FIELDTYPE_USER }, 123 { "com.sun.star.text.TextField.SetExpression", SW_SERVICE_FIELDTYPE_SET_EXP }, 124 { "com.sun.star.text.TextField.GetExpression", SW_SERVICE_FIELDTYPE_GET_EXP }, 125 { "com.sun.star.text.TextField.FileName", SW_SERVICE_FIELDTYPE_FILE_NAME }, 126 { "com.sun.star.text.TextField.PageNumber", SW_SERVICE_FIELDTYPE_PAGE_NUM }, 127 { "com.sun.star.text.TextField.Author", SW_SERVICE_FIELDTYPE_AUTHOR }, 128 { "com.sun.star.text.TextField.Chapter", SW_SERVICE_FIELDTYPE_CHAPTER }, 129 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 }, 130 { "com.sun.star.text.TextField.GetReference", SW_SERVICE_FIELDTYPE_GET_REFERENCE }, 131 { "com.sun.star.text.TextField.ConditionalText", SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT }, 132 { "com.sun.star.text.TextField.Annotation", SW_SERVICE_FIELDTYPE_ANNOTATION }, 133 { "com.sun.star.text.TextField.Input", SW_SERVICE_FIELDTYPE_INPUT }, 134 { "com.sun.star.text.TextField.Macro", SW_SERVICE_FIELDTYPE_MACRO }, 135 { "com.sun.star.text.TextField.DDE", SW_SERVICE_FIELDTYPE_DDE }, 136 { "com.sun.star.text.TextField.HiddenParagraph", SW_SERVICE_FIELDTYPE_HIDDEN_PARA }, 137 { "" /*com.sun.star.text.TextField.DocumentInfo"*/, SW_SERVICE_FIELDTYPE_DOC_INFO }, 138 { "com.sun.star.text.TextField.TemplateName", SW_SERVICE_FIELDTYPE_TEMPLATE_NAME }, 139 { "com.sun.star.text.TextField.ExtendedUser", SW_SERVICE_FIELDTYPE_USER_EXT }, 140 { "com.sun.star.text.TextField.ReferencePageSet", SW_SERVICE_FIELDTYPE_REF_PAGE_SET }, 141 { "com.sun.star.text.TextField.ReferencePageGet", SW_SERVICE_FIELDTYPE_REF_PAGE_GET }, 142 { "com.sun.star.text.TextField.JumpEdit", SW_SERVICE_FIELDTYPE_JUMP_EDIT }, 143 { "com.sun.star.text.TextField.Script", SW_SERVICE_FIELDTYPE_SCRIPT }, 144 { "com.sun.star.text.TextField.DatabaseNextSet", SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET }, 145 { "com.sun.star.text.TextField.DatabaseNumberOfSet", SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET }, 146 { "com.sun.star.text.TextField.DatabaseSetNumber", SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM }, 147 { "com.sun.star.text.TextField.Database", SW_SERVICE_FIELDTYPE_DATABASE }, 148 { "com.sun.star.text.TextField.DatabaseName", SW_SERVICE_FIELDTYPE_DATABASE_NAME }, 149 { "com.sun.star.text.TextField.TableFormula", SW_SERVICE_FIELDTYPE_TABLE_FORMULA }, 150 { "com.sun.star.text.TextField.PageCount", SW_SERVICE_FIELDTYPE_PAGE_COUNT }, 151 { "com.sun.star.text.TextField.ParagraphCount", SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT }, 152 { "com.sun.star.text.TextField.WordCount", SW_SERVICE_FIELDTYPE_WORD_COUNT }, 153 { "com.sun.star.text.TextField.CharacterCount", SW_SERVICE_FIELDTYPE_CHARACTER_COUNT }, 154 { "com.sun.star.text.TextField.TableCount", SW_SERVICE_FIELDTYPE_TABLE_COUNT }, 155 { "com.sun.star.text.TextField.GraphicObjectCount", SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT }, 156 { "com.sun.star.text.TextField.EmbeddedObjectCount", SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT }, 157 { "com.sun.star.text.TextField.DocInfo.ChangeAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR }, 158 { "com.sun.star.text.TextField.DocInfo.ChangeDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME }, 159 { "com.sun.star.text.TextField.DocInfo.EditTime", SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME }, 160 { "com.sun.star.text.TextField.DocInfo.Description", SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION }, 161 { "com.sun.star.text.TextField.DocInfo.CreateAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR }, 162 { "com.sun.star.text.TextField.DocInfo.CreateDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME }, 163 { "", SW_SERVICE_FIELDTYPE_DUMMY_0 }, 164 { "", SW_SERVICE_FIELDTYPE_DUMMY_1 }, 165 { "", SW_SERVICE_FIELDTYPE_DUMMY_2 }, 166 { "", SW_SERVICE_FIELDTYPE_DUMMY_3 }, 167 { "com.sun.star.text.TextField.DocInfo.Custom", SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM }, 168 { "com.sun.star.text.TextField.DocInfo.PrintAuthor", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR }, 169 { "com.sun.star.text.TextField.DocInfo.PrintDateTime", SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME }, 170 { "com.sun.star.text.TextField.DocInfo.KeyWords", SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS }, 171 { "com.sun.star.text.TextField.DocInfo.Subject", SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT }, 172 { "com.sun.star.text.TextField.DocInfo.Title", SW_SERVICE_FIELDTYPE_DOCINFO_TITLE }, 173 { "com.sun.star.text.TextField.DocInfo.Revision", SW_SERVICE_FIELDTYPE_DOCINFO_REVISION }, 174 { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY }, 175 { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS }, 176 { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN }, 177 { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD }, 178 { "", SW_SERVICE_FIELDTYPE_DUMMY_4 }, 179 { "", SW_SERVICE_FIELDTYPE_DUMMY_5 }, 180 { "", SW_SERVICE_FIELDTYPE_DUMMY_6 }, 181 { "", SW_SERVICE_FIELDTYPE_DUMMY_7 }, 182 { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER }, 183 { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE }, 184 { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP }, 185 { "com.sun.star.text.FieldMaster.Database", SW_SERVICE_FIELDMASTER_DATABASE }, 186 { "com.sun.star.text.FieldMaster.Bibliography", SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY }, 187 { "", SW_SERVICE_FIELDMASTER_DUMMY2 }, 188 { "", SW_SERVICE_FIELDMASTER_DUMMY3 }, 189 { "", SW_SERVICE_FIELDMASTER_DUMMY4 }, 190 { "", SW_SERVICE_FIELDMASTER_DUMMY5 }, 191 { "com.sun.star.text.IllustrationsIndex", SW_SERVICE_INDEX_ILLUSTRATIONS }, 192 { "com.sun.star.text.ObjectIndex", SW_SERVICE_INDEX_OBJECTS }, 193 { "com.sun.star.text.TableIndex", SW_SERVICE_INDEX_TABLES }, 194 { "com.sun.star.text.Bibliography", SW_SERVICE_INDEX_BIBLIOGRAPHY }, 195 { "com.sun.star.text.Paragraph", SW_SERVICE_PARAGRAPH }, 196 { "com.sun.star.text.TextField.InputUser", SW_SERVICE_FIELDTYPE_INPUT_USER }, 197 { "com.sun.star.text.TextField.HiddenText", SW_SERVICE_FIELDTYPE_HIDDEN_TEXT }, 198 { "com.sun.star.style.ConditionalParagraphStyle", SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE }, 199 { "com.sun.star.text.NumberingRules", SW_SERVICE_NUMBERING_RULES }, 200 { "com.sun.star.text.TextColumns", SW_SERVICE_TEXT_COLUMNS }, 201 { "com.sun.star.text.IndexHeaderSection", SW_SERVICE_INDEX_HEADER_SECTION }, 202 { "com.sun.star.text.Defaults", SW_SERVICE_DEFAULTS }, 203 { "com.sun.star.image.ImageMapRectangleObject", SW_SERVICE_IMAP_RECTANGLE }, 204 { "com.sun.star.image.ImageMapCircleObject", SW_SERVICE_IMAP_CIRCLE }, 205 { "com.sun.star.image.ImageMapPolygonObject", SW_SERVICE_IMAP_POLYGON }, 206 { "com.sun.star.text.TextGraphicObject", SW_SERVICE_TYPE_TEXT_GRAPHIC }, 207 { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER }, 208 { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK }, 209 { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK }, 210 { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META }, 211 212 // case-correct versions of the service names (see #i67811) 213 { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME }, 214 { CSS_TEXT_TEXTFIELD_USER, SW_SERVICE_FIELDTYPE_USER }, 215 { CSS_TEXT_TEXTFIELD_SET_EXPRESSION, SW_SERVICE_FIELDTYPE_SET_EXP }, 216 { CSS_TEXT_TEXTFIELD_GET_EXPRESSION, SW_SERVICE_FIELDTYPE_GET_EXP }, 217 { CSS_TEXT_TEXTFIELD_FILE_NAME, SW_SERVICE_FIELDTYPE_FILE_NAME }, 218 { CSS_TEXT_TEXTFIELD_PAGE_NUMBER, SW_SERVICE_FIELDTYPE_PAGE_NUM }, 219 { CSS_TEXT_TEXTFIELD_AUTHOR, SW_SERVICE_FIELDTYPE_AUTHOR }, 220 { CSS_TEXT_TEXTFIELD_CHAPTER, SW_SERVICE_FIELDTYPE_CHAPTER }, 221 { CSS_TEXT_TEXTFIELD_GET_REFERENCE, SW_SERVICE_FIELDTYPE_GET_REFERENCE }, 222 { CSS_TEXT_TEXTFIELD_CONDITIONAL_TEXT, SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT }, 223 { CSS_TEXT_TEXTFIELD_ANNOTATION, SW_SERVICE_FIELDTYPE_ANNOTATION }, 224 { CSS_TEXT_TEXTFIELD_INPUT, SW_SERVICE_FIELDTYPE_INPUT }, 225 { CSS_TEXT_TEXTFIELD_MACRO, SW_SERVICE_FIELDTYPE_MACRO }, 226 { CSS_TEXT_TEXTFIELD_DDE, SW_SERVICE_FIELDTYPE_DDE }, 227 { CSS_TEXT_TEXTFIELD_HIDDEN_PARAGRAPH, SW_SERVICE_FIELDTYPE_HIDDEN_PARA }, 228 { CSS_TEXT_TEXTFIELD_TEMPLATE_NAME, SW_SERVICE_FIELDTYPE_TEMPLATE_NAME }, 229 { CSS_TEXT_TEXTFIELD_EXTENDED_USER, SW_SERVICE_FIELDTYPE_USER_EXT }, 230 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_SET, SW_SERVICE_FIELDTYPE_REF_PAGE_SET }, 231 { CSS_TEXT_TEXTFIELD_REFERENCE_PAGE_GET, SW_SERVICE_FIELDTYPE_REF_PAGE_GET }, 232 { CSS_TEXT_TEXTFIELD_JUMP_EDIT, SW_SERVICE_FIELDTYPE_JUMP_EDIT }, 233 { CSS_TEXT_TEXTFIELD_SCRIPT, SW_SERVICE_FIELDTYPE_SCRIPT }, 234 { CSS_TEXT_TEXTFIELD_DATABASE_NEXT_SET, SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET }, 235 { CSS_TEXT_TEXTFIELD_DATABASE_NUMBER_OF_SET, SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET }, 236 { CSS_TEXT_TEXTFIELD_DATABASE_SET_NUMBER, SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM }, 237 { CSS_TEXT_TEXTFIELD_DATABASE, SW_SERVICE_FIELDTYPE_DATABASE }, 238 { CSS_TEXT_TEXTFIELD_DATABASE_NAME, SW_SERVICE_FIELDTYPE_DATABASE_NAME }, 239 { CSS_TEXT_TEXTFIELD_TABLE_FORMULA, SW_SERVICE_FIELDTYPE_TABLE_FORMULA }, 240 { CSS_TEXT_TEXTFIELD_PAGE_COUNT, SW_SERVICE_FIELDTYPE_PAGE_COUNT }, 241 { CSS_TEXT_TEXTFIELD_PARAGRAPH_COUNT, SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT }, 242 { CSS_TEXT_TEXTFIELD_WORD_COUNT, SW_SERVICE_FIELDTYPE_WORD_COUNT }, 243 { CSS_TEXT_TEXTFIELD_CHARACTER_COUNT, SW_SERVICE_FIELDTYPE_CHARACTER_COUNT }, 244 { CSS_TEXT_TEXTFIELD_TABLE_COUNT, SW_SERVICE_FIELDTYPE_TABLE_COUNT }, 245 { CSS_TEXT_TEXTFIELD_GRAPHIC_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT }, 246 { CSS_TEXT_TEXTFIELD_EMBEDDED_OBJECT_COUNT, SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT }, 247 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR }, 248 { CSS_TEXT_TEXTFIELD_DOCINFO_CHANGE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME }, 249 { CSS_TEXT_TEXTFIELD_DOCINFO_EDIT_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME }, 250 { CSS_TEXT_TEXTFIELD_DOCINFO_DESCRIPTION, SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION }, 251 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR }, 252 { CSS_TEXT_TEXTFIELD_DOCINFO_CREATE_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME }, 253 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_AUTHOR, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR }, 254 { CSS_TEXT_TEXTFIELD_DOCINFO_PRINT_DATE_TIME, SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME }, 255 { CSS_TEXT_TEXTFIELD_DOCINFO_KEY_WORDS, SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS }, 256 { CSS_TEXT_TEXTFIELD_DOCINFO_SUBJECT, SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT }, 257 { CSS_TEXT_TEXTFIELD_DOCINFO_TITLE, SW_SERVICE_FIELDTYPE_DOCINFO_TITLE }, 258 { CSS_TEXT_TEXTFIELD_DOCINFO_REVISION, SW_SERVICE_FIELDTYPE_DOCINFO_REVISION }, 259 { CSS_TEXT_TEXTFIELD_DOCINFO_CUSTOM, SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM }, 260 { CSS_TEXT_TEXTFIELD_BIBLIOGRAPHY, SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY }, 261 { CSS_TEXT_TEXTFIELD_COMBINED_CHARACTERS, SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS }, 262 { CSS_TEXT_TEXTFIELD_DROP_DOWN, SW_SERVICE_FIELDTYPE_DROPDOWN }, 263 { CSS_TEXT_TEXTFIELD_INPUT_USER, SW_SERVICE_FIELDTYPE_INPUT_USER }, 264 { CSS_TEXT_TEXTFIELD_HIDDEN_TEXT, SW_SERVICE_FIELDTYPE_HIDDEN_TEXT }, 265 { CSS_TEXT_FIELDMASTER_USER, SW_SERVICE_FIELDMASTER_USER }, 266 { CSS_TEXT_FIELDMASTER_DDE, SW_SERVICE_FIELDMASTER_DDE }, 267 { CSS_TEXT_FIELDMASTER_SET_EXPRESSION, SW_SERVICE_FIELDMASTER_SET_EXP }, 268 { CSS_TEXT_FIELDMASTER_DATABASE, SW_SERVICE_FIELDMASTER_DATABASE }, 269 { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY, SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY } 270 }; 271 272 const SvEventDescription* lcl_GetSupportedMacroItems() 273 { 274 static const SvEventDescription aMacroDescriptionsImpl[] = 275 { 276 { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" }, 277 { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" }, 278 { 0, NULL } 279 }; 280 281 return aMacroDescriptionsImpl; 282 } 283 284 /****************************************************************** 285 * SwXServiceProvider 286 ******************************************************************/ 287 OUString SwXServiceProvider::GetProviderName(sal_uInt16 nObjectType) 288 { 289 vos::OGuard aGuard(Application::GetSolarMutex()); 290 OUString sRet; 291 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); 292 if(nObjectType < nEntries) 293 sRet = C2U(aProvNamesId[nObjectType].pName); 294 return sRet; 295 } 296 297 uno::Sequence<OUString> SwXServiceProvider::GetAllServiceNames() 298 { 299 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); 300 uno::Sequence<OUString> aRet(nEntries); 301 OUString* pArray = aRet.getArray(); 302 sal_uInt16 n = 0; 303 for(sal_uInt16 i = 0; i < nEntries; i++) 304 { 305 String sProv(C2U(aProvNamesId[i].pName)); 306 if(sProv.Len()) 307 { 308 pArray[n] = sProv; 309 n++; 310 } 311 } 312 aRet.realloc(n); 313 return aRet; 314 315 } 316 317 sal_uInt16 SwXServiceProvider::GetProviderType(const OUString& rServiceName) 318 { 319 sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]); 320 for(sal_uInt16 i = 0; i < nEntries; i++ ) 321 { 322 if( COMPARE_EQUAL == rServiceName.compareToAscii(aProvNamesId[i].pName)) 323 return aProvNamesId[i].nType; 324 } 325 return SW_SERVICE_INVALID; 326 } 327 328 uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc* pDoc) 329 { 330 vos::OGuard aGuard(Application::GetSolarMutex()); 331 uno::Reference< uno::XInterface > xRet; 332 switch(nObjectType) 333 { 334 case SW_SERVICE_TYPE_TEXTTABLE: 335 { 336 SwXTextTable* pTextTable = new SwXTextTable(); 337 xRet = (cppu::OWeakObject*)pTextTable; 338 } 339 break; 340 case SW_SERVICE_TYPE_TEXTFRAME: 341 { 342 SwXTextFrame* pTextFrame = new SwXTextFrame( pDoc ); 343 xRet = (cppu::OWeakObject*)(SwXFrame*)pTextFrame; 344 } 345 break; 346 case SW_SERVICE_TYPE_GRAPHIC : 347 case SW_SERVICE_TYPE_TEXT_GRAPHIC /* #i47503# */ : 348 { 349 SwXTextGraphicObject* pGraphic = new SwXTextGraphicObject( pDoc ); 350 xRet = (cppu::OWeakObject*)(SwXFrame*)pGraphic; 351 352 } 353 break; 354 case SW_SERVICE_TYPE_OLE : 355 { 356 SwXTextEmbeddedObject* pOle = new SwXTextEmbeddedObject( pDoc ); 357 xRet = (cppu::OWeakObject*)(SwXFrame*)pOle; 358 } 359 break; 360 case SW_SERVICE_TYPE_BOOKMARK : 361 { 362 SwXBookmark* pBookmark = new SwXBookmark; 363 xRet = (cppu::OWeakObject*)pBookmark; 364 } 365 break; 366 case SW_SERVICE_TYPE_FIELDMARK : 367 { 368 SwXFieldmark* pFieldmark = new SwXFieldmark(false); 369 xRet = (cppu::OWeakObject*)pFieldmark; 370 } 371 break; 372 case SW_SERVICE_TYPE_FORMFIELDMARK : 373 { 374 SwXFieldmark* pFieldmark = new SwXFieldmark(true); 375 xRet = (cppu::OWeakObject*)pFieldmark; 376 } 377 break; 378 case SW_SERVICE_TYPE_FOOTNOTE : 379 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_False); 380 break; 381 case SW_SERVICE_TYPE_ENDNOTE : 382 xRet = (cppu::OWeakObject*)new SwXFootnote(sal_True); 383 break; 384 case SW_SERVICE_CONTENT_INDEX_MARK : 385 case SW_SERVICE_USER_INDEX_MARK : 386 case SW_SERVICE_TYPE_INDEXMARK: 387 { 388 TOXTypes eType = TOX_INDEX; 389 if(SW_SERVICE_CONTENT_INDEX_MARK== nObjectType) 390 eType = TOX_CONTENT; 391 else if(SW_SERVICE_USER_INDEX_MARK == nObjectType) 392 eType = TOX_USER; 393 xRet = (cppu::OWeakObject*)new SwXDocumentIndexMark(eType); 394 } 395 break; 396 case SW_SERVICE_CONTENT_INDEX : 397 case SW_SERVICE_USER_INDEX : 398 case SW_SERVICE_TYPE_INDEX : 399 case SW_SERVICE_INDEX_ILLUSTRATIONS: 400 case SW_SERVICE_INDEX_OBJECTS : 401 case SW_SERVICE_INDEX_TABLES: 402 case SW_SERVICE_INDEX_BIBLIOGRAPHY : 403 { 404 TOXTypes eType = TOX_INDEX; 405 if(SW_SERVICE_CONTENT_INDEX == nObjectType) 406 eType = TOX_CONTENT; 407 else if(SW_SERVICE_USER_INDEX == nObjectType) 408 eType = TOX_USER; 409 else if(SW_SERVICE_INDEX_ILLUSTRATIONS == nObjectType) 410 { 411 eType = TOX_ILLUSTRATIONS; 412 } 413 else if(SW_SERVICE_INDEX_OBJECTS == nObjectType) 414 { 415 eType = TOX_OBJECTS; 416 } 417 else if(SW_SERVICE_INDEX_BIBLIOGRAPHY == nObjectType) 418 { 419 eType = TOX_AUTHORITIES; 420 } 421 else if(SW_SERVICE_INDEX_TABLES == nObjectType) 422 { 423 eType = TOX_TABLES; 424 } 425 xRet = (cppu::OWeakObject*)new SwXDocumentIndex(eType, *pDoc); 426 } 427 break; 428 case SW_SERVICE_INDEX_HEADER_SECTION : 429 case SW_SERVICE_TEXT_SECTION : 430 xRet = SwXTextSection::CreateXTextSection(0, 431 (SW_SERVICE_INDEX_HEADER_SECTION == nObjectType)); 432 433 break; 434 case SW_SERVICE_REFERENCE_MARK : 435 xRet = (cppu::OWeakObject*)new SwXReferenceMark(0, 0); 436 break; 437 case SW_SERVICE_STYLE_CHARACTER_STYLE: 438 case SW_SERVICE_STYLE_PARAGRAPH_STYLE: 439 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE: 440 case SW_SERVICE_STYLE_FRAME_STYLE: 441 case SW_SERVICE_STYLE_PAGE_STYLE: 442 case SW_SERVICE_STYLE_NUMBERING_STYLE: 443 { 444 SfxStyleFamily eFamily = SFX_STYLE_FAMILY_CHAR; 445 switch(nObjectType) 446 { 447 case SW_SERVICE_STYLE_PARAGRAPH_STYLE: 448 case SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE: 449 eFamily = SFX_STYLE_FAMILY_PARA; 450 break; 451 case SW_SERVICE_STYLE_FRAME_STYLE: 452 eFamily = SFX_STYLE_FAMILY_FRAME; 453 break; 454 case SW_SERVICE_STYLE_PAGE_STYLE: 455 eFamily = SFX_STYLE_FAMILY_PAGE; 456 break; 457 case SW_SERVICE_STYLE_NUMBERING_STYLE: 458 eFamily = SFX_STYLE_FAMILY_PSEUDO; 459 break; 460 } 461 SwXStyle* pNewStyle = SFX_STYLE_FAMILY_PAGE == eFamily ? 462 new SwXPageStyle(pDoc->GetDocShell()) : 463 eFamily == SFX_STYLE_FAMILY_FRAME ? 464 new SwXFrameStyle ( pDoc ): 465 new SwXStyle( pDoc, eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE); 466 xRet = (cppu::OWeakObject*)pNewStyle; 467 } 468 break; 469 // SW_SERVICE_DUMMY_5 470 // SW_SERVICE_DUMMY_6 471 // SW_SERVICE_DUMMY_7 472 // SW_SERVICE_DUMMY_8 473 // SW_SERVICE_DUMMY_9 474 case SW_SERVICE_FIELDTYPE_DATETIME: 475 case SW_SERVICE_FIELDTYPE_USER: 476 case SW_SERVICE_FIELDTYPE_SET_EXP: 477 case SW_SERVICE_FIELDTYPE_GET_EXP: 478 case SW_SERVICE_FIELDTYPE_FILE_NAME: 479 case SW_SERVICE_FIELDTYPE_PAGE_NUM: 480 case SW_SERVICE_FIELDTYPE_AUTHOR: 481 case SW_SERVICE_FIELDTYPE_CHAPTER: 482 case SW_SERVICE_FIELDTYPE_GET_REFERENCE: 483 case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT: 484 case SW_SERVICE_FIELDTYPE_INPUT: 485 case SW_SERVICE_FIELDTYPE_MACRO: 486 case SW_SERVICE_FIELDTYPE_DDE: 487 case SW_SERVICE_FIELDTYPE_HIDDEN_PARA: 488 case SW_SERVICE_FIELDTYPE_DOC_INFO: 489 case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME: 490 case SW_SERVICE_FIELDTYPE_USER_EXT: 491 case SW_SERVICE_FIELDTYPE_REF_PAGE_SET: 492 case SW_SERVICE_FIELDTYPE_REF_PAGE_GET: 493 case SW_SERVICE_FIELDTYPE_JUMP_EDIT: 494 case SW_SERVICE_FIELDTYPE_SCRIPT: 495 case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET: 496 case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET: 497 case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM: 498 case SW_SERVICE_FIELDTYPE_DATABASE: 499 case SW_SERVICE_FIELDTYPE_DATABASE_NAME: 500 case SW_SERVICE_FIELDTYPE_PAGE_COUNT : 501 case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT : 502 case SW_SERVICE_FIELDTYPE_WORD_COUNT : 503 case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT : 504 case SW_SERVICE_FIELDTYPE_TABLE_COUNT : 505 case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT : 506 case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT : 507 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR : 508 case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME : 509 case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME : 510 case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION : 511 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR : 512 case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME : 513 case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM : 514 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR : 515 case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME : 516 case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS : 517 case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT : 518 case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE : 519 case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION : 520 case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY: 521 case SW_SERVICE_FIELDTYPE_INPUT_USER : 522 case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT : 523 case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS : 524 case SW_SERVICE_FIELDTYPE_DROPDOWN : 525 case SW_SERVICE_FIELDTYPE_TABLE_FORMULA: 526 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType); 527 break; 528 case SW_SERVICE_FIELDTYPE_ANNOTATION: 529 xRet = (cppu::OWeakObject*)new SwXTextField(nObjectType, pDoc); 530 break; 531 case SW_SERVICE_FIELDMASTER_USER: 532 case SW_SERVICE_FIELDMASTER_DDE: 533 case SW_SERVICE_FIELDMASTER_SET_EXP : 534 case SW_SERVICE_FIELDMASTER_DATABASE: 535 { 536 sal_uInt16 nResId = USHRT_MAX; 537 switch(nObjectType) 538 { 539 case SW_SERVICE_FIELDMASTER_USER: nResId = RES_USERFLD; break; 540 case SW_SERVICE_FIELDMASTER_DDE: nResId = RES_DDEFLD; break; 541 case SW_SERVICE_FIELDMASTER_SET_EXP : nResId = RES_SETEXPFLD; break; 542 case SW_SERVICE_FIELDMASTER_DATABASE: nResId = RES_DBFLD; break; 543 } 544 xRet = (cppu::OWeakObject*)new SwXFieldMaster(pDoc, nResId); 545 } 546 break; 547 case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY: 548 { 549 SwFieldType* pType = pDoc->GetFldType(RES_AUTHORITY, aEmptyStr, sal_True); 550 if(!pType) 551 { 552 SwAuthorityFieldType aType(pDoc); 553 pType = pDoc->InsertFldType(aType); 554 } 555 else 556 { 557 SwXFieldMaster* pMaster = SwIterator<SwXFieldMaster,SwFieldType>::FirstElement( *pType ); 558 if(pMaster) 559 xRet = (cppu::OWeakObject*)pMaster; 560 } 561 if(!xRet.is()) 562 xRet = (cppu::OWeakObject*)new SwXFieldMaster(*pType, pDoc); 563 } 564 break; 565 case SW_SERVICE_PARAGRAPH : 566 xRet = (cppu::OWeakObject*)new SwXParagraph(); 567 break; 568 case SW_SERVICE_NUMBERING_RULES : 569 xRet = (cppu::OWeakObject*)new SwXNumberingRules(*pDoc); 570 break; 571 case SW_SERVICE_TEXT_COLUMNS : 572 xRet = (cppu::OWeakObject*)new SwXTextColumns(0); 573 break; 574 case SW_SERVICE_DEFAULTS: 575 xRet = (cppu::OWeakObject*)new SwXTextDefaults( pDoc ); 576 break; 577 case SW_SERVICE_IMAP_RECTANGLE : 578 xRet = SvUnoImageMapRectangleObject_createInstance( lcl_GetSupportedMacroItems() ); 579 break; 580 case SW_SERVICE_IMAP_CIRCLE : 581 xRet = SvUnoImageMapCircleObject_createInstance( lcl_GetSupportedMacroItems() ); 582 break; 583 case SW_SERVICE_IMAP_POLYGON : 584 xRet = SvUnoImageMapPolygonObject_createInstance( lcl_GetSupportedMacroItems() ); 585 break; 586 case SW_SERVICE_CHART2_DATA_PROVIDER : 587 // #i64497# If a chart is in a temporary document during clipoard 588 // paste, there should be no data provider, so that own data is used 589 // This should not happen during copy/paste, as this will unlink 590 // charts using table data. 591 OSL_ASSERT( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ); 592 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) 593 xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ ); 594 break; 595 case SW_SERVICE_TYPE_META: 596 xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) ); 597 break; 598 case SW_SERVICE_FIELDTYPE_METAFIELD: 599 xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc)); 600 break; 601 default: 602 throw uno::RuntimeException(); 603 } 604 return xRet; 605 } 606 /****************************************************************** 607 * SwXTextTables 608 ******************************************************************/ 609 //SMART_UNO_IMPLEMENTATION( SwXTextTables, UsrObject ); 610 611 SwXTextTables::SwXTextTables(SwDoc* pDc) : 612 SwUnoCollection(pDc) 613 { 614 615 } 616 617 SwXTextTables::~SwXTextTables() 618 { 619 620 } 621 622 sal_Int32 SwXTextTables::getCount(void) throw( uno::RuntimeException ) 623 { 624 vos::OGuard aGuard(Application::GetSolarMutex()); 625 sal_Int32 nRet = 0; 626 if(IsValid()) 627 nRet = GetDoc()->GetTblFrmFmtCount(sal_True); 628 return nRet; 629 } 630 631 uno::Any SAL_CALL SwXTextTables::getByIndex(sal_Int32 nIndex) 632 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 633 { 634 vos::OGuard aGuard(Application::GetSolarMutex()); 635 uno::Any aRet; 636 if(IsValid()) 637 { 638 if(0 <= nIndex && GetDoc()->GetTblFrmFmtCount(sal_True) > nIndex) 639 { 640 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt( static_cast< xub_StrLen >(nIndex), sal_True); 641 uno::Reference< XTextTable > xTbl = SwXTextTables::GetObject(rFmt); 642 aRet.setValue( &xTbl, 643 ::getCppuType((uno::Reference< XTextTable>*)0)); 644 } 645 else 646 throw IndexOutOfBoundsException(); 647 } 648 else 649 throw uno::RuntimeException(); 650 return aRet; 651 } 652 653 uno::Any SwXTextTables::getByName(const OUString& rItemName) 654 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException ) 655 { 656 vos::OGuard aGuard(Application::GetSolarMutex()); 657 uno::Any aRet; 658 if(IsValid()) 659 { 660 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True); 661 uno::Reference< XTextTable > xTbl; 662 for( sal_uInt16 i = 0; i < nCount; i++) 663 { 664 String aName(rItemName); 665 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True); 666 if(aName == rFmt.GetName()) 667 { 668 xTbl = SwXTextTables::GetObject(rFmt); 669 aRet.setValue(&xTbl, 670 ::getCppuType(( uno::Reference< XTextTable >*)0)); 671 break; 672 } 673 } 674 if(!xTbl.is()) 675 throw NoSuchElementException(); 676 } 677 else 678 throw uno::RuntimeException(); 679 return aRet; 680 } 681 682 uno::Sequence< OUString > SwXTextTables::getElementNames(void) 683 throw( uno::RuntimeException ) 684 { 685 vos::OGuard aGuard(Application::GetSolarMutex()); 686 if(!IsValid()) 687 throw uno::RuntimeException(); 688 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True); 689 uno::Sequence<OUString> aSeq(nCount); 690 if(nCount) 691 { 692 OUString* pArray = aSeq.getArray(); 693 for( sal_uInt16 i = 0; i < nCount; i++) 694 { 695 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True); 696 697 pArray[i] = OUString(rFmt.GetName()); 698 } 699 } 700 return aSeq; 701 } 702 703 sal_Bool SwXTextTables::hasByName(const OUString& rName) 704 throw( uno::RuntimeException ) 705 { 706 vos::OGuard aGuard(Application::GetSolarMutex()); 707 sal_Bool bRet= sal_False; 708 if(IsValid()) 709 { 710 sal_uInt16 nCount = GetDoc()->GetTblFrmFmtCount(sal_True); 711 for( sal_uInt16 i = 0; i < nCount; i++) 712 { 713 String aName(rName); 714 SwFrmFmt& rFmt = GetDoc()->GetTblFrmFmt(i, sal_True); 715 if(aName == rFmt.GetName()) 716 { 717 bRet = sal_True; 718 break; 719 } 720 } 721 } 722 else 723 throw uno::RuntimeException(); 724 return bRet; 725 } 726 727 uno::Type SAL_CALL 728 SwXTextTables::getElementType( ) 729 throw(uno::RuntimeException) 730 { 731 return ::getCppuType((uno::Reference<XTextTable>*)0); 732 } 733 734 sal_Bool SwXTextTables::hasElements(void) throw( uno::RuntimeException ) 735 { 736 vos::OGuard aGuard(Application::GetSolarMutex()); 737 if(!IsValid()) 738 throw uno::RuntimeException(); 739 return 0 != GetDoc()->GetTblFrmFmtCount(sal_True); 740 } 741 742 OUString SwXTextTables::getImplementationName(void) throw( uno::RuntimeException ) 743 { 744 return C2U("SwXTextTables"); 745 } 746 747 sal_Bool SwXTextTables::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 748 { 749 return rServiceName == C2U("com.sun.star.text.TextTables"); 750 } 751 752 uno::Sequence< OUString > SwXTextTables::getSupportedServiceNames(void) throw( uno::RuntimeException ) 753 { 754 uno::Sequence< OUString > aRet(1); 755 OUString* pArr = aRet.getArray(); 756 pArr[0] = C2U("com.sun.star.text.TextTables"); 757 return aRet; 758 } 759 760 XTextTable* SwXTextTables::GetObject( SwFrmFmt& rFmt ) 761 { 762 vos::OGuard aGuard(Application::GetSolarMutex()); 763 SwXTextTable* pTbl = SwIterator<SwXTextTable,SwFmt>::FirstElement( rFmt ); 764 if( !pTbl ) 765 pTbl = new SwXTextTable(rFmt); 766 return pTbl ; 767 } 768 769 770 /****************************************************************** 771 * SwXFrameEnumeration 772 ******************************************************************/ 773 namespace 774 { 775 template<FlyCntType T> struct UnoFrameWrap_traits {}; 776 777 template<> 778 struct UnoFrameWrap_traits<FLYCNTTYPE_FRM> 779 { 780 typedef SwXTextFrame core_frame_t; 781 typedef XTextFrame uno_frame_t; 782 static inline bool filter(const SwNode* const pNode) { return !pNode->IsNoTxtNode(); }; 783 }; 784 785 template<> 786 struct UnoFrameWrap_traits<FLYCNTTYPE_GRF> 787 { 788 typedef SwXTextGraphicObject core_frame_t; 789 typedef XTextContent uno_frame_t; 790 static inline bool filter(const SwNode* const pNode) { return pNode->IsGrfNode(); }; 791 }; 792 793 template<> 794 struct UnoFrameWrap_traits<FLYCNTTYPE_OLE> 795 { 796 typedef SwXTextEmbeddedObject core_frame_t; 797 typedef XEmbeddedObjectSupplier uno_frame_t; 798 static inline bool filter(const SwNode* const pNode) { return pNode->IsOLENode(); }; 799 }; 800 801 template<FlyCntType T> 802 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt) 803 { 804 SwXFrame* pFrm = SwIterator<SwXFrame,SwFmt>::FirstElement( *pFmt ); 805 if(!pFrm) 806 pFrm = new typename UnoFrameWrap_traits<T>::core_frame_t(*pFmt); 807 Reference< typename UnoFrameWrap_traits<T>::uno_frame_t > xFrm = 808 static_cast< typename UnoFrameWrap_traits<T>::core_frame_t* >(pFrm); 809 return uno::makeAny(xFrm); 810 } 811 812 // runtime adapter for lcl_UnoWrapFrame 813 static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt, FlyCntType eType) throw(uno::RuntimeException()) 814 { 815 switch(eType) 816 { 817 case FLYCNTTYPE_FRM: 818 return lcl_UnoWrapFrame<FLYCNTTYPE_FRM>(pFmt); 819 case FLYCNTTYPE_GRF: 820 return lcl_UnoWrapFrame<FLYCNTTYPE_GRF>(pFmt); 821 case FLYCNTTYPE_OLE: 822 return lcl_UnoWrapFrame<FLYCNTTYPE_OLE>(pFmt); 823 default: 824 throw uno::RuntimeException(); 825 } 826 } 827 828 template<FlyCntType T> 829 class SwXFrameEnumeration 830 : public SwSimpleEnumeration_Base 831 { 832 private: 833 typedef ::std::slist< Any > frmcontainer_t; 834 frmcontainer_t m_aFrames; 835 protected: 836 virtual ~SwXFrameEnumeration() {}; 837 public: 838 SwXFrameEnumeration(const SwDoc* const pDoc); 839 840 //XEnumeration 841 virtual sal_Bool SAL_CALL hasMoreElements(void) throw( RuntimeException ); 842 virtual Any SAL_CALL nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException ); 843 844 //XServiceInfo 845 virtual OUString SAL_CALL getImplementationName(void) throw( RuntimeException ); 846 virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException ); 847 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException ); 848 }; 849 } 850 851 template<FlyCntType T> 852 SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) 853 : m_aFrames() 854 { 855 vos::OGuard aGuard(Application::GetSolarMutex()); 856 const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts(); 857 if(!pFmts->Count()) 858 return; 859 // --> OD 2009-09-10 #i104937# 860 // const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()]; 861 const sal_uInt16 nSize = pFmts->Count(); 862 // <-- 863 ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin()); 864 // --> OD 2009-09-10 #i104937# 865 SwFrmFmt* pFmt( 0 ); 866 for( sal_uInt16 i = 0; i < nSize; ++i ) 867 // for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt) 868 // <-- 869 { 870 // --> OD 2009-09-10 #i104937# 871 pFmt = (*pFmts)[i]; 872 // <-- 873 if(pFmt->Which() != RES_FLYFRMFMT) 874 continue; 875 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 876 if(!pIdx || !pIdx->GetNodes().IsDocNodes()) 877 continue; 878 const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ]; 879 if(UnoFrameWrap_traits<T>::filter(pNd)) 880 *pInserter++ = lcl_UnoWrapFrame<T>(pFmt); 881 } 882 } 883 884 template<FlyCntType T> 885 sal_Bool SwXFrameEnumeration<T>::hasMoreElements(void) throw( RuntimeException ) 886 { 887 vos::OGuard aGuard(Application::GetSolarMutex()); 888 return !m_aFrames.empty(); 889 } 890 891 template<FlyCntType T> 892 Any SwXFrameEnumeration<T>::nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException ) 893 { 894 vos::OGuard aGuard(Application::GetSolarMutex()); 895 if(m_aFrames.empty()) 896 throw NoSuchElementException(); 897 Any aResult = *m_aFrames.begin(); 898 m_aFrames.pop_front(); 899 return aResult; 900 } 901 902 template<FlyCntType T> 903 OUString SwXFrameEnumeration<T>::getImplementationName(void) throw( RuntimeException ) 904 { 905 return C2U("SwXFrameEnumeration"); 906 } 907 908 template<FlyCntType T> 909 sal_Bool SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException ) 910 { 911 return C2U("com.sun.star.container.XEnumeration") == ServiceName; 912 } 913 914 template<FlyCntType T> 915 Sequence< OUString > SwXFrameEnumeration<T>::getSupportedServiceNames(void) throw( RuntimeException ) 916 { 917 return ::comphelper::makeSequence(C2U("com.sun.star.container.XEnumeration")); 918 } 919 920 /****************************************************************** 921 * SwXFrames 922 ******************************************************************/ 923 OUString SwXFrames::getImplementationName(void) throw( RuntimeException ) 924 { 925 return C2U("SwXFrames"); 926 } 927 928 sal_Bool SwXFrames::supportsService(const OUString& rServiceName) throw( RuntimeException ) 929 { 930 return C2U("com.sun.star.text.TextFrames") == rServiceName; 931 } 932 933 Sequence<OUString> SwXFrames::getSupportedServiceNames(void) throw( RuntimeException ) 934 { 935 return ::comphelper::makeSequence(C2U("com.sun.star.text.TextFrames")); 936 } 937 938 SwXFrames::SwXFrames(SwDoc* _pDoc, FlyCntType eSet) : 939 SwUnoCollection(_pDoc), 940 eType(eSet) 941 {} 942 943 SwXFrames::~SwXFrames() 944 {} 945 946 uno::Reference<container::XEnumeration> SwXFrames::createEnumeration(void) throw(uno::RuntimeException) 947 { 948 vos::OGuard aGuard(Application::GetSolarMutex()); 949 if(!IsValid()) 950 throw uno::RuntimeException(); 951 switch(eType) 952 { 953 case FLYCNTTYPE_FRM: 954 return uno::Reference< container::XEnumeration >( 955 new SwXFrameEnumeration<FLYCNTTYPE_FRM>(GetDoc())); 956 case FLYCNTTYPE_GRF: 957 return uno::Reference< container::XEnumeration >( 958 new SwXFrameEnumeration<FLYCNTTYPE_GRF>(GetDoc())); 959 case FLYCNTTYPE_OLE: 960 return uno::Reference< container::XEnumeration >( 961 new SwXFrameEnumeration<FLYCNTTYPE_OLE>(GetDoc())); 962 default: 963 throw uno::RuntimeException(); 964 } 965 } 966 967 sal_Int32 SwXFrames::getCount(void) throw(uno::RuntimeException) 968 { 969 vos::OGuard aGuard(Application::GetSolarMutex()); 970 if(!IsValid()) 971 throw uno::RuntimeException(); 972 return GetDoc()->GetFlyCount(eType); 973 } 974 975 uno::Any SwXFrames::getByIndex(sal_Int32 nIndex) 976 throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 977 { 978 vos::OGuard aGuard(Application::GetSolarMutex()); 979 if(!IsValid()) 980 throw uno::RuntimeException(); 981 if(nIndex < 0 || nIndex >= USHRT_MAX) 982 throw IndexOutOfBoundsException(); 983 SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType); 984 if(!pFmt) 985 throw IndexOutOfBoundsException(); 986 return lcl_UnoWrapFrame(pFmt, eType); 987 } 988 989 uno::Any SwXFrames::getByName(const OUString& rName) 990 throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException ) 991 { 992 vos::OGuard aGuard(Application::GetSolarMutex()); 993 if(!IsValid()) 994 throw uno::RuntimeException(); 995 const SwFrmFmt* pFmt; 996 switch(eType) 997 { 998 case FLYCNTTYPE_GRF: 999 pFmt = GetDoc()->FindFlyByName(rName, ND_GRFNODE); 1000 break; 1001 case FLYCNTTYPE_OLE: 1002 pFmt = GetDoc()->FindFlyByName(rName, ND_OLENODE); 1003 break; 1004 default: 1005 pFmt = GetDoc()->FindFlyByName(rName, ND_TEXTNODE); 1006 break; 1007 } 1008 if(!pFmt) 1009 throw NoSuchElementException(); 1010 return lcl_UnoWrapFrame(const_cast<SwFrmFmt*>(pFmt), eType); 1011 } 1012 1013 uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeException ) 1014 { 1015 vos::OGuard aGuard(Application::GetSolarMutex()); 1016 if(!IsValid()) 1017 throw uno::RuntimeException(); 1018 const Reference<XEnumeration> xEnum = createEnumeration(); 1019 ::std::vector<OUString> vNames; 1020 while(xEnum->hasMoreElements()) 1021 { 1022 Reference<container::XNamed> xNamed; 1023 xEnum->nextElement() >>= xNamed; 1024 if(xNamed.is()) 1025 vNames.push_back(xNamed->getName()); 1026 } 1027 return ::comphelper::containerToSequence(vNames); 1028 } 1029 1030 sal_Bool SwXFrames::hasByName(const OUString& rName) throw( uno::RuntimeException ) 1031 { 1032 vos::OGuard aGuard(Application::GetSolarMutex()); 1033 if(!IsValid()) 1034 throw uno::RuntimeException(); 1035 switch(eType) 1036 { 1037 case FLYCNTTYPE_GRF: 1038 return GetDoc()->FindFlyByName(rName, ND_GRFNODE) != NULL; 1039 case FLYCNTTYPE_OLE: 1040 return GetDoc()->FindFlyByName(rName, ND_OLENODE) != NULL; 1041 default: 1042 return GetDoc()->FindFlyByName(rName, ND_TEXTNODE) != NULL; 1043 } 1044 } 1045 1046 uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException) 1047 { 1048 vos::OGuard aGuard(Application::GetSolarMutex()); 1049 switch(eType) 1050 { 1051 case FLYCNTTYPE_FRM: 1052 return ::getCppuType((uno::Reference<XTextFrame>*)0); 1053 case FLYCNTTYPE_GRF: 1054 return ::getCppuType((uno::Reference<XTextContent>*)0); 1055 case FLYCNTTYPE_OLE: 1056 return ::getCppuType((uno::Reference<XEmbeddedObjectSupplier>*)0); 1057 default: 1058 return uno::Type(); 1059 } 1060 } 1061 1062 sal_Bool SwXFrames::hasElements(void) throw(uno::RuntimeException) 1063 { 1064 vos::OGuard aGuard(Application::GetSolarMutex()); 1065 if(!IsValid()) 1066 throw uno::RuntimeException(); 1067 return GetDoc()->GetFlyCount(eType) > 0; 1068 } 1069 1070 SwXFrame* SwXFrames::GetObject(SwFrmFmt& rFmt, FlyCntType eType) 1071 { 1072 SwXFrame* pFrm = SwIterator<SwXFrame,SwFmt>::FirstElement( rFmt ); 1073 if(pFrm) return pFrm; 1074 switch(eType) 1075 { 1076 case FLYCNTTYPE_FRM: 1077 return new SwXTextFrame(rFmt); 1078 case FLYCNTTYPE_GRF: 1079 return new SwXTextGraphicObject(rFmt); 1080 case FLYCNTTYPE_OLE: 1081 return new SwXTextEmbeddedObject(rFmt); 1082 default: 1083 return NULL; 1084 } 1085 } 1086 1087 /****************************************************************** 1088 * SwXTextFrames 1089 ******************************************************************/ 1090 OUString SwXTextFrames::getImplementationName(void) throw( RuntimeException ) 1091 { 1092 return C2U("SwXTextFrames"); 1093 } 1094 1095 sal_Bool SwXTextFrames::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1096 { 1097 return C2U("com.sun.star.text.TextFrames") == rServiceName; 1098 } 1099 1100 Sequence< OUString > SwXTextFrames::getSupportedServiceNames(void) throw( RuntimeException ) 1101 { 1102 Sequence< OUString > aRet(1); 1103 OUString* pArray = aRet.getArray(); 1104 pArray[0] = C2U("com.sun.star.text.TextFrames"); 1105 return aRet; 1106 } 1107 1108 SwXTextFrames::SwXTextFrames(SwDoc* _pDoc) : 1109 SwXFrames(_pDoc, FLYCNTTYPE_FRM) 1110 { 1111 } 1112 1113 SwXTextFrames::~SwXTextFrames() 1114 { 1115 } 1116 1117 /****************************************************************** 1118 * SwXTextGraphicObjects 1119 ******************************************************************/ 1120 1121 OUString SwXTextGraphicObjects::getImplementationName(void) throw( RuntimeException ) 1122 { 1123 return C2U("SwXTextGraphicObjects"); 1124 } 1125 1126 sal_Bool SwXTextGraphicObjects::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1127 { 1128 return C2U("com.sun.star.text.TextGraphicObjects") == rServiceName; 1129 } 1130 1131 Sequence< OUString > SwXTextGraphicObjects::getSupportedServiceNames(void) throw( RuntimeException ) 1132 { 1133 Sequence< OUString > aRet(1); 1134 OUString* pArray = aRet.getArray(); 1135 pArray[0] = C2U("com.sun.star.text.TextGraphicObjects"); 1136 return aRet; 1137 } 1138 1139 SwXTextGraphicObjects::SwXTextGraphicObjects(SwDoc* _pDoc) : 1140 SwXFrames(_pDoc, FLYCNTTYPE_GRF) 1141 { 1142 } 1143 1144 SwXTextGraphicObjects::~SwXTextGraphicObjects() 1145 { 1146 } 1147 1148 /****************************************************************** 1149 * SwXTextEmbeddedObjects 1150 ******************************************************************/ 1151 OUString SwXTextEmbeddedObjects::getImplementationName(void) throw( RuntimeException ) 1152 { 1153 return C2U("SwXTextEmbeddedObjects"); 1154 } 1155 1156 sal_Bool SwXTextEmbeddedObjects::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1157 { 1158 return C2U("com.sun.star.text.TextEmbeddedObjects") == rServiceName; 1159 } 1160 1161 Sequence< OUString > SwXTextEmbeddedObjects::getSupportedServiceNames(void) throw( RuntimeException ) 1162 { 1163 Sequence< OUString > aRet(1); 1164 OUString* pArray = aRet.getArray(); 1165 pArray[0] = C2U("com.sun.star.text.TextEmbeddedObjects"); 1166 return aRet; 1167 } 1168 1169 SwXTextEmbeddedObjects::SwXTextEmbeddedObjects(SwDoc* _pDoc) : 1170 SwXFrames(_pDoc, FLYCNTTYPE_OLE) 1171 { 1172 } 1173 1174 SwXTextEmbeddedObjects::~SwXTextEmbeddedObjects() 1175 { 1176 } 1177 1178 /****************************************************************** 1179 * 1180 ******************************************************************/ 1181 #define PASSWORD_STD_TIMEOUT 1000 1182 OUString SwXTextSections::getImplementationName(void) throw( RuntimeException ) 1183 { 1184 return C2U("SwXTextSections"); 1185 } 1186 1187 sal_Bool SwXTextSections::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1188 { 1189 return C2U("com.sun.star.text.TextSections") == rServiceName; 1190 } 1191 1192 Sequence< OUString > SwXTextSections::getSupportedServiceNames(void) throw( RuntimeException ) 1193 { 1194 Sequence< OUString > aRet(1); 1195 OUString* pArray = aRet.getArray(); 1196 pArray[0] = C2U("com.sun.star.text.TextSections"); 1197 return aRet; 1198 } 1199 1200 SwXTextSections::SwXTextSections(SwDoc* _pDoc) : 1201 SwUnoCollection(_pDoc) 1202 { 1203 } 1204 1205 SwXTextSections::~SwXTextSections() 1206 { 1207 } 1208 1209 sal_Int32 SwXTextSections::getCount(void) throw( uno::RuntimeException ) 1210 { 1211 vos::OGuard aGuard(Application::GetSolarMutex()); 1212 if(!IsValid()) 1213 throw uno::RuntimeException(); 1214 const SwSectionFmts& rSectFmts = GetDoc()->GetSections(); 1215 sal_uInt16 nCount = rSectFmts.Count(); 1216 for(sal_uInt16 i = nCount; i; i--) 1217 { 1218 if( !rSectFmts[i - 1]->IsInNodesArr()) 1219 nCount--; 1220 } 1221 return nCount; 1222 } 1223 1224 uno::Any SwXTextSections::getByIndex(sal_Int32 nIndex) 1225 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 1226 { 1227 vos::OGuard aGuard(Application::GetSolarMutex()); 1228 uno::Reference< XTextSection > xRet; 1229 if(IsValid()) 1230 { 1231 SwSectionFmts& rFmts = GetDoc()->GetSections(); 1232 1233 const SwSectionFmts& rSectFmts = GetDoc()->GetSections(); 1234 sal_uInt16 nCount = rSectFmts.Count(); 1235 for(sal_uInt16 i = 0; i < nCount; i++) 1236 { 1237 if( !rSectFmts[i]->IsInNodesArr()) 1238 nIndex ++; 1239 else if(nIndex == i) 1240 break; 1241 if(nIndex == i) 1242 break; 1243 } 1244 if(nIndex >= 0 && nIndex < rFmts.Count()) 1245 { 1246 SwSectionFmt* pFmt = rFmts[(sal_uInt16)nIndex]; 1247 xRet = GetObject(*pFmt); 1248 } 1249 else 1250 throw IndexOutOfBoundsException(); 1251 } 1252 else 1253 throw uno::RuntimeException(); 1254 return makeAny(xRet); 1255 } 1256 1257 uno::Any SwXTextSections::getByName(const OUString& Name) 1258 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException ) 1259 { 1260 vos::OGuard aGuard(Application::GetSolarMutex()); 1261 uno::Any aRet; 1262 if(IsValid()) 1263 { 1264 String aName(Name); 1265 SwSectionFmts& rFmts = GetDoc()->GetSections(); 1266 uno::Reference< XTextSection > xSect; 1267 for(sal_uInt16 i = 0; i < rFmts.Count(); i++) 1268 { 1269 SwSectionFmt* pFmt = rFmts[i]; 1270 if (pFmt->IsInNodesArr() 1271 && (aName == pFmt->GetSection()->GetSectionName())) 1272 { 1273 xSect = GetObject(*pFmt); 1274 aRet.setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0)); 1275 break; 1276 } 1277 } 1278 if(!xSect.is()) 1279 throw NoSuchElementException(); 1280 } 1281 else 1282 throw uno::RuntimeException(); 1283 return aRet; 1284 } 1285 1286 uno::Sequence< OUString > SwXTextSections::getElementNames(void) 1287 throw( uno::RuntimeException ) 1288 { 1289 vos::OGuard aGuard(Application::GetSolarMutex()); 1290 if(!IsValid()) 1291 throw uno::RuntimeException(); 1292 sal_uInt16 nCount = GetDoc()->GetSections().Count(); 1293 SwSectionFmts& rSectFmts = GetDoc()->GetSections(); 1294 for(sal_uInt16 i = nCount; i; i--) 1295 { 1296 if( !rSectFmts[i - 1]->IsInNodesArr()) 1297 nCount--; 1298 } 1299 1300 uno::Sequence<OUString> aSeq(nCount); 1301 if(nCount) 1302 { 1303 SwSectionFmts& rFmts = GetDoc()->GetSections(); 1304 OUString* pArray = aSeq.getArray(); 1305 sal_uInt16 nIndex = 0; 1306 for( sal_uInt16 i = 0; i < nCount; i++, nIndex++) 1307 { 1308 const SwSectionFmt* pFmt = rFmts[nIndex]; 1309 while(!pFmt->IsInNodesArr()) 1310 { 1311 pFmt = rFmts[++nIndex]; 1312 } 1313 pArray[i] = pFmt->GetSection()->GetSectionName(); 1314 } 1315 } 1316 return aSeq; 1317 } 1318 1319 sal_Bool SwXTextSections::hasByName(const OUString& Name) 1320 throw( uno::RuntimeException ) 1321 { 1322 vos::OGuard aGuard(Application::GetSolarMutex()); 1323 sal_Bool bRet = sal_False; 1324 String aName(Name); 1325 if(IsValid()) 1326 { 1327 SwSectionFmts& rFmts = GetDoc()->GetSections(); 1328 for(sal_uInt16 i = 0; i < rFmts.Count(); i++) 1329 { 1330 const SwSectionFmt* pFmt = rFmts[i]; 1331 if (aName == pFmt->GetSection()->GetSectionName()) 1332 { 1333 bRet = sal_True; 1334 break; 1335 } 1336 } 1337 } 1338 else 1339 { 1340 //Sonderbehandlung der dbg_ - Methoden 1341 if( COMPARE_EQUAL != aName.CompareToAscii("dbg_", 4)) 1342 throw uno::RuntimeException(); 1343 } 1344 return bRet; 1345 } 1346 1347 uno::Type SAL_CALL SwXTextSections::getElementType() throw(uno::RuntimeException) 1348 { 1349 return ::getCppuType((uno::Reference<XTextSection>*)0); 1350 } 1351 1352 sal_Bool SwXTextSections::hasElements(void) throw( uno::RuntimeException ) 1353 { 1354 vos::OGuard aGuard(Application::GetSolarMutex()); 1355 sal_uInt16 nCount = 0; 1356 if(IsValid()) 1357 { 1358 SwSectionFmts& rFmts = GetDoc()->GetSections(); 1359 nCount = rFmts.Count(); 1360 } 1361 else 1362 throw uno::RuntimeException(); 1363 return nCount > 0; 1364 } 1365 1366 uno::Reference< XTextSection > SwXTextSections::GetObject( SwSectionFmt& rFmt ) 1367 { 1368 return SwXTextSection::CreateXTextSection(&rFmt); 1369 } 1370 1371 OUString SwXBookmarks::getImplementationName(void) throw( RuntimeException ) 1372 { 1373 return OUString::createFromAscii("SwXBookmarks"); 1374 } 1375 1376 sal_Bool SwXBookmarks::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1377 { 1378 return OUString::createFromAscii("com.sun.star.text.Bookmarks") == rServiceName; 1379 } 1380 1381 Sequence< OUString > SwXBookmarks::getSupportedServiceNames(void) throw( RuntimeException ) 1382 { 1383 Sequence< OUString > aRet(1); 1384 aRet[0] = OUString::createFromAscii("com.sun.star.text.Bookmarks"); 1385 return aRet; 1386 } 1387 1388 SwXBookmarks::SwXBookmarks(SwDoc* _pDoc) : 1389 SwUnoCollection(_pDoc) 1390 { } 1391 1392 SwXBookmarks::~SwXBookmarks() 1393 { } 1394 1395 sal_Int32 SwXBookmarks::getCount(void) 1396 throw( uno::RuntimeException ) 1397 { 1398 vos::OGuard aGuard(Application::GetSolarMutex()); 1399 if(!IsValid()) 1400 throw uno::RuntimeException(); 1401 return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount(); 1402 } 1403 1404 uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) 1405 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 1406 { 1407 vos::OGuard aGuard(Application::GetSolarMutex()); 1408 if(!IsValid()) 1409 throw uno::RuntimeException(); 1410 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); 1411 if(nIndex < 0 || nIndex >= pMarkAccess->getBookmarksCount()) 1412 throw IndexOutOfBoundsException(); 1413 1414 uno::Any aRet; 1415 ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get(); 1416 const uno::Reference< text::XTextContent > xRef = 1417 SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk); 1418 aRet <<= xRef; 1419 return aRet; 1420 } 1421 1422 uno::Any SwXBookmarks::getByName(const rtl::OUString& rName) 1423 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException ) 1424 { 1425 vos::OGuard aGuard(Application::GetSolarMutex()); 1426 if(!IsValid()) 1427 throw uno::RuntimeException(); 1428 1429 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); 1430 IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findBookmark(rName); 1431 if(ppBkmk == pMarkAccess->getBookmarksEnd()) 1432 throw NoSuchElementException(); 1433 1434 uno::Any aRet; 1435 const uno::Reference< text::XTextContent > xRef = 1436 SwXBookmark::CreateXBookmark(*GetDoc(), *(ppBkmk->get())); 1437 aRet <<= xRef; 1438 return aRet; 1439 } 1440 1441 uno::Sequence< OUString > SwXBookmarks::getElementNames(void) 1442 throw( uno::RuntimeException ) 1443 { 1444 vos::OGuard aGuard(Application::GetSolarMutex()); 1445 if(!IsValid()) 1446 throw uno::RuntimeException(); 1447 1448 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); 1449 uno::Sequence<OUString> aSeq(pMarkAccess->getBookmarksCount()); 1450 sal_Int32 nCnt = 0; 1451 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin(); 1452 ppMark != pMarkAccess->getBookmarksEnd();) 1453 aSeq[nCnt++] = (*ppMark++)->GetName(); 1454 return aSeq; 1455 } 1456 1457 sal_Bool SwXBookmarks::hasByName(const OUString& rName) 1458 throw( uno::RuntimeException ) 1459 { 1460 vos::OGuard aGuard(Application::GetSolarMutex()); 1461 if(!IsValid()) 1462 throw uno::RuntimeException(); 1463 1464 IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); 1465 return pMarkAccess->findBookmark(rName) != pMarkAccess->getBookmarksEnd(); 1466 } 1467 1468 uno::Type SAL_CALL SwXBookmarks::getElementType() 1469 throw(uno::RuntimeException) 1470 { 1471 return ::getCppuType((uno::Reference<XTextContent>*)0); 1472 } 1473 1474 sal_Bool SwXBookmarks::hasElements(void) 1475 throw( uno::RuntimeException ) 1476 { 1477 vos::OGuard aGuard(Application::GetSolarMutex()); 1478 if(!IsValid()) 1479 throw uno::RuntimeException(); 1480 return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0; 1481 } 1482 1483 /****************************************************************** 1484 * 1485 ******************************************************************/ 1486 1487 SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc* _pDoc ) : 1488 SwUnoCollection(_pDoc) 1489 { 1490 } 1491 1492 SwXNumberingRulesCollection::~SwXNumberingRulesCollection() 1493 { 1494 } 1495 1496 sal_Int32 SwXNumberingRulesCollection::getCount(void) throw( uno::RuntimeException ) 1497 { 1498 vos::OGuard aGuard(Application::GetSolarMutex()); 1499 if(!IsValid()) 1500 throw uno::RuntimeException(); 1501 return GetDoc()->GetNumRuleTbl().Count(); 1502 } 1503 1504 uno::Any SwXNumberingRulesCollection::getByIndex(sal_Int32 nIndex) 1505 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 1506 { 1507 vos::OGuard aGuard(Application::GetSolarMutex()); 1508 uno::Any aRet; 1509 if(IsValid()) 1510 { 1511 uno::Reference< XIndexReplace > xRef; 1512 if ( nIndex < GetDoc()->GetNumRuleTbl().Count() ) 1513 { 1514 xRef = new SwXNumberingRules( *GetDoc()->GetNumRuleTbl()[ static_cast< sal_uInt16 >(nIndex) ] ); 1515 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XIndexReplace>*)0)); 1516 } 1517 1518 if(!xRef.is()) 1519 throw IndexOutOfBoundsException(); 1520 } 1521 else 1522 throw uno::RuntimeException(); 1523 return aRet; 1524 } 1525 1526 uno::Type SAL_CALL SwXNumberingRulesCollection::getElementType() throw(uno::RuntimeException) 1527 { 1528 return ::getCppuType((uno::Reference<XIndexReplace>*)0); 1529 } 1530 1531 sal_Bool SwXNumberingRulesCollection::hasElements(void) throw( uno::RuntimeException ) 1532 { 1533 vos::OGuard aGuard(Application::GetSolarMutex()); 1534 if(!IsValid()) 1535 throw uno::RuntimeException(); 1536 return GetDoc()->GetNumRuleTbl().Count() > 0; 1537 } 1538 1539 OUString SwXFootnotes::getImplementationName(void) throw( RuntimeException ) 1540 { 1541 return C2U("SwXFootnotes"); 1542 } 1543 1544 sal_Bool SwXFootnotes::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1545 { 1546 return C2U("com.sun.star.text.Footnotes") == rServiceName; 1547 } 1548 1549 Sequence< OUString > SwXFootnotes::getSupportedServiceNames(void) throw( RuntimeException ) 1550 { 1551 Sequence< OUString > aRet(1); 1552 OUString* pArray = aRet.getArray(); 1553 pArray[0] = C2U("com.sun.star.text.Footnotes"); 1554 return aRet; 1555 } 1556 1557 SwXFootnotes::SwXFootnotes(sal_Bool bEnd, SwDoc* _pDoc) 1558 : SwUnoCollection(_pDoc) 1559 , m_bEndnote(bEnd) 1560 { 1561 } 1562 1563 SwXFootnotes::~SwXFootnotes() 1564 { 1565 } 1566 1567 sal_Int32 SwXFootnotes::getCount(void) throw( uno::RuntimeException ) 1568 { 1569 vos::OGuard aGuard(Application::GetSolarMutex()); 1570 if(!IsValid()) 1571 throw uno::RuntimeException(); 1572 sal_Int32 nCount = 0; 1573 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count(); 1574 SwTxtFtn* pTxtFtn; 1575 for( n = 0; n < nFtnCnt; ++n ) 1576 { 1577 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; 1578 const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); 1579 if ( rFtn.IsEndNote() != m_bEndnote ) 1580 continue; 1581 nCount++; 1582 } 1583 return nCount; 1584 } 1585 1586 uno::Any SwXFootnotes::getByIndex(sal_Int32 nIndex) 1587 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 1588 { 1589 vos::OGuard aGuard(Application::GetSolarMutex()); 1590 uno::Any aRet; 1591 sal_Int32 nCount = 0; 1592 if(IsValid()) 1593 { 1594 sal_uInt16 n, nFtnCnt = GetDoc()->GetFtnIdxs().Count(); 1595 SwTxtFtn* pTxtFtn; 1596 uno::Reference< XFootnote > xRef; 1597 for( n = 0; n < nFtnCnt; ++n ) 1598 { 1599 pTxtFtn = GetDoc()->GetFtnIdxs()[ n ]; 1600 const SwFmtFtn& rFtn = pTxtFtn->GetFtn(); 1601 if ( rFtn.IsEndNote() != m_bEndnote ) 1602 continue; 1603 1604 if(nCount == nIndex) 1605 { 1606 xRef = SwXFootnote::CreateXFootnote(*GetDoc(), rFtn); 1607 aRet <<= xRef; 1608 break; 1609 } 1610 nCount++; 1611 } 1612 if(!xRef.is()) 1613 throw IndexOutOfBoundsException(); 1614 } 1615 else 1616 throw uno::RuntimeException(); 1617 return aRet; 1618 } 1619 1620 uno::Type SAL_CALL SwXFootnotes::getElementType() throw(uno::RuntimeException) 1621 { 1622 return ::getCppuType((uno::Reference<XFootnote>*)0); 1623 } 1624 1625 sal_Bool SwXFootnotes::hasElements(void) throw( uno::RuntimeException ) 1626 { 1627 vos::OGuard aGuard(Application::GetSolarMutex()); 1628 if(!IsValid()) 1629 throw uno::RuntimeException(); 1630 return GetDoc()->GetFtnIdxs().Count() > 0; 1631 } 1632 1633 Reference<XFootnote> SwXFootnotes::GetObject( SwDoc& rDoc, const SwFmtFtn& rFmt ) 1634 { 1635 return SwXFootnote::CreateXFootnote(rDoc, rFmt); 1636 } 1637 1638 /****************************************************************** 1639 * 1640 ******************************************************************/ 1641 1642 OUString SwXReferenceMarks::getImplementationName(void) throw( RuntimeException ) 1643 { 1644 return C2U("SwXReferenceMarks"); 1645 } 1646 1647 sal_Bool SwXReferenceMarks::supportsService(const OUString& rServiceName) throw( RuntimeException ) 1648 { 1649 return C2U("com.sun.star.text.ReferenceMarks") == rServiceName; 1650 } 1651 1652 Sequence< OUString > SwXReferenceMarks::getSupportedServiceNames(void) throw( RuntimeException ) 1653 { 1654 Sequence< OUString > aRet(1); 1655 OUString* pArray = aRet.getArray(); 1656 pArray[0] = C2U("com.sun.star.text.ReferenceMarks"); 1657 return aRet; 1658 } 1659 1660 SwXReferenceMarks::SwXReferenceMarks(SwDoc* _pDoc) : 1661 SwUnoCollection(_pDoc) 1662 { 1663 } 1664 1665 SwXReferenceMarks::~SwXReferenceMarks() 1666 { 1667 } 1668 1669 sal_Int32 SwXReferenceMarks::getCount(void) throw( uno::RuntimeException ) 1670 { 1671 vos::OGuard aGuard(Application::GetSolarMutex()); 1672 if(!IsValid()) 1673 throw uno::RuntimeException(); 1674 return GetDoc()->GetRefMarks(); 1675 } 1676 1677 uno::Any SwXReferenceMarks::getByIndex(sal_Int32 nIndex) 1678 throw( IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) 1679 { 1680 vos::OGuard aGuard(Application::GetSolarMutex()); 1681 uno::Any aRet; 1682 if(!IsValid()) 1683 throw uno::RuntimeException(); 1684 uno::Reference< XTextContent > xRef; 1685 if(0 <= nIndex && nIndex < USHRT_MAX) 1686 { 1687 const SwFmtRefMark* pMark = GetDoc()->GetRefMark( (sal_uInt16) nIndex ); 1688 if(pMark) 1689 { 1690 xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark ); 1691 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); 1692 } 1693 } 1694 if(!xRef.is()) 1695 throw IndexOutOfBoundsException(); 1696 return aRet; 1697 } 1698 1699 uno::Any SwXReferenceMarks::getByName(const OUString& rName) 1700 throw( NoSuchElementException, WrappedTargetException, uno::RuntimeException ) 1701 { 1702 vos::OGuard aGuard(Application::GetSolarMutex()); 1703 uno::Any aRet; 1704 if(IsValid()) 1705 { 1706 const SwFmtRefMark* pMark = GetDoc()->GetRefMark(rName); 1707 if(pMark) 1708 { 1709 uno::Reference< XTextContent > xRef = SwXReferenceMarks::GetObject( GetDoc(), pMark ); 1710 aRet.setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0)); 1711 } 1712 else 1713 throw NoSuchElementException(); 1714 } 1715 else 1716 throw uno::RuntimeException(); 1717 return aRet; 1718 } 1719 1720 uno::Sequence< OUString > SwXReferenceMarks::getElementNames(void) throw( uno::RuntimeException ) 1721 { 1722 vos::OGuard aGuard(Application::GetSolarMutex()); 1723 uno::Sequence<OUString> aRet; 1724 if(IsValid()) 1725 { 1726 SvStringsDtor aStrings; 1727 sal_uInt16 nCount = GetDoc()->GetRefMarks( &aStrings ); 1728 aRet.realloc(nCount); 1729 OUString* pNames = aRet.getArray(); 1730 for(sal_uInt16 i = 0; i < nCount; i++) 1731 pNames[i] = *aStrings.GetObject(i); 1732 } 1733 else 1734 throw uno::RuntimeException(); 1735 return aRet; 1736 } 1737 1738 sal_Bool SwXReferenceMarks::hasByName(const OUString& rName) throw( uno::RuntimeException ) 1739 { 1740 vos::OGuard aGuard(Application::GetSolarMutex()); 1741 if(!IsValid()) 1742 throw uno::RuntimeException(); 1743 return 0 != GetDoc()->GetRefMark( rName); 1744 } 1745 1746 uno::Type SAL_CALL SwXReferenceMarks::getElementType() throw(uno::RuntimeException) 1747 { 1748 return ::getCppuType((uno::Reference<XTextContent>*)0); 1749 } 1750 1751 sal_Bool SwXReferenceMarks::hasElements(void) throw( uno::RuntimeException ) 1752 { 1753 vos::OGuard aGuard(Application::GetSolarMutex()); 1754 if(!IsValid()) 1755 throw uno::RuntimeException(); 1756 return 0 != GetDoc()->GetRefMarks(); 1757 } 1758 1759 SwXReferenceMark* SwXReferenceMarks::GetObject( SwDoc* pDoc, const SwFmtRefMark* pMark ) 1760 { 1761 vos::OGuard aGuard(Application::GetSolarMutex()); 1762 1763 return SwXReferenceMark::CreateXReferenceMark(*pDoc, *pMark); 1764 } 1765 1766 /****************************************************************** 1767 * 1768 ******************************************************************/ 1769 1770 void SwUnoCollection::Invalidate() 1771 { 1772 bObjectValid = sal_False; 1773 pDoc = 0; 1774 } 1775 1776