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

Generated by: LCOV version 1.10