LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbafield.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 221 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 34 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             : #include "vbafield.hxx"
      20             : #include "vbarange.hxx"
      21             : #include <com/sun/star/frame/XModel.hpp>
      22             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      23             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      24             : #include <com/sun/star/text/XTextFieldsSupplier.hpp>
      25             : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
      26             : #include <com/sun/star/util/XRefreshable.hpp>
      27             : #include <com/sun/star/util/XUpdatable.hpp>
      28             : #include <comphelper/string.hxx>
      29             : #include <ooo/vba/word/WdFieldType.hpp>
      30             : #include <swtypes.hxx>
      31             : #include <cppuhelper/implbase.hxx>
      32             : 
      33             : using namespace ::ooo::vba;
      34             : using namespace ::com::sun::star;
      35             : 
      36           0 : SwVbaField::SwVbaField(  const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& rDocument, const  uno::Reference< css::text::XTextField >& xTextField) throw ( uno::RuntimeException ) : SwVbaField_BASE( rParent, rContext ), mxTextDocument( rDocument )
      37             : {
      38           0 :     mxTextField.set( xTextField, uno::UNO_QUERY_THROW );
      39           0 : }
      40             : 
      41           0 : sal_Bool SAL_CALL SwVbaField::Update() throw (uno::RuntimeException, std::exception)
      42             : {
      43           0 :     uno::Reference< util::XUpdatable > xUpdatable( mxTextField, uno::UNO_QUERY );
      44           0 :     if( xUpdatable.is() )
      45             :     {
      46           0 :         xUpdatable->update();
      47           0 :         return sal_True;
      48             :     }
      49           0 :     return sal_False;
      50             : }
      51             : 
      52             : // XHelperInterface
      53             : OUString
      54           0 : SwVbaField::getServiceImplName()
      55             : {
      56           0 :     return OUString("SwVbaField");
      57             : }
      58             : 
      59             : uno::Sequence<OUString>
      60           0 : SwVbaField::getServiceNames()
      61             : {
      62           0 :     static uno::Sequence< OUString > aServiceNames;
      63           0 :     if ( aServiceNames.getLength() == 0 )
      64             :     {
      65           0 :         aServiceNames.realloc( 1 );
      66           0 :         aServiceNames[ 0 ] = "ooo.vba.word.Field";
      67             :     }
      68           0 :     return aServiceNames;
      69             : }
      70             : 
      71             : // FIXME? copy and paste code
      72             : // the codes are copied from ww8par5.cxx
      73             : class SwVbaReadFieldParams
      74             : {
      75             : private:
      76             :     OUString aData;
      77             :     sal_Int32 nLen, nFnd, nNext, nSavPtr;
      78             :     OUString aFieldName;
      79             : public:
      80             :     explicit SwVbaReadFieldParams( const OUString& rData );
      81             :     ~SwVbaReadFieldParams();
      82             : 
      83             :     long SkipToNextToken();
      84             : 
      85             :     sal_Int32 FindNextStringPiece( sal_Int32 _nStart = -1 );
      86             : 
      87             :     OUString GetResult() const;
      88           0 :     OUString GetFieldName()const { return aFieldName; }
      89             : };
      90             : 
      91           0 : SwVbaReadFieldParams::SwVbaReadFieldParams( const OUString& _rData )
      92           0 :     : aData( _rData ), nLen( _rData.getLength() ), nNext( 0 )
      93             : {
      94             :     // First search for an opening parenthesis or a space or a quotation mark
      95             :     // or a backslash, so that the field command
      96             :     // (thus INCLUDEPICTURE or ...) is ignored.
      97           0 :     while( (nLen > nNext) && (aData[ nNext ] == ' ') )
      98           0 :         ++nNext;
      99             : 
     100             :     sal_Unicode c;
     101           0 :     while(     nLen > nNext
     102           0 :             && (c = aData[ nNext ]) != ' '
     103           0 :             && c != '"'
     104           0 :             && c != '\\'
     105           0 :             && c != 132
     106           0 :             && c != 0x201c )
     107           0 :         ++nNext;
     108             : 
     109           0 :     nFnd      = nNext;
     110           0 :     nSavPtr   = nNext;
     111           0 :     aFieldName = aData.copy( 0, nFnd );
     112           0 : }
     113             : 
     114           0 : SwVbaReadFieldParams::~SwVbaReadFieldParams()
     115             : {
     116           0 : }
     117             : 
     118           0 : OUString SwVbaReadFieldParams::GetResult() const
     119             : {
     120           0 :     return    (-1 == nFnd)
     121             :             ? OUString()
     122           0 :             : aData.copy( nFnd, (nSavPtr - nFnd) );
     123             : }
     124             : 
     125             : // ret: -2: NOT a '\' parameter but normal Text
     126           0 : long SwVbaReadFieldParams::SkipToNextToken()
     127             : {
     128           0 :     long nRet = -1;     // end
     129           0 :     if (
     130           0 :          (-1 != nNext) && (nLen > nNext) &&
     131           0 :          -1 != (nFnd = FindNextStringPiece(nNext))
     132             :        )
     133             :     {
     134           0 :         nSavPtr = nNext;
     135             : 
     136           0 :         if ('\\' == aData[nFnd] && '\\' != aData[nFnd + 1])
     137             :         {
     138           0 :             nRet = aData[++nFnd];
     139           0 :             nNext = ++nFnd;             // and set behind
     140             :         }
     141             :         else
     142             :         {
     143           0 :             nRet = -2;
     144           0 :             if (
     145           0 :                  (-1 != nSavPtr ) &&
     146             :                  (
     147           0 :                    ('"' == aData[nSavPtr - 1]) ||
     148           0 :                    (0x201d == aData[nSavPtr - 1])
     149             :                  )
     150             :                )
     151             :             {
     152           0 :                 --nSavPtr;
     153             :             }
     154             :         }
     155             :     }
     156           0 :     return nRet;
     157             : }
     158             : 
     159             : // FindNextPara is searching for the next Backslash-Parameter or the next string
     160             : // until blank or the next "\" or until the closing quotation mark
     161             : // or until the string end of pStr.
     162             : 
     163             : // Output ppNext (if ppNext != 0) beginning of the search for the next parameter or 0
     164             : 
     165             : // Return value: 0 if String-End reached, otherwise begin of the parameter or the string
     166             : 
     167           0 : sal_Int32 SwVbaReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
     168             : {
     169           0 :     sal_Int32  n = ( -1 == nStart ) ? nFnd : nStart;  // Start
     170             :     sal_Int32 n2;          // End
     171             : 
     172           0 :     nNext = -1;        // Default for not found
     173             : 
     174           0 :     while( (nLen > n) && (aData[ n ] == ' ') )
     175           0 :         ++n;
     176             : 
     177           0 :     if( nLen == n )
     178           0 :         return -1;     // String End reached!
     179             : 
     180           0 :     if(     (aData[ n ] == '"')     // quotation marks are in front of parenthesis?
     181           0 :         ||  (aData[ n ] == 0x201c)
     182           0 :         ||  (aData[ n ] == 132) )
     183             :     {
     184           0 :         n++;                        // ignore quotation marks
     185           0 :         n2 = n;                     // From here search for the end
     186           0 :         while(     (nLen > n2)
     187           0 :                 && (aData[ n2 ] != '"')
     188           0 :                 && (aData[ n2 ] != 0x201d)
     189           0 :                 && (aData[ n2 ] != 147) )
     190           0 :             n2++;                   // Search for the end of the parenthesis
     191             :     }
     192             :     else                        // no quotation marks
     193             :     {
     194           0 :         n2 = n;                     // from here search for the end
     195           0 :         while( (nLen > n2) && (aData[ n2 ] != ' ') ) // Search for the end of the parenthesis
     196             :         {
     197           0 :             if( aData[ n2 ] == '\\' )
     198             :             {
     199           0 :                 if( aData[ n2+1 ] == '\\' )
     200           0 :                     n2 += 2;        // double-backslash -> OK
     201             :                 else
     202             :                 {
     203           0 :                     if( n2 > n )
     204           0 :                         n2--;
     205           0 :                     break;          // single-backslash -> End
     206             :                 }
     207             :             }
     208             :             else
     209           0 :                 n2++;               // no backslash -> OK
     210             :         }
     211             :     }
     212           0 :     if( nLen > n2 )
     213             :     {
     214           0 :         if(aData[ n2 ] != ' ') n2++;
     215           0 :         nNext = n2;
     216             :     }
     217           0 :     return n;
     218             : }
     219             : 
     220             : // SwVbaFields
     221             : 
     222           0 : static uno::Any lcl_createField( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Any& aSource )
     223             : {
     224           0 :     uno::Reference< text::XTextField > xTextField( aSource, uno::UNO_QUERY_THROW );
     225           0 :     uno::Reference< text::XTextDocument > xTextDocument( xModel, uno::UNO_QUERY_THROW );
     226           0 :     uno::Reference< word::XField > xField( new SwVbaField( xParent, xContext, xTextDocument, xTextField ) );
     227           0 :     return uno::makeAny( xField );
     228             : }
     229             : 
     230             : typedef ::cppu::WeakImplHelper< css::container::XEnumeration > FieldEnumeration_BASE;
     231             : typedef ::cppu::WeakImplHelper< container::XIndexAccess, container::XEnumerationAccess > FieldCollectionHelper_BASE;
     232             : 
     233           0 : class FieldEnumeration : public FieldEnumeration_BASE
     234             : {
     235             :     uno::Reference< XHelperInterface > mxParent;
     236             :     uno::Reference< uno::XComponentContext > mxContext;
     237             :     uno::Reference< frame::XModel > mxModel;
     238             :     uno::Reference< container::XEnumeration > mxEnumeration;
     239             : public:
     240           0 :     FieldEnumeration(  const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< container::XEnumeration >& xEnumeration ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxEnumeration( xEnumeration )
     241             :     {
     242           0 :     }
     243           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     244             :     {
     245           0 :         return mxEnumeration->hasMoreElements();
     246             :     }
     247           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     248             :     {
     249           0 :         if ( !hasMoreElements() )
     250           0 :             throw container::NoSuchElementException();
     251           0 :         return lcl_createField( mxParent, mxContext, mxModel, mxEnumeration->nextElement() );
     252             :     }
     253             : };
     254             : 
     255           0 : class FieldCollectionHelper : public FieldCollectionHelper_BASE
     256             : {
     257             :     uno::Reference< XHelperInterface > mxParent;
     258             :     uno::Reference< uno::XComponentContext > mxContext;
     259             :     uno::Reference< frame::XModel > mxModel;
     260             :     uno::Reference< container::XEnumerationAccess > mxEnumerationAccess;
     261             : public:
     262           0 :     FieldCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) throw (css::uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel )
     263             :     {
     264           0 :         uno::Reference< text::XTextFieldsSupplier > xSupp( xModel, uno::UNO_QUERY_THROW );
     265           0 :         mxEnumerationAccess.set( xSupp->getTextFields(), uno::UNO_QUERY_THROW );
     266           0 :     }
     267             :     // XElementAccess
     268           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return  mxEnumerationAccess->getElementType(); }
     269           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return mxEnumerationAccess->hasElements(); }
     270             :     // XIndexAccess
     271           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     272             :     {
     273           0 :         uno::Reference< container::XEnumeration > xEnumeration =  mxEnumerationAccess->createEnumeration();
     274           0 :         sal_Int32 nCount = 0;
     275           0 :         while( xEnumeration->hasMoreElements() )
     276             :         {
     277           0 :             ++nCount;
     278           0 :             xEnumeration->nextElement();
     279             :         }
     280           0 :         return nCount;
     281             :     }
     282           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) SAL_OVERRIDE
     283             :     {
     284           0 :         if( Index < 0 || Index >= getCount() )
     285           0 :             throw lang::IndexOutOfBoundsException();
     286             : 
     287           0 :         uno::Reference< container::XEnumeration > xEnumeration =  mxEnumerationAccess->createEnumeration();
     288           0 :         sal_Int32 nCount = 0;
     289           0 :         while( xEnumeration->hasMoreElements() )
     290             :         {
     291           0 :             if( nCount == Index )
     292             :             {
     293           0 :                 return xEnumeration->nextElement();
     294             :             }
     295           0 :             ++nCount;
     296             :         }
     297           0 :         throw lang::IndexOutOfBoundsException();
     298             :     }
     299             :     // XEnumerationAccess
     300           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     301             :     {
     302           0 :         uno::Reference< container::XEnumeration > xEnumeration =  mxEnumerationAccess->createEnumeration();
     303           0 :         return uno::Reference< container::XEnumeration >( new FieldEnumeration( mxParent, mxContext, mxModel, xEnumeration ) );
     304             :     }
     305             : };
     306             : 
     307           0 : SwVbaFields::SwVbaFields( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaFields_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new FieldCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel )
     308             : {
     309           0 :     mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
     310           0 : }
     311             : 
     312             : uno::Reference< word::XField > SAL_CALL
     313           0 : SwVbaFields::Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& Type, const css::uno::Any& Text, const css::uno::Any& /*PreserveFormatting*/ ) throw (css::script::BasicErrorException, css::uno::RuntimeException, std::exception)
     314             : {
     315           0 :     sal_Int32 nType = word::WdFieldType::wdFieldEmpty;
     316           0 :     Type >>= nType;
     317           0 :     OUString sText;
     318           0 :     Text >>= sText;
     319             : 
     320           0 :     OUString sFieldName;
     321           0 :     if( ( nType == word::WdFieldType::wdFieldEmpty ) && !sText.isEmpty() )
     322             :     {
     323           0 :         SwVbaReadFieldParams aReadParam(sText);
     324           0 :         sFieldName = aReadParam.GetFieldName();
     325           0 :         OSL_TRACE("SwVbaFields::Add, the field name is %s ",OUStringToOString( sFieldName, RTL_TEXTENCODING_UTF8 ).getStr() );
     326             :     }
     327             : 
     328           0 :     uno::Reference< text::XTextContent > xTextField;
     329           0 :     if( nType == word::WdFieldType::wdFieldFileName || sFieldName.equalsIgnoreAsciiCase("FILENAME") )
     330             :     {
     331           0 :         xTextField.set( Create_Field_FileName( sText ), uno::UNO_QUERY_THROW );
     332             :     }
     333           0 :     else if( nType == word::WdFieldType::wdFieldDocProperty || sFieldName.equalsIgnoreAsciiCase("DOCPROPERTY") )
     334             :     {
     335           0 :         xTextField.set( Create_Field_DocProperty( sText ), uno::UNO_QUERY_THROW );
     336             :     }
     337             :     else
     338             :     {
     339           0 :         throw uno::RuntimeException("Not implemented" );
     340             :     }
     341             : 
     342           0 :     SwVbaRange& rVbaRange = dynamic_cast<SwVbaRange&>(*Range.get());
     343           0 :     uno::Reference< text::XTextRange > xTextRange = rVbaRange.getXTextRange();
     344           0 :     uno::Reference< text::XText > xText = xTextRange->getText();
     345           0 :     xText->insertTextContent( xTextRange, xTextField, true );
     346           0 :     return uno::Reference< word::XField >( new SwVbaField( mxParent, mxContext, uno::Reference< text::XTextDocument >( mxModel, uno::UNO_QUERY_THROW ), uno::Reference< text::XTextField >( xTextField, uno::UNO_QUERY_THROW ) ) );
     347             : }
     348             : 
     349           0 : uno::Reference< text::XTextField > SwVbaFields::Create_Field_FileName( const OUString& _text )
     350             :     throw (uno::RuntimeException, script::BasicErrorException)
     351             : {
     352           0 :     uno::Reference< text::XTextField > xTextField( mxMSF->createInstance("com.sun.star.text.TextField.FileName"), uno::UNO_QUERY_THROW );
     353           0 :     sal_Int16 nFileFormat = text::FilenameDisplayFormat::NAME_AND_EXT;
     354           0 :     if( !_text.isEmpty() )
     355             :     {
     356             :         long nRet;
     357           0 :         SwVbaReadFieldParams aReadParam( _text );
     358           0 :         while (-1 != (nRet = aReadParam.SkipToNextToken()))
     359             :         {
     360           0 :             switch (nRet)
     361             :             {
     362             :                 case 'p':
     363           0 :                     nFileFormat = text::FilenameDisplayFormat::FULL;
     364           0 :                     break;
     365             :                 case '*':
     366             :                     //Skip over MERGEFORMAT
     367           0 :                     aReadParam.SkipToNextToken();
     368           0 :                     break;
     369             :                 default:
     370           0 :                     DebugHelper::basicexception(SbERR_BAD_ARGUMENT, OUString());
     371           0 :                     break;
     372             :             }
     373           0 :         }
     374             :     }
     375             : 
     376           0 :     uno::Reference< beans::XPropertySet > xProps( xTextField, uno::UNO_QUERY_THROW );
     377           0 :     xProps->setPropertyValue("FileFormat", uno::makeAny( nFileFormat ) );
     378             : 
     379           0 :     return xTextField;
     380             : }
     381             : 
     382             : struct DocPropertyTable
     383             : {
     384             :     const char* sDocPropertyName;
     385             :     const char* sFieldService;
     386             : };
     387             : 
     388             : static const DocPropertyTable aDocPropertyTables[] =
     389             : {
     390             :     { "Author", "com.sun.star.text.textfield.docinfo.CreateAuthor" },
     391             :     { "Bytes", NULL },
     392             :     { "Category", NULL },
     393             :     { "Characters",NULL },
     394             :     { "CharactersWithSpaces", NULL },
     395             :     { "Comments", "com.sun.star.text.textfield.docinfo.Description" },
     396             :     { "Company", NULL },
     397             :     { "CreateTime", "com.sun.star.text.textfield.docinfo.CreateDateTime" },
     398             :     { "HyperlinkBase", NULL },
     399             :     { "Keywords", "com.sun.star.text.textfield.docinfo.Keywords" },
     400             :     { "LastPrinted", "com.sun.star.text.textfield.docinfo.PrintDateTime" },
     401             :     { "LastSavedBy", "com.sun.star.text.textfield.docinfo.ChangeAuthor" },
     402             :     { "LastSavedTime", "com.sun.star.text.textfield.docinfo.ChangeDateTime" },
     403             :     { "Lines", NULL },
     404             :     { "Manager", NULL },
     405             :     { "NameofApplication", NULL },
     406             :     { "ODMADocID", NULL },
     407             :     { "Pages", "com.sun.star.text.textfield.PageCount" },
     408             :     { "Paragraphs", "com.sun.star.text.textfield.ParagraphCount" },
     409             :     { "RevisionNumber", "com.sun.star.text.textfield.docinfo.Revision" },
     410             :     { "Security", NULL },
     411             :     { "Subject", "com.sun.star.text.textfield.docinfo.Subject" },
     412             :     { "Template", "com.sun.star.text.textfield.TemplateName" },
     413             :     { "Title", "com.sun.star.text.textfield.docinfo.Title" },
     414             :     { "TotalEditingTime", "com.sun.star.text.textfield.docinfo.EditTime" },
     415             :     { "Words", "com.sun.star.text.textfield.WordCount" },
     416             :     { NULL, NULL }
     417             : };
     418             : 
     419           0 : uno::Reference< text::XTextField > SwVbaFields::Create_Field_DocProperty( const OUString& _text ) throw (uno::RuntimeException)
     420             : {
     421           0 :     OUString aDocProperty;
     422           0 :     SwVbaReadFieldParams aReadParam( _text );
     423             :     long nRet;
     424           0 :     while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
     425             :     {
     426           0 :         switch( nRet )
     427             :         {
     428             :             case -2:
     429           0 :                 if( aDocProperty.isEmpty() )
     430           0 :                     aDocProperty = aReadParam.GetResult();
     431           0 :                 break;
     432             :             case '*':
     433             :                 //Skip over MERGEFORMAT
     434           0 :                 aReadParam.SkipToNextToken();
     435           0 :                 break;
     436             :         }
     437             :     }
     438           0 :     aDocProperty = comphelper::string::remove(aDocProperty, '"');
     439             :     OSL_TRACE("SwVbaFields::Create_Field_DocProperty, the document property name is %s ",OUStringToOString( aDocProperty, RTL_TEXTENCODING_UTF8 ).getStr() );
     440           0 :     if( aDocProperty.isEmpty() )
     441             :     {
     442           0 :         throw uno::RuntimeException();
     443             :     }
     444             : 
     445           0 :     bool bCustom = true;
     446           0 :     OUString sFieldService;
     447             :     // find the build in document properties
     448           0 :     for( const DocPropertyTable* pTable = aDocPropertyTables; pTable->sDocPropertyName != NULL; pTable++ )
     449             :     {
     450           0 :         if( aDocProperty.equalsIgnoreAsciiCaseAscii( pTable->sDocPropertyName ) )
     451             :         {
     452           0 :             if( pTable->sFieldService != NULL )
     453           0 :                 sFieldService = OUString::createFromAscii(pTable->sFieldService);
     454           0 :             bCustom = false;
     455           0 :             break;
     456             :         }
     457             :     }
     458             : 
     459           0 :     if( bCustom )
     460             :     {
     461           0 :         sFieldService = "com.sun.star.text.textfield.docinfo.Custom";
     462             :     }
     463           0 :     else if( sFieldService.isEmpty() )
     464             :     {
     465           0 :         throw uno::RuntimeException("Not implemented" );
     466             :     }
     467             : 
     468           0 :     uno::Reference< text::XTextField > xTextField( mxMSF->createInstance( sFieldService ), uno::UNO_QUERY_THROW );
     469             : 
     470           0 :     if( bCustom )
     471             :     {
     472           0 :         uno::Reference< beans::XPropertySet > xProps( xTextField, uno::UNO_QUERY_THROW );
     473           0 :         OUString sDocPropertyName( aDocProperty );
     474           0 :         xProps->setPropertyValue("Name", uno::makeAny( sDocPropertyName ) );
     475             :     }
     476             : 
     477           0 :     return xTextField;
     478             : }
     479             : 
     480             : uno::Reference< container::XEnumeration > SAL_CALL
     481           0 : SwVbaFields::createEnumeration() throw (uno::RuntimeException)
     482             : {
     483           0 :     uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     484           0 :     return xEnumerationAccess->createEnumeration();
     485             : }
     486             : 
     487             : // ScVbaCollectionBaseImpl
     488             : uno::Any
     489           0 : SwVbaFields::createCollectionObject( const uno::Any& aSource )
     490             : {
     491           0 :     return lcl_createField( mxParent, mxContext, mxModel, aSource );
     492             : }
     493             : 
     494           0 : sal_Int32 SAL_CALL SwVbaFields::Update() throw (uno::RuntimeException, std::exception)
     495             : {
     496           0 :     sal_Int32 nUpdate = 1;
     497             :     try
     498             :     {
     499           0 :         uno::Reference< text::XTextFieldsSupplier > xSupp( mxModel, uno::UNO_QUERY_THROW );
     500           0 :         uno::Reference< util::XRefreshable > xRef( xSupp->getTextFields(), uno::UNO_QUERY_THROW );
     501           0 :         xRef->refresh();
     502           0 :         nUpdate = 0;
     503             :     }
     504           0 :     catch(const uno::Exception&)
     505             :     {
     506           0 :         nUpdate = 1;
     507             :     }
     508           0 :     return nUpdate;
     509             : }
     510             : 
     511             : // XHelperInterface
     512             : OUString
     513           0 : SwVbaFields::getServiceImplName()
     514             : {
     515           0 :     return OUString("SwVbaFields");
     516             : }
     517             : 
     518             : // XEnumerationAccess
     519             : uno::Type SAL_CALL
     520           0 : SwVbaFields::getElementType() throw (uno::RuntimeException)
     521             : {
     522           0 :     return  cppu::UnoType<word::XField>::get();
     523             : }
     524             : 
     525             : uno::Sequence<OUString>
     526           0 : SwVbaFields::getServiceNames()
     527             : {
     528           0 :     static uno::Sequence< OUString > aServiceNames;
     529           0 :     if ( aServiceNames.getLength() == 0 )
     530             :     {
     531           0 :         aServiceNames.realloc( 1 );
     532           0 :         aServiceNames[ 0 ] = "ooo.vba.word.Fields";
     533             :     }
     534           0 :     return aServiceNames;
     535             : }
     536             : 
     537             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11