LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/unocore - unocoll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 260 891 29.2 %
Date: 2012-12-27 Functions: 60 167 35.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10