LCOV - code coverage report
Current view: top level - svx/inc/svx - xmlgrhlp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : 
      29                 :            : #ifndef _XMLGRHLP_HXX
      30                 :            : #define _XMLGRHLP_HXX
      31                 :            : 
      32                 :            : #include <cppuhelper/compbase2.hxx>
      33                 :            : #include <osl/mutex.hxx>
      34                 :            : #include <svtools/grfmgr.hxx>
      35                 :            : #include <vector>
      36                 :            : #include <set>
      37                 :            : #include <utility>
      38                 :            : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
      39                 :            : #include <com/sun/star/document/XBinaryStreamResolver.hpp>
      40                 :            : #include <com/sun/star/embed/XStorage.hpp>
      41                 :            : #include "svx/svxdllapi.h"
      42                 :            : 
      43                 :            : // ----------------------
      44                 :            : // - SvXMLGraphicHelper -
      45                 :            : // ----------------------
      46                 :            : 
      47                 :            : enum SvXMLGraphicHelperMode
      48                 :            : {
      49                 :            :     GRAPHICHELPER_MODE_READ = 0,
      50                 :            :     GRAPHICHELPER_MODE_WRITE = 1
      51                 :            : };
      52                 :            : 
      53                 :            : // ----------------------
      54                 :            : // - SvXMLGraphicHelper -
      55                 :            : // ----------------------
      56                 :        360 : struct SvxGraphicHelperStream_Impl
      57                 :            : {
      58                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage > xStorage;
      59                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > xStream;
      60                 :            : };
      61                 :            : 
      62                 :            : class SVX_DLLPUBLIC SvXMLGraphicHelper : public ::cppu::WeakComponentImplHelper2<   ::com::sun::star::document::XGraphicObjectResolver,
      63                 :            :                                                                     ::com::sun::star::document::XBinaryStreamResolver >
      64                 :            : {
      65                 :            : private:
      66                 :            : 
      67                 :            :     typedef ::std::pair< ::rtl::OUString, ::rtl::OUString >                                             URLPair;
      68                 :            :     typedef ::std::vector< URLPair >                                                                    URLPairVector;
      69                 :            :     typedef ::std::vector< GraphicObject >                                                              GraphicObjectVector;
      70                 :            :     typedef ::std::set< ::rtl::OUString >                                                               URLSet;
      71                 :            :     typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > >    GraphicOutputStreamVector;
      72                 :            : 
      73                 :            :     ::osl::Mutex                maMutex;
      74                 :            :     ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage > mxRootStorage;
      75                 :            :     ::rtl::OUString             maCurStorageName;
      76                 :            :     URLPairVector               maGrfURLs;
      77                 :            :     GraphicObjectVector         maGrfObjs;
      78                 :            :     GraphicOutputStreamVector   maGrfStms;
      79                 :            :     URLSet                      maURLSet;
      80                 :            :     SvXMLGraphicHelperMode      meCreateMode;
      81                 :            :     sal_Bool                    mbDirect;
      82                 :            : 
      83                 :            :     SVX_DLLPRIVATE sal_Bool                 ImplGetStreamNames( const ::rtl::OUString& rURLStr,
      84                 :            :                                                     ::rtl::OUString& rPictureStorageName,
      85                 :            :                                                     ::rtl::OUString& rPictureStreamName );
      86                 :            :     SVX_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage > ImplGetGraphicStorage( const ::rtl::OUString& rPictureStorageName );
      87                 :            :     SVX_DLLPRIVATE SvxGraphicHelperStream_Impl ImplGetGraphicStream( const ::rtl::OUString& rPictureStorageName,
      88                 :            :                                                       const ::rtl::OUString& rPictureStreamName,
      89                 :            :                                                       sal_Bool bTruncate );
      90                 :            :     SVX_DLLPRIVATE String                      ImplGetGraphicMimeType( const String& rFileName ) const;
      91                 :            :     SVX_DLLPRIVATE Graphic                      ImplReadGraphic( const ::rtl::OUString& rPictureStorageName,
      92                 :            :                                                  const ::rtl::OUString& rPictureStreamName );
      93                 :            :     SVX_DLLPRIVATE sal_Bool                 ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName,
      94                 :            :                                                   const ::rtl::OUString& rPictureStreamName,
      95                 :            :                                                   const ::rtl::OUString& rGraphicId,
      96                 :            :                                                   bool bUseGfxLink );
      97                 :            :     SVX_DLLPRIVATE void                     ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, sal_uInt32 nInsertPos, rtl::OUString& rRequestedFileName );
      98                 :            : 
      99                 :            : protected:
     100                 :            :                                 SvXMLGraphicHelper();
     101                 :            :                                 ~SvXMLGraphicHelper();
     102                 :            :     void                        Init( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage >& xXMLStorage,
     103                 :            :                                       SvXMLGraphicHelperMode eCreateMode,
     104                 :            :                                       sal_Bool bDirect );
     105                 :            : 
     106                 :            :     virtual void SAL_CALL       disposing();
     107                 :            : 
     108                 :            : public:
     109                 :            :                                 SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode );
     110                 :            : 
     111                 :            :     static SvXMLGraphicHelper*  Create( const ::com::sun::star::uno::Reference < ::com::sun::star::embed::XStorage >& rXMLStorage,
     112                 :            :                                         SvXMLGraphicHelperMode eCreateMode,
     113                 :            :                                         sal_Bool bDirect = sal_True );
     114                 :            :     static SvXMLGraphicHelper*  Create( SvXMLGraphicHelperMode eCreateMode );
     115                 :            : 
     116                 :            :     static void                 Destroy( SvXMLGraphicHelper* pSvXMLGraphicHelper );
     117                 :            : 
     118                 :            : public:
     119                 :            : 
     120                 :            :     // XGraphicObjectResolver
     121                 :            :     virtual ::rtl::OUString SAL_CALL resolveGraphicObjectURL( const ::rtl::OUString& aURL ) throw(::com::sun::star::uno::RuntimeException);
     122                 :            : 
     123                 :            :     // XBinaryStreamResolver
     124                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( const ::rtl::OUString& rURL ) throw (::com::sun::star::uno::RuntimeException);
     125                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL createOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
     126                 :            :     virtual ::rtl::OUString SAL_CALL resolveOutputStream( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxBinaryStream ) throw (::com::sun::star::uno::RuntimeException);
     127                 :            : };
     128                 :            : 
     129                 :            : 
     130                 :            : // for instantiation via service manager
     131                 :            : namespace svx
     132                 :            : {
     133                 :            : /** Create this with createInstanceWithArguments. service name
     134                 :            :     "com.sun.star.comp.Svx.GraphicImportHelper", one argument which is the
     135                 :            :     XStorage.  Without arguments no helper class is created.  With an empty
     136                 :            :     argument the helper class is created and initialized like in the CTOR to
     137                 :            :     SvXMLGraphicHelper that only gets the create mode.
     138                 :            : 
     139                 :            :     You should call dispose after you no longer need this component.
     140                 :            : 
     141                 :            :     uses eCreateMode == GRAPHICHELPER_MODE_READ, bDirect == sal_True in
     142                 :            :     SvXMLGraphicHelper
     143                 :            :  */
     144                 :            : SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvXMLGraphicImportHelper_createInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( ::com::sun::star::uno::Exception );
     145                 :            : SVX_DLLPUBLIC ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicImportHelper_getSupportedServiceNames() throw();
     146                 :            : SVX_DLLPUBLIC ::rtl::OUString SAL_CALL SvXMLGraphicImportHelper_getImplementationName() throw();
     147                 :            : 
     148                 :            : /** Create this with createInstanceWithArguments. service name
     149                 :            :     "com.sun.star.comp.Svx.GraphicExportHelper", one argument which is the
     150                 :            :     XStorage.  Without arguments no helper class is created.  With an empty
     151                 :            :     argument the helper class is created and initialized like in the CTOR to
     152                 :            :     SvXMLGraphicHelper that only gets the create mode
     153                 :            : 
     154                 :            :     To write the Pictures stream, you have to call dispose at this component.
     155                 :            :     Make sure you call dipose before you commit the parent storage.
     156                 :            : 
     157                 :            :     uses eCreateMode == GRAPHICHELPER_MODE_WRITE, bDirect == sal_True in
     158                 :            :     SvXMLGraphicHelper
     159                 :            :  */
     160                 :            : SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvXMLGraphicExportHelper_createInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( ::com::sun::star::uno::Exception );
     161                 :            : SVX_DLLPUBLIC ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServiceNames() throw();
     162                 :            : SVX_DLLPUBLIC ::rtl::OUString SAL_CALL SvXMLGraphicExportHelper_getImplementationName() throw();
     163                 :            : }
     164                 :            : 
     165                 :            : #endif
     166                 :            : 
     167                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10