LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbadocuments.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 55 0.0 %
Date: 2012-08-25 Functions: 0 14 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 108 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #include <comphelper/processfactory.hxx>
      29                 :            : 
      30                 :            : #include <cppuhelper/implbase1.hxx>
      31                 :            : #include <cppuhelper/implbase3.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/frame/XDesktop.hpp>
      34                 :            : #include <com/sun/star/text/XTextDocument.hpp>
      35                 :            : #include <com/sun/star/container/XEnumerationAccess.hpp>
      36                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      37                 :            : #include <com/sun/star/lang/XComponent.hpp>
      38                 :            : #include <com/sun/star/frame/XModel.hpp>
      39                 :            : #include <com/sun/star/frame/XFrame.hpp>
      40                 :            : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      41                 :            : #include <com/sun/star/util/XModifiable.hpp>
      42                 :            : #include <com/sun/star/frame/XStorable.hpp>
      43                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      44                 :            : #include <com/sun/star/beans/PropertyVetoException.hpp>
      45                 :            : #include <com/sun/star/util/XCloseable.hpp>
      46                 :            : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      47                 :            : #include <com/sun/star/document/XTypeDetection.hpp>
      48                 :            : #include <com/sun/star/uri/XUriReference.hpp>
      49                 :            : #include <com/sun/star/uri/XUriReferenceFactory.hpp>
      50                 :            : 
      51                 :            : #include <sfx2/objsh.hxx>
      52                 :            : #include <tools/urlobj.hxx>
      53                 :            : 
      54                 :            : #include "vbaglobals.hxx"
      55                 :            : #include "vbadocument.hxx"
      56                 :            : #include "vbadocuments.hxx"
      57                 :            : #include <vbahelper/vbahelper.hxx>
      58                 :            : 
      59                 :            : #include <boost/unordered_map.hpp>
      60                 :            : #include <osl/file.hxx>
      61                 :            : using namespace ::ooo::vba;
      62                 :            : using namespace ::com::sun::star;
      63                 :            : 
      64                 :            : static uno::Any
      65                 :          0 : getDocument( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextDocument > &xDoc, const uno::Any& aApplication )
      66                 :            : {
      67                 :            :     // FIXME: fine as long as SwVbaDocument is stateless ...
      68         [ #  # ]:          0 :     uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
      69         [ #  # ]:          0 :     if( !xModel.is() )
      70                 :          0 :         return uno::Any();
      71                 :            : 
      72 [ #  # ][ #  # ]:          0 :     SwVbaDocument *pWb = new SwVbaDocument(  uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel );
      73 [ #  # ][ #  # ]:          0 :     return uno::Any( uno::Reference< word::XDocument > (pWb) );
                 [ #  # ]
      74                 :            : }
      75                 :            : 
      76         [ #  # ]:          0 : class DocumentEnumImpl : public EnumerationHelperImpl
      77                 :            : {
      78                 :            :     uno::Any m_aApplication;
      79                 :            : public:
      80                 :          0 :     DocumentEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {}
      81                 :            : 
      82                 :          0 :     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
      83                 :            :     {
      84 [ #  # ][ #  # ]:          0 :         uno::Reference< text::XTextDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
                 [ #  # ]
      85         [ #  # ]:          0 :         return getDocument( m_xContext, xDoc, m_aApplication );
      86                 :            :     }
      87                 :            : };
      88                 :            : 
      89         [ #  # ]:          0 : SwVbaDocuments::SwVbaDocuments( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : SwVbaDocuments_BASE( xParent, xContext, VbaDocumentsBase::WORD_DOCUMENT )
      90                 :            : {
      91                 :          0 : }
      92                 :            : // XEnumerationAccess
      93                 :            : uno::Type
      94                 :          0 : SwVbaDocuments::getElementType() throw (uno::RuntimeException)
      95                 :            : {
      96                 :          0 :     return word::XDocument::static_type(0);
      97                 :            : }
      98                 :            : uno::Reference< container::XEnumeration >
      99                 :          0 : SwVbaDocuments::createEnumeration() throw (uno::RuntimeException)
     100                 :            : {
     101                 :            :     // #FIXME its possible the DocumentEnumImpl here doens't reflect
     102                 :            :     // the state of this object ( although it should ) would be
     103                 :            :     // safer to create an enumeration based on this objects state
     104                 :            :     // rather than one effectively based of the desktop component
     105         [ #  # ]:          0 :     uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
     106 [ #  # ][ #  # ]:          0 :     return new DocumentEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     107                 :            : }
     108                 :            : 
     109                 :            : uno::Any
     110                 :          0 : SwVbaDocuments::createCollectionObject( const uno::Any& aSource )
     111                 :            : {
     112         [ #  # ]:          0 :     uno::Reference< text::XTextDocument > xDoc( aSource, uno::UNO_QUERY_THROW );
     113 [ #  # ][ #  # ]:          0 :     return getDocument( mxContext, xDoc, Application() );
     114                 :            : }
     115                 :            : 
     116                 :            : uno::Any SAL_CALL
     117                 :          0 : SwVbaDocuments::Add( const uno::Any& Template, const uno::Any& /*NewTemplate*/, const uno::Any& /*DocumentType*/, const uno::Any& /*Visible*/ ) throw (uno::RuntimeException)
     118                 :            : {
     119                 :          0 :     rtl::OUString sFileName;
     120 [ #  # ][ #  # ]:          0 :     if( Template.hasValue() && ( Template >>= sFileName ) )
                 [ #  # ]
     121                 :            :     {
     122         [ #  # ]:          0 :         return  Open( sFileName, uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any());
     123                 :            :     }
     124 [ #  # ][ #  # ]:          0 :     uno::Reference <text::XTextDocument> xTextDoc( createDocument() , uno::UNO_QUERY_THROW );
     125                 :            : 
     126         [ #  # ]:          0 :     if( xTextDoc.is() )
     127 [ #  # ][ #  # ]:          0 :         return getDocument( mxContext, xTextDoc, Application() );
     128                 :          0 :     return uno::Any();
     129                 :            : }
     130                 :            : 
     131                 :            : // #TODO# #FIXME# can any of the unused params below be used?
     132                 :            : void SAL_CALL
     133                 :          0 : SwVbaDocuments::Close( const uno::Any& /*SaveChanges*/, const uno::Any& /*OriginalFormat*/, const uno::Any& /*RouteDocument*/ ) throw (uno::RuntimeException)
     134                 :            : {
     135                 :          0 :     closeDocuments();
     136                 :          0 : }
     137                 :            : 
     138                 :            : // #TODO# #FIXME# can any of the unused params below be used?
     139                 :            : uno::Any SAL_CALL
     140                 :          0 : SwVbaDocuments::Open( const ::rtl::OUString& Filename, const uno::Any& /*ConfirmConversions*/, const uno::Any& ReadOnly, const uno::Any& /*AddToRecentFiles*/, const uno::Any& /*PasswordDocument*/, const uno::Any& /*PasswordTemplate*/, const uno::Any& /*Revert*/, const uno::Any& /*WritePasswordDocument*/, const uno::Any& /*WritePasswordTemplate*/, const uno::Any& /*Format*/, const uno::Any& /*Encoding*/, const uno::Any& /*Visible*/, const uno::Any& /*OpenAndRepair*/, const uno::Any& /*DocumentDirection*/, const uno::Any& /*NoEncodingDialog*/, const uno::Any& /*XMLTransform*/ ) throw (uno::RuntimeException)
     141                 :            : {
     142                 :            :     // we need to detect if this is a URL, if not then assume its a file path
     143                 :          0 :     rtl::OUString aURL;
     144         [ #  # ]:          0 :     INetURLObject aObj;
     145         [ #  # ]:          0 :     aObj.SetURL( Filename );
     146                 :          0 :     bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
     147         [ #  # ]:          0 :     if ( bIsURL )
     148                 :          0 :         aURL = Filename;
     149                 :            :     else
     150         [ #  # ]:          0 :         osl::FileBase::getFileURLFromSystemPath( Filename, aURL );
     151                 :            : 
     152         [ #  # ]:          0 :     uno::Sequence< beans::PropertyValue > sProps(0);
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :     uno::Reference <text::XTextDocument> xSpreadDoc( openDocument( Filename, ReadOnly, sProps ), uno::UNO_QUERY_THROW );
     155 [ #  # ][ #  # ]:          0 :     uno::Any aRet = getDocument( mxContext, xSpreadDoc, Application() );
     156         [ #  # ]:          0 :     uno::Reference< word::XDocument > xDocument( aRet, uno::UNO_QUERY );
     157         [ #  # ]:          0 :     if ( xDocument.is() )
     158 [ #  # ][ #  # ]:          0 :         xDocument->Activate();
     159 [ #  # ][ #  # ]:          0 :     return aRet;
     160                 :            : }
     161                 :            : 
     162                 :            : rtl::OUString
     163                 :          0 : SwVbaDocuments::getServiceImplName()
     164                 :            : {
     165                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaDocuments"));
     166                 :            : }
     167                 :            : 
     168                 :            : uno::Sequence<rtl::OUString>
     169                 :          0 : SwVbaDocuments::getServiceNames()
     170                 :            : {
     171 [ #  # ][ #  # ]:          0 :     static uno::Sequence< rtl::OUString > sNames;
         [ #  # ][ #  # ]
     172         [ #  # ]:          0 :     if ( sNames.getLength() == 0 )
     173                 :            :     {
     174                 :          0 :         sNames.realloc( 1 );
     175         [ #  # ]:          0 :         sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Documents") );
     176                 :            :     }
     177                 :          0 :     return sNames;
     178                 :            : }
     179                 :            : 
     180                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10