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

Generated by: LCOV version 1.10