LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/unocore - unocoll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 651 893 72.9 %
Date: 2013-07-09 Functions: 114 169 67.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10