LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbadocumentproperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 401 0.2 %
Date: 2015-06-13 12:38:46 Functions: 2 99 2.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 "vbadocumentproperties.hxx"
      20             : #include <cppuhelper/implbase.hxx>
      21             : #include <com/sun/star/document/XDocumentProperties.hpp>
      22             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      23             : #include <com/sun/star/beans/NamedValue.hpp>
      24             : #include <com/sun/star/beans/XPropertyContainer.hpp>
      25             : #include <ooo/vba/word/WdBuiltInProperty.hpp>
      26             : #include <ooo/vba/office/MsoDocProperties.hpp>
      27             : #include <boost/shared_ptr.hpp>
      28             : #include "wordvbahelper.hxx"
      29             : #include "fesh.hxx"
      30             : #include "docsh.hxx"
      31             : using namespace ::ooo::vba;
      32             : using namespace css;
      33             : 
      34           0 : static sal_Int8 lcl_toMSOPropType( const uno::Type& aType ) throw ( lang::IllegalArgumentException )
      35             : {
      36           0 :     sal_Int16 msoType = office::MsoDocProperties::msoPropertyTypeString;
      37             : 
      38           0 :     switch ( aType.getTypeClass() )
      39             :     {
      40             :         case uno::TypeClass_BOOLEAN:
      41           0 :             msoType =  office::MsoDocProperties::msoPropertyTypeBoolean;
      42           0 :             break;
      43             :         case uno::TypeClass_FLOAT:
      44           0 :             msoType =  office::MsoDocProperties::msoPropertyTypeFloat;
      45           0 :             break;
      46             :         case uno::TypeClass_STRUCT: // Assume date
      47           0 :             msoType =  office::MsoDocProperties::msoPropertyTypeDate;
      48           0 :             break;
      49             :         case  uno::TypeClass_BYTE:
      50             :         case  uno::TypeClass_SHORT:
      51             :         case  uno::TypeClass_LONG:
      52             :         case  uno::TypeClass_HYPER:
      53           0 :             msoType =  office::MsoDocProperties::msoPropertyTypeNumber;
      54           0 :             break;
      55             :         default:
      56           0 :             throw lang::IllegalArgumentException();
      57             :     }
      58           0 :     return msoType;
      59             : }
      60             : 
      61             : class PropertGetSetHelper
      62             : {
      63             : protected:
      64             :     uno::Reference< frame::XModel > m_xModel;
      65             :     uno::Reference<document::XDocumentProperties> m_xDocProps;
      66             : public:
      67           0 :     explicit PropertGetSetHelper( const uno::Reference< frame::XModel >& xModel ):m_xModel( xModel )
      68             :     {
      69             :         uno::Reference<document::XDocumentPropertiesSupplier> const
      70           0 :             xDocPropSupp(m_xModel, uno::UNO_QUERY_THROW);
      71           0 :         m_xDocProps.set(xDocPropSupp->getDocumentProperties(),
      72           0 :                 uno::UNO_SET_THROW);
      73           0 :     }
      74           0 :     virtual ~PropertGetSetHelper() {}
      75             :     virtual uno::Any getPropertyValue( const OUString& rPropName ) = 0;
      76             :     virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) = 0;
      77           0 :     uno::Reference< beans::XPropertySet > getUserDefinedProperties() {
      78             :         return uno::Reference<beans::XPropertySet>(
      79           0 :                 m_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
      80             :     }
      81             : 
      82             : };
      83             : 
      84           0 : class BuiltinPropertyGetSetHelper : public PropertGetSetHelper
      85             : {
      86             : public:
      87           0 :     explicit BuiltinPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel )
      88             :     {
      89           0 :     }
      90           0 :     virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
      91             :     {
      92           0 :         if ( rPropName == "EditingDuration" )
      93             :         {
      94           0 :             sal_Int32 const nSecs = m_xDocProps->getEditingDuration();
      95           0 :             return uno::makeAny( nSecs/60 ); // minutes
      96             :         }
      97           0 :         else if ("Title" == rPropName)
      98             :         {
      99           0 :             return uno::makeAny(m_xDocProps->getTitle());
     100             :         }
     101           0 :         else if ("Subject" == rPropName)
     102             :         {
     103           0 :             return uno::makeAny(m_xDocProps->getSubject());
     104             :         }
     105           0 :         else if ("Author" == rPropName)
     106             :         {
     107           0 :             return uno::makeAny(m_xDocProps->getAuthor());
     108             :         }
     109           0 :         else if ("Keywords" == rPropName)
     110             :         {
     111           0 :             return uno::makeAny(m_xDocProps->getKeywords());
     112             :         }
     113           0 :         else if ("Description" == rPropName)
     114             :         {
     115           0 :             return uno::makeAny(m_xDocProps->getDescription());
     116             :         }
     117           0 :         else if ("Template" == rPropName)
     118             :         {
     119           0 :             return uno::makeAny(m_xDocProps->getTemplateName());
     120             :         }
     121           0 :         else if ("ModifiedBy" == rPropName)
     122             :         {
     123           0 :             return uno::makeAny(m_xDocProps->getModifiedBy());
     124             :         }
     125           0 :         else if ("Generator" == rPropName)
     126             :         {
     127           0 :             return uno::makeAny(m_xDocProps->getGenerator());
     128             :         }
     129           0 :         else if ("PrintDate" == rPropName)
     130             :         {
     131           0 :             return uno::makeAny(m_xDocProps->getPrintDate());
     132             :         }
     133           0 :         else if ("CreationDate" == rPropName)
     134             :         {
     135           0 :             return uno::makeAny(m_xDocProps->getCreationDate());
     136             :         }
     137           0 :         else if ("ModifyDate" == rPropName)
     138             :         {
     139           0 :             return uno::makeAny(m_xDocProps->getModificationDate());
     140             :         }
     141           0 :         else if ("AutoloadURL" == rPropName)
     142             :         {
     143           0 :             return uno::makeAny(m_xDocProps->getAutoloadURL());
     144             :         }
     145             :         else
     146             :         {
     147             :             // fall back to user-defined properties
     148           0 :             return getUserDefinedProperties()->getPropertyValue(rPropName);
     149             :         }
     150             :     }
     151           0 :     virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) SAL_OVERRIDE
     152             :     {
     153           0 :         if ("EditingDuration" == rPropName)
     154             :         {
     155           0 :             sal_Int32 nMins = 0;
     156           0 :             if (aValue >>= nMins)
     157             :             {
     158           0 :                 m_xDocProps->setEditingDuration(nMins * 60); // convert minutes
     159             :             }
     160             :         }
     161           0 :         else if ("Title" == rPropName)
     162             :         {
     163           0 :             OUString str;
     164           0 :             if (aValue >>= str)
     165             :             {
     166           0 :                 m_xDocProps->setTitle(str);
     167           0 :             }
     168             :         }
     169           0 :         else if ("Subject" == rPropName)
     170             :         {
     171           0 :             OUString str;
     172           0 :             if (aValue >>= str)
     173             :             {
     174           0 :                 m_xDocProps->setSubject(str);
     175           0 :             }
     176             :         }
     177           0 :         else if ("Author" == rPropName)
     178             :         {
     179           0 :             OUString str;
     180           0 :             if (aValue >>= str)
     181             :             {
     182           0 :                 m_xDocProps->setAuthor(str);
     183           0 :             }
     184             :         }
     185           0 :         else if ("Keywords" == rPropName)
     186             :         {
     187           0 :             uno::Sequence<OUString> keywords;
     188           0 :             if (aValue >>= keywords)
     189             :             {
     190           0 :                 m_xDocProps->setKeywords(keywords);
     191           0 :             }
     192             :         }
     193           0 :         else if ("Description" == rPropName)
     194             :         {
     195           0 :             OUString str;
     196           0 :             if (aValue >>= str)
     197             :             {
     198           0 :                 m_xDocProps->setDescription(str);
     199           0 :             }
     200             :         }
     201           0 :         else if ("Template" == rPropName)
     202             :         {
     203           0 :             OUString str;
     204           0 :             if (aValue >>= str)
     205             :             {
     206           0 :                 m_xDocProps->setTemplateName(str);
     207           0 :             }
     208             :         }
     209           0 :         else if ("ModifiedBy" == rPropName)
     210             :         {
     211           0 :             OUString str;
     212           0 :             if (aValue >>= str)
     213             :             {
     214           0 :                 m_xDocProps->setModifiedBy(str);
     215           0 :             }
     216             :         }
     217           0 :         else if ("Generator" == rPropName)
     218             :         {
     219           0 :             OUString str;
     220           0 :             if (aValue >>= str)
     221             :             {
     222           0 :                 return m_xDocProps->setGenerator(str);
     223           0 :             }
     224             :         }
     225           0 :         else if ("PrintDate" == rPropName)
     226             :         {
     227           0 :             util::DateTime dt;
     228           0 :             if (aValue >>= dt)
     229             :             {
     230           0 :                 m_xDocProps->setPrintDate(dt);
     231             :             }
     232             :         }
     233           0 :         else if ("CreationDate" == rPropName)
     234             :         {
     235           0 :             util::DateTime dt;
     236           0 :             if (aValue >>= dt)
     237             :             {
     238           0 :                 m_xDocProps->setCreationDate(dt);
     239             :             }
     240             :         }
     241           0 :         else if ("ModifyDate" == rPropName)
     242             :         {
     243           0 :             util::DateTime dt;
     244           0 :             if (aValue >>= dt)
     245             :             {
     246           0 :                 m_xDocProps->setModificationDate(dt);
     247             :             }
     248             :         }
     249           0 :         else if ("AutoloadURL" == rPropName)
     250             :         {
     251           0 :             OUString str;
     252           0 :             if (aValue >>= str)
     253             :             {
     254           0 :                 m_xDocProps->setAutoloadURL(str);
     255           0 :             }
     256             :         }
     257             :         else
     258             :         {
     259             :             // fall back to user-defined properties
     260           0 :             getUserDefinedProperties()->setPropertyValue(rPropName, aValue);
     261             :         }
     262             :     }
     263             : };
     264             : 
     265           0 : class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper
     266             : {
     267             : public:
     268           0 :     explicit CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel )
     269             :     {
     270           0 :     }
     271           0 :     virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
     272             :     {
     273           0 :         return getUserDefinedProperties()->getPropertyValue(rPropName);
     274             :     }
     275           0 :     virtual void setPropertyValue(
     276             :             const OUString& rPropName, const uno::Any& rValue) SAL_OVERRIDE
     277             :     {
     278           0 :         return getUserDefinedProperties()->setPropertyValue(rPropName, rValue);
     279             :     }
     280             : };
     281             : 
     282           0 : class StatisticPropertyGetSetHelper : public PropertGetSetHelper
     283             : {
     284             :     SwDocShell* mpDocShell;
     285             :     uno::Reference< beans::XPropertySet > mxModelProps;
     286             : public:
     287           0 :     explicit StatisticPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( NULL )
     288             :     {
     289           0 :             mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW );
     290           0 :             mpDocShell = word::getDocShell( xModel );
     291           0 :     }
     292           0 :     virtual uno::Any getPropertyValue( const OUString& rPropName ) SAL_OVERRIDE
     293             :     {
     294             :         try
     295             :         {
     296             :             // Characters, ParagraphCount & WordCount are available from
     297             :             // the model ( and additionally these also update the statics object )
     298           0 :             return mxModelProps->getPropertyValue( rPropName );
     299             :         }
     300           0 :         catch (const uno::Exception&)
     301             :         {
     302             :             OSL_TRACE("Got exception");
     303             :         }
     304           0 :         uno::Any aReturn;
     305           0 :         if ( rPropName == "LineCount" ) // special processing needed
     306             :         {
     307           0 :             if ( mpDocShell )
     308             :             {
     309           0 :                 SwFEShell* pFEShell = mpDocShell->GetFEShell();
     310           0 :                 if(pFEShell)
     311             :                 {
     312           0 :                     aReturn <<= pFEShell->GetLineCount(false);
     313             :                 }
     314             :             }
     315             :         }
     316             :         else
     317             :         {
     318             :             uno::Sequence< beans::NamedValue > const stats(
     319           0 :                 m_xDocProps->getDocumentStatistics());
     320             : 
     321           0 :             sal_Int32 nLen = stats.getLength();
     322           0 :             bool bFound = false;
     323           0 :             for ( sal_Int32 index = 0; index < nLen && !bFound ; ++index )
     324             :             {
     325           0 :                 if ( rPropName.equals( stats[ index ].Name ) )
     326             :                 {
     327           0 :                     aReturn = stats[ index ].Value;
     328           0 :                     bFound = true;
     329             :                 }
     330             :             }
     331           0 :             if ( !bFound )
     332           0 :                 throw uno::RuntimeException(); // bad Property
     333             :         }
     334           0 :         return aReturn;
     335             :     }
     336             : 
     337           0 :     virtual void setPropertyValue( const OUString& rPropName, const uno::Any& aValue ) SAL_OVERRIDE
     338             :     {
     339             :         uno::Sequence< beans::NamedValue > stats(
     340           0 :                 m_xDocProps->getDocumentStatistics());
     341             : 
     342           0 :         sal_Int32 nLen = stats.getLength();
     343           0 :         for ( sal_Int32 index = 0; index < nLen; ++index )
     344             :         {
     345           0 :             if ( rPropName.equals( stats[ index ].Name ) )
     346             :             {
     347           0 :                 stats[ index ].Value = aValue;
     348           0 :                 m_xDocProps->setDocumentStatistics(stats);
     349           0 :                 break;
     350             :             }
     351           0 :         }
     352           0 :     }
     353             : };
     354             : 
     355           0 : class DocPropInfo
     356             : {
     357             : public:
     358             :     OUString msMSODesc;
     359             :     OUString msOOOPropName;
     360             :     boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
     361             : 
     362           0 :     static DocPropInfo createDocPropInfo( const OUString& sDesc, const OUString& sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
     363             :     {
     364           0 :         DocPropInfo aItem;
     365           0 :         aItem.msMSODesc = sDesc;
     366           0 :         aItem.msOOOPropName = sPropName;
     367           0 :         aItem.mpPropGetSetHelper = rHelper;
     368           0 :         return aItem;
     369             :     }
     370             : 
     371           0 :     static DocPropInfo createDocPropInfo( const sal_Char* sDesc, const sal_Char* sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
     372             :     {
     373           0 :         return createDocPropInfo( OUString::createFromAscii( sDesc ), OUString::createFromAscii( sPropName ), rHelper );
     374             :     }
     375           0 :     uno::Any getValue()
     376             :     {
     377           0 :         if ( mpPropGetSetHelper.get() )
     378           0 :             return mpPropGetSetHelper->getPropertyValue( msOOOPropName );
     379           0 :         return uno::Any();
     380             :     }
     381           0 :     void setValue( const uno::Any& rValue )
     382             :     {
     383           0 :         if ( mpPropGetSetHelper.get() )
     384           0 :             mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue );
     385           0 :     }
     386           0 :     uno::Reference< beans::XPropertySet > getUserDefinedProperties()
     387             :     {
     388           0 :         uno::Reference< beans::XPropertySet > xProps;
     389           0 :         if ( mpPropGetSetHelper.get() )
     390           0 :             return mpPropGetSetHelper->getUserDefinedProperties();
     391           0 :         return xProps;
     392             :     }
     393             : };
     394             : 
     395             : typedef std::unordered_map< sal_Int32, DocPropInfo > MSOIndexToOODocPropInfo;
     396             : 
     397           0 : class BuiltInIndexHelper
     398             : {
     399             :     MSOIndexToOODocPropInfo m_docPropInfoMap;
     400             : 
     401             : public:
     402           0 :     explicit BuiltInIndexHelper( const uno::Reference< frame::XModel >& xModel )
     403           0 :     {
     404           0 :         boost::shared_ptr< PropertGetSetHelper > aStandardHelper( new BuiltinPropertyGetSetHelper( xModel ) );
     405           0 :         boost::shared_ptr< PropertGetSetHelper > aUsingStatsHelper( new StatisticPropertyGetSetHelper( xModel ) );
     406             : 
     407           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo( "Title", "Title", aStandardHelper );
     408           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo( "Subject", "Subject", aStandardHelper );
     409           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo( "Author", "Author", aStandardHelper );
     410           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo( "Keywords", "Keywords", aStandardHelper );
     411           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo( "Comments", "Description", aStandardHelper );
     412           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo( "Template", "Template", aStandardHelper );
     413           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo( "Last author", "ModifiedBy", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
     414           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo( "Revision number", "EditingCycles", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
     415           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo( "Application name", "Generator", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
     416           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo( "Last print date", "PrintDate", aStandardHelper ); // doesn't seem to exist - throw or return nothing ?
     417           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo( "Creation date", "CreationDate", aStandardHelper );
     418           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo( "Last save time", "ModifyDate", aStandardHelper );
     419           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo( "Total editing time", "EditingDuration", aStandardHelper ); // Not sure if this is correct
     420           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo( "Number of pages", "PageCount", aUsingStatsHelper ); // special handling required ?
     421           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo( "Number of words", "WordCount", aUsingStatsHelper ); // special handling require ?
     422           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo( "Number of characters", "CharacterCount", aUsingStatsHelper ); // special handling required ?
     423           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo( "Security", "", aStandardHelper ); // doesn't seem to exist
     424           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo( "Category", "Category", aStandardHelper ); // hacked in
     425           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo( "Format", "", aStandardHelper ); // doesn't seem to exist
     426           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo( "Manager", "Manager", aStandardHelper ); // hacked in
     427           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo( "Company", "Company", aStandardHelper ); // hacked in
     428           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo( "Number of bytes", "", aStandardHelper ); // doesn't seem to exist - size on disk exists ( for an already saved document ) perhaps it will do ( or we need something else )
     429           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo( "Number of lines", "LineCount", aUsingStatsHelper ); // special handling
     430           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo( "Number of paragraphs", "ParagraphCount", aUsingStatsHelper ); // special handling
     431           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo( "Number of slides", "" , aStandardHelper ); // doesn't seem to exist
     432           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo( "Number of notes", "", aStandardHelper ); // doesn't seem to exist
     433           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo("Number of hidden Slides", "", aStandardHelper  ); // doesn't seem to exist
     434           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo( "Number of multimedia clips", "", aStandardHelper ); // doesn't seem to exist
     435           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo( "Hyperlink base", "AutoloadURL", aStandardHelper );
     436           0 :         m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo( "Number of characters (with spaces)", "", aStandardHelper ); // doesn't seem to be supported
     437           0 :     }
     438             : 
     439           0 :     MSOIndexToOODocPropInfo& getDocPropInfoMap() { return m_docPropInfoMap; }
     440             : };
     441             : 
     442             : typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentProperty > SwVbaDocumentProperty_BASE;
     443             : 
     444           0 : class SwVbaBuiltInDocumentProperty : public SwVbaDocumentProperty_BASE
     445             : {
     446             : protected:
     447             :     DocPropInfo mPropInfo;
     448             : public:
     449             :     SwVbaBuiltInDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
     450             :     // XDocumentProperty
     451             :     virtual void SAL_CALL Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     452             :     virtual OUString SAL_CALL getName(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     453             :     virtual void SAL_CALL setName( const OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     454             :     virtual ::sal_Int8 SAL_CALL getType(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     455             :     virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     456             :     virtual sal_Bool SAL_CALL getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     457             :     virtual void SAL_CALL setLinkToContent( sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     458             :     virtual uno::Any SAL_CALL getValue(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     459             :     virtual void SAL_CALL setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     460             :     virtual OUString SAL_CALL getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     461             :     virtual void SAL_CALL setLinkSource( const OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     462             :     //XDefaultProperty
     463           0 :     virtual OUString SAL_CALL getDefaultPropertyName(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE { return OUString("Value"); }
     464             :     // XHelperInterface
     465             :     virtual OUString getServiceImplName() SAL_OVERRIDE;
     466             :     virtual uno::Sequence<OUString> getServiceNames() SAL_OVERRIDE;
     467             : };
     468             : 
     469           0 : class SwVbaCustomDocumentProperty : public SwVbaBuiltInDocumentProperty
     470             : {
     471             : public:
     472             : 
     473             :     SwVbaCustomDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo );
     474             : 
     475             :     virtual sal_Bool SAL_CALL getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     476             :     virtual void SAL_CALL setLinkToContent( sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     477             : 
     478             :     virtual OUString SAL_CALL getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     479             :     virtual void SAL_CALL setLinkSource( const OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     480             :     virtual void SAL_CALL Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     481             :     virtual void SAL_CALL setName( const OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     482             :     virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     483             : 
     484             : };
     485             : 
     486           0 : SwVbaCustomDocumentProperty::SwVbaCustomDocumentProperty(  const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaBuiltInDocumentProperty( xParent, xContext, rInfo )
     487             : {
     488           0 : }
     489             : 
     490             : sal_Bool
     491           0 : SwVbaCustomDocumentProperty::getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     492             : {
     493             :     // #FIXME we need to store the link content somewhere
     494           0 :     return sal_False;
     495             : }
     496             : 
     497             : void
     498           0 : SwVbaCustomDocumentProperty::setLinkToContent( sal_Bool /*bLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     499             : {
     500           0 : }
     501             : 
     502             : OUString
     503           0 : SwVbaCustomDocumentProperty::getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     504             : {
     505             :     // #FIXME we need to store the link content somewhere
     506           0 :     return OUString();
     507             : }
     508             : 
     509             : void
     510           0 : SwVbaCustomDocumentProperty::setLinkSource( const OUString& /*rsLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     511             : {
     512             :     // #FIXME we need to store the link source somewhere
     513           0 : }
     514             : 
     515             : void SAL_CALL
     516           0 : SwVbaCustomDocumentProperty::setName( const OUString& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     517             : {
     518             :     // setName on existing property ?
     519             :     // #FIXME
     520             :     // do we need to delete existing property and create a new one?
     521           0 : }
     522             : 
     523             : void SAL_CALL
     524           0 : SwVbaCustomDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     525             : {
     526             :     // setType, do we need to do a conversion?
     527             :     // #FIXME the underlying value needs to be changed to the new type
     528           0 : }
     529             : 
     530             : void SAL_CALL
     531           0 : SwVbaCustomDocumentProperty::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     532             : {
     533             :     uno::Reference< beans::XPropertyContainer > xContainer(
     534           0 :             mPropInfo.getUserDefinedProperties(), uno::UNO_QUERY_THROW);
     535           0 :     xContainer->removeProperty( getName() );
     536           0 : }
     537             : 
     538           0 : SwVbaBuiltInDocumentProperty::SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaDocumentProperty_BASE( xParent, xContext ), mPropInfo( rInfo )
     539             : {
     540           0 : }
     541             : 
     542             : void SAL_CALL
     543           0 : SwVbaBuiltInDocumentProperty::Delete(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     544             : {
     545             :     // not valid for Builtin
     546           0 :     throw uno::RuntimeException();
     547             : }
     548             : 
     549             : OUString SAL_CALL
     550           0 : SwVbaBuiltInDocumentProperty::getName(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     551             : {
     552           0 :     return mPropInfo.msMSODesc;
     553             : }
     554             : 
     555             : void SAL_CALL
     556           0 : SwVbaBuiltInDocumentProperty::setName( const OUString& ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     557             : {
     558             :     // not valid for Builtin
     559           0 :     throw uno::RuntimeException();
     560             : }
     561             : 
     562             : ::sal_Int8 SAL_CALL
     563           0 : SwVbaBuiltInDocumentProperty::getType(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     564             : {
     565           0 :     return lcl_toMSOPropType( getValue().getValueType() );
     566             : }
     567             : 
     568             : void SAL_CALL
     569           0 : SwVbaBuiltInDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     570             : {
     571             :     // not valid for Builtin
     572           0 :     throw uno::RuntimeException();
     573             : }
     574             : 
     575             : sal_Bool SAL_CALL
     576           0 : SwVbaBuiltInDocumentProperty::getLinkToContent(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     577             : {
     578           0 :     return sal_False; // built-in always false
     579             : }
     580             : 
     581             : void SAL_CALL
     582           0 : SwVbaBuiltInDocumentProperty::setLinkToContent( sal_Bool /*LinkToContent*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     583             : {
     584             :     // not valid for Builtin
     585           0 :     throw uno::RuntimeException();
     586             : }
     587             : 
     588             : uno::Any SAL_CALL
     589           0 : SwVbaBuiltInDocumentProperty::getValue(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     590             : {
     591           0 :     uno::Any aRet = mPropInfo.getValue();
     592           0 :     if ( !aRet.hasValue() )
     593           0 :         throw uno::RuntimeException();
     594           0 :     return aRet;
     595             : }
     596             : 
     597             : void SAL_CALL
     598           0 : SwVbaBuiltInDocumentProperty::setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     599             : {
     600           0 :     mPropInfo.setValue( Value );
     601           0 : }
     602             : 
     603             : OUString SAL_CALL
     604           0 : SwVbaBuiltInDocumentProperty::getLinkSource(  ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     605             : {
     606             :     // not valid for Builtin
     607           0 :     throw uno::RuntimeException();
     608             : }
     609             : 
     610             : void SAL_CALL
     611           0 : SwVbaBuiltInDocumentProperty::setLinkSource( const OUString& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     612             : {
     613             :     // not valid for Builtin
     614           0 :     throw uno::RuntimeException();
     615             : }
     616             : 
     617             : OUString
     618           0 : SwVbaBuiltInDocumentProperty::getServiceImplName()
     619             : {
     620           0 :     return OUString("SwVbaBuiltinDocumentProperty");
     621             : }
     622             : 
     623             : uno::Sequence<OUString>
     624           0 : SwVbaBuiltInDocumentProperty::getServiceNames()
     625             : {
     626           0 :     static uno::Sequence< OUString > aServiceNames;
     627           0 :     if ( aServiceNames.getLength() == 0 )
     628             :     {
     629           0 :         aServiceNames.realloc( 1 );
     630           0 :         aServiceNames[ 0 ] = "ooo.vba.word.DocumentProperty";
     631             :     }
     632           0 :     return aServiceNames;
     633             : }
     634             : typedef ::cppu::WeakImplHelper< com::sun::star::container::XIndexAccess
     635             :         ,com::sun::star::container::XNameAccess
     636             :         ,com::sun::star::container::XEnumerationAccess
     637             :         > PropertiesImpl_BASE;
     638             : 
     639             : typedef std::unordered_map< sal_Int32, uno::Reference< XDocumentProperty > > DocProps;
     640             : 
     641             : typedef ::cppu::WeakImplHelper< com::sun::star::container::XEnumeration > DocPropEnumeration_BASE;
     642           0 : class DocPropEnumeration : public DocPropEnumeration_BASE
     643             : {
     644             :     DocProps mDocProps;
     645             :     DocProps::iterator mIt;
     646             : public:
     647             : 
     648           0 :     explicit DocPropEnumeration( const DocProps& rProps ) : mDocProps( rProps ), mIt( mDocProps.begin() ) {}
     649           0 :     virtual sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     650             :     {
     651           0 :         return mIt != mDocProps.end();
     652             :     }
     653           0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     654             :     {
     655           0 :         if ( !hasMoreElements() )
     656           0 :             throw container::NoSuchElementException();
     657           0 :         return uno::makeAny( mIt++->second );
     658             :     }
     659             : };
     660             : 
     661             : typedef std::unordered_map< OUString, uno::Reference< XDocumentProperty >, OUStringHash, ::std::equal_to< OUString > > DocPropsByName;
     662             : 
     663           0 : class BuiltInPropertiesImpl : public PropertiesImpl_BASE
     664             : {
     665             : protected:
     666             : 
     667             :     uno::Reference< XHelperInterface > m_xParent;
     668             :     uno::Reference< uno::XComponentContext > m_xContext;
     669             :     uno::Reference< frame::XModel > m_xModel;
     670             : 
     671             :     DocProps mDocProps;
     672             :     DocPropsByName mNamedDocProps;
     673             : 
     674             :     public:
     675           0 :     BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
     676             :     {
     677           0 :         BuiltInIndexHelper builtIns( m_xModel );
     678           0 :         for ( sal_Int32 index = word::WdBuiltInProperty::wdPropertyTitle; index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++index )
     679             :         {
     680           0 :             mDocProps[ index ] = new SwVbaBuiltInDocumentProperty( xParent, xContext, builtIns.getDocPropInfoMap()[ index ] );
     681           0 :             mNamedDocProps[ mDocProps[ index ]->getName() ] = mDocProps[ index ];
     682           0 :         }
     683           0 :     }
     684             : // XIndexAccess
     685           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     686             :     {
     687           0 :         return mDocProps.size();
     688             :     }
     689           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
     690             :     {
     691             :         // correct the correct by the base class for 1 based indices
     692           0 :         DocProps::iterator it = mDocProps.find( ++Index );
     693           0 :         if ( it == mDocProps.end() )
     694           0 :             throw lang::IndexOutOfBoundsException();
     695           0 :         return uno::makeAny( it->second  );
     696             :     }
     697           0 :     virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     698             :     {
     699           0 :         if ( !hasByName( aName ) )
     700           0 :             throw container::NoSuchElementException();
     701           0 :         DocPropsByName::iterator it = mNamedDocProps.find( aName );
     702           0 :         return uno::Any( it->second );
     703             : 
     704             :     }
     705           0 :     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     706             :     {
     707           0 :         uno::Sequence< OUString > aNames( getCount() );
     708           0 :         OUString* pName = aNames.getArray();
     709           0 :         DocPropsByName::iterator it_end = mNamedDocProps.end();
     710           0 :         for(  DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName )
     711           0 :            *pName = it->first;
     712           0 :         return aNames;
     713             :     }
     714             : 
     715           0 :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     716             :     {
     717           0 :         DocPropsByName::iterator it = mNamedDocProps.find( aName );
     718           0 :         if ( it == mNamedDocProps.end() )
     719           0 :             return sal_False;
     720           0 :         return sal_True;
     721             :     }
     722             : // XElementAccess
     723           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     724             :     {
     725           0 :         return  cppu::UnoType<XDocumentProperty>::get();
     726             :     }
     727           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     728             :     {
     729           0 :         return !mDocProps.empty();
     730             :     }
     731           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     732             :     {
     733           0 :         return new DocPropEnumeration( mDocProps );
     734             :     }
     735             : };
     736             : 
     737           0 : SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaDocumentproperties_BASE( xParent, xContext,  uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) ), m_xModel( xModel )
     738             : {
     739           0 : }
     740             : 
     741             : uno::Reference< XDocumentProperty > SAL_CALL
     742           0 : SwVbaBuiltinDocumentProperties::Add( const OUString& /*Name*/, sal_Bool /*LinkToContent*/, ::sal_Int8 /*Type*/, const uno::Any& /*value*/, const uno::Any& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     743             : {
     744           0 :     throw uno::RuntimeException( "not supported for Builtin properties" );
     745             : }
     746             : 
     747             : // XEnumerationAccess
     748             : uno::Type SAL_CALL
     749           0 : SwVbaBuiltinDocumentProperties::getElementType() throw (uno::RuntimeException)
     750             : {
     751           0 :     return  cppu::UnoType<XDocumentProperty>::get();
     752             : }
     753             : 
     754             : uno::Reference< container::XEnumeration > SAL_CALL
     755           0 : SwVbaBuiltinDocumentProperties::createEnumeration() throw (uno::RuntimeException)
     756             : {
     757           0 :     uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     758           0 :     return xEnumAccess->createEnumeration();
     759             : }
     760             : 
     761             : // ScVbaCollectionBaseImpl
     762             : uno::Any
     763           0 : SwVbaBuiltinDocumentProperties::createCollectionObject( const uno::Any& aSource )
     764             : {
     765             :     // pass through
     766           0 :     return aSource;
     767             : }
     768             : 
     769             : // XHelperInterface
     770             : OUString
     771           0 : SwVbaBuiltinDocumentProperties::getServiceImplName()
     772             : {
     773           0 :     return OUString("SwVbaBuiltinDocumentProperties");
     774             : }
     775             : 
     776             : uno::Sequence<OUString>
     777           0 : SwVbaBuiltinDocumentProperties::getServiceNames()
     778             : {
     779           0 :     static uno::Sequence< OUString > aServiceNames;
     780           0 :     if ( aServiceNames.getLength() == 0 )
     781             :     {
     782           0 :         aServiceNames.realloc( 1 );
     783           0 :         aServiceNames[ 0 ] = "ooo.vba.word.DocumentProperties";
     784             :     }
     785           0 :     return aServiceNames;
     786             : }
     787             : 
     788           0 : class CustomPropertiesImpl : public PropertiesImpl_BASE
     789             : {
     790             :     uno::Reference< XHelperInterface > m_xParent;
     791             :     uno::Reference< uno::XComponentContext > m_xContext;
     792             :     uno::Reference< frame::XModel > m_xModel;
     793             :     uno::Reference< beans::XPropertySet > mxUserDefinedProp;
     794             :     boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper;
     795             : public:
     796           0 :     CustomPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel )
     797             :     {
     798             :         // suck in the document( custom ) properties
     799           0 :         mpPropGetSetHelper.reset( new CustomPropertyGetSetHelper( m_xModel ) );
     800             :         mxUserDefinedProp.set(mpPropGetSetHelper->getUserDefinedProperties(),
     801           0 :                 uno::UNO_SET_THROW);
     802           0 :     };
     803             :     // XIndexAccess
     804           0 :     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     805             :     {
     806           0 :         return mxUserDefinedProp->getPropertySetInfo()->getProperties().getLength();
     807             :     }
     808             : 
     809           0 :     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, std::exception ) SAL_OVERRIDE
     810             :     {
     811           0 :         uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
     812           0 :         if ( Index >= aProps.getLength() )
     813           0 :             throw lang::IndexOutOfBoundsException();
     814             :         // How to determine type e.g Date? ( com.sun.star.util.DateTime )
     815           0 :         DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aProps[ Index ].Name, aProps[ Index ].Name, mpPropGetSetHelper );
     816           0 :         return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
     817             :     }
     818             : 
     819           0 :     virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE
     820             :     {
     821           0 :         if ( !hasByName( aName ) )
     822           0 :             throw container::NoSuchElementException();
     823             : 
     824           0 :         DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aName, aName, mpPropGetSetHelper );
     825           0 :         return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) );
     826             :     }
     827             : 
     828           0 :     virtual uno::Sequence< OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     829             :     {
     830           0 :         uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties();
     831           0 :         uno::Sequence< OUString > aNames( aProps.getLength() );
     832           0 :         OUString* pString = aNames.getArray();
     833           0 :         OUString* pEnd = ( pString + aNames.getLength() );
     834           0 :         beans::Property* pProp = aProps.getArray();
     835           0 :         for ( ; pString != pEnd; ++pString, ++pProp )
     836           0 :             *pString = pProp->Name;
     837           0 :         return aNames;
     838             :     }
     839             : 
     840           0 :     virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     841             :     {
     842             :         OSL_TRACE("hasByName(%s) returns %d", OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ) );
     843           0 :         return mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName );
     844             :     }
     845             : 
     846             :     // XElementAccess
     847           0 :     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     848             :     {
     849           0 :         return  cppu::UnoType<XDocumentProperty>::get();
     850             :     }
     851             : 
     852           0 :     virtual sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     853             :     {
     854           0 :         return getCount() > 0;
     855             :     }
     856             : 
     857           0 :     virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration(  ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
     858             :     {
     859             :         // create a map of properties ( the key doesn't matter )
     860             :         OSL_TRACE("Creating an enumeration");
     861           0 :         sal_Int32 key = 0;
     862           0 :         sal_Int32 nElem =  getCount();
     863           0 :         DocProps simpleDocPropSnapShot;
     864           0 :         for ( ; key < nElem; ++key )
     865           0 :              simpleDocPropSnapShot[ key ].set( getByIndex( key ), uno::UNO_QUERY_THROW );
     866             :         OSL_TRACE("After creating the enumeration");
     867           0 :         return  new DocPropEnumeration( simpleDocPropSnapShot );
     868             :     }
     869             : 
     870           0 :     void addProp( const OUString& Name, ::sal_Int8 /*Type*/, const uno::Any& Value )
     871             :     {
     872           0 :         sal_Int16 attributes = 128;
     873           0 :         uno::Reference< beans::XPropertyContainer > xContainer( mxUserDefinedProp, uno::UNO_QUERY_THROW );
     874             :         // TODO fixme, perform the necessary Type Value conversions
     875           0 :         xContainer->addProperty( Name, attributes, Value );
     876           0 :     }
     877             : 
     878             : };
     879             : 
     880           0 : SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel )
     881             : {
     882             :     // replace the m_xIndexAccess implementation ( we need a virtual init )
     883           0 :     m_xIndexAccess.set( new CustomPropertiesImpl( xParent, xContext, xModel ) );
     884           0 :     m_xNameAccess.set( m_xIndexAccess, uno::UNO_QUERY_THROW );
     885           0 : }
     886             : 
     887             : uno::Reference< XDocumentProperty > SAL_CALL
     888           0 : SwVbaCustomDocumentProperties::Add( const OUString& Name, sal_Bool LinkToContent, ::sal_Int8 Type, const uno::Any& Value, const uno::Any& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException, std::exception)
     889             : {
     890           0 :     CustomPropertiesImpl* pCustomProps = dynamic_cast< CustomPropertiesImpl* > ( m_xIndexAccess.get() );
     891           0 :     uno::Reference< XDocumentProperty > xDocProp;
     892           0 :     if ( pCustomProps )
     893             :     {
     894           0 :         OUString sLinkSource;
     895           0 :         pCustomProps->addProp( Name, Type, Value );
     896             : 
     897           0 :         xDocProp.set( m_xNameAccess->getByName( Name ), uno::UNO_QUERY_THROW );
     898           0 :         xDocProp->setLinkToContent( LinkToContent );
     899             : 
     900           0 :         if ( LinkSource >>= sLinkSource )
     901           0 :            xDocProp->setLinkSource( sLinkSource );
     902             :     }
     903           0 :     return xDocProp;
     904             : }
     905             : 
     906             : // XHelperInterface
     907             : OUString
     908           0 : SwVbaCustomDocumentProperties::getServiceImplName()
     909             : {
     910           0 :     return OUString("SwVbaCustomDocumentProperties");
     911           3 : }
     912             : 
     913             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11