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

Generated by: LCOV version 1.10