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

Generated by: LCOV version 1.10