LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unocoll.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 888 0.0 %
Date: 2014-04-14 Functions: 0 167 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10