LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/comphelper - mediadescriptor.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-12-27 Functions: 3 3 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 _COMPHELPER_MEDIADESCRIPTOR_HXX_
      21             : #define _COMPHELPER_MEDIADESCRIPTOR_HXX_
      22             : 
      23             : #include <comphelper/sequenceashashmap.hxx>
      24             : #include <rtl/ustring.hxx>
      25             : #include "comphelper/comphelperdllapi.h"
      26             : 
      27             : namespace com { namespace sun { namespace star { namespace io {
      28             :     class XInputStream;
      29             : } } } }
      30             : 
      31             : namespace comphelper{
      32             : 
      33             : /** @short  can be used to work with a <type scope="::com::sun::star::document">MediaDescriptor</type>
      34             :             struct.
      35             : 
      36             :     @descr  It wraps a ::boost::unordered_map around the Sequence< css::beans::PropertyValue >, which
      37             :             represent the MediaDescriptor item.
      38             :             Further this helper defines often used functions (as e.g. open of the required streams,
      39             :             consistent checks etcpp.) and it defines all useable property names.
      40             : 
      41             :     @attention  This class isnt threadsafe and must be guarded from outside!
      42             :  */
      43        4425 : class COMPHELPER_DLLPUBLIC MediaDescriptor : public SequenceAsHashMap
      44             : {
      45             :     public:
      46             : 
      47             :         //---------------------------------------
      48             :         /** @short  these methods can be used to get the different property names
      49             :                     as static const OUString values.
      50             : 
      51             :             @descr  Because definition and declaration of static const class members
      52             :                     does not work as expected under windows (under unix it works as well)
      53             :                     these way must be used :-(
      54             :           */
      55             :         static const ::rtl::OUString& PROP_ABORTED();
      56             :         static const ::rtl::OUString& PROP_ASTEMPLATE();
      57             :         static const ::rtl::OUString& PROP_COMPONENTDATA();
      58             :         static const ::rtl::OUString& PROP_DOCUMENTSERVICE();
      59             :         static const ::rtl::OUString& PROP_ENCRYPTIONDATA();
      60             :         static const ::rtl::OUString& PROP_FILENAME();
      61             :         static const ::rtl::OUString& PROP_FILTERNAME();
      62             :         static const ::rtl::OUString& PROP_FILTERPROVIDER();
      63             :         static const ::rtl::OUString& PROP_FILTEROPTIONS();
      64             :         static const ::rtl::OUString& PROP_FRAME();
      65             :         static const ::rtl::OUString& PROP_FRAMENAME();
      66             :         static const ::rtl::OUString& PROP_HIDDEN();
      67             :         static const ::rtl::OUString& PROP_INPUTSTREAM();
      68             :         static const ::rtl::OUString& PROP_INTERACTIONHANDLER();
      69             :         static const ::rtl::OUString& PROP_JUMPMARK();
      70             :         static const ::rtl::OUString& PROP_MACROEXECUTIONMODE();
      71             :         static const ::rtl::OUString& PROP_MEDIATYPE();
      72             :         static const ::rtl::OUString& PROP_MINIMIZED();
      73             :         static const ::rtl::OUString& PROP_NOAUTOSAVE();
      74             :         static const ::rtl::OUString& PROP_OPENNEWVIEW();
      75             :         static const ::rtl::OUString& PROP_OUTPUTSTREAM();
      76             :         static const ::rtl::OUString& PROP_PASSWORD();
      77             :         static const ::rtl::OUString& PROP_POSTDATA();
      78             :         static const ::rtl::OUString& PROP_PREVIEW();
      79             :         static const ::rtl::OUString& PROP_READONLY();
      80             :         static const ::rtl::OUString& PROP_REFERRER();
      81             :         static const ::rtl::OUString& PROP_SALVAGEDFILE();
      82             :         static const ::rtl::OUString& PROP_STATUSINDICATOR();
      83             :         static const ::rtl::OUString& PROP_STREAM();
      84             :         static const ::rtl::OUString& PROP_STREAMFOROUTPUT();
      85             :         static const ::rtl::OUString& PROP_TEMPLATENAME();
      86             :         static const ::rtl::OUString& PROP_TITLE();
      87             :         static const ::rtl::OUString& PROP_TYPENAME();
      88             :         static const ::rtl::OUString& PROP_UCBCONTENT();
      89             :         static const ::rtl::OUString& PROP_UPDATEDOCMODE();
      90             :         static const ::rtl::OUString& PROP_URL();
      91             :         static const ::rtl::OUString& PROP_VERSION();
      92             :         static const ::rtl::OUString& PROP_DOCUMENTTITLE();
      93             :         static const ::rtl::OUString& PROP_MODEL();
      94             :         static const ::rtl::OUString& PROP_VIEWONLY();
      95             :         static const ::rtl::OUString& PROP_DOCUMENTBASEURL();
      96             : 
      97             :     //-------------------------------------------
      98             :     // interface
      99             :     public:
     100             :         //---------------------------------------
     101             :         /** @short  these ctors do nothing - excepting that they forward
     102             :                     the given parameters to the base class ctors.
     103             : 
     104             :             @descr  The ctros must be overwritten to resolve conflicts with
     105             :                     the default ctors of the compiler :-(.
     106             :          */
     107             :         MediaDescriptor();
     108             :         MediaDescriptor(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lSource);
     109             : 
     110             :         //---------------------------------------
     111             :         /** @short  it checks if the descriptor already has a valid
     112             :                     InputStream item and creates a new one, if not.
     113             : 
     114             :             @descr  This method uses the current items of this MediaDescriptor,
     115             :                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
     116             :                     It creates a seekable stream and put it into the descriptor.
     117             : 
     118             :                     A might existing InteractionHandler will be used automaticly,
     119             :                     to solve problems!
     120             : 
     121             :                     In case of local file the system file locking is used.
     122             : 
     123             :             @return TRUE, if the stream was already part of the descriptor or could
     124             :                     be created as new item. FALSE otherwhise.
     125             :          */
     126             :         sal_Bool addInputStream();
     127             : 
     128             :         //---------------------------------------
     129             :         /** @short  it checks if the descriptor already has a valid
     130             :                     InputStream item and creates a new one, if not.
     131             : 
     132             :             @descr  This method uses the current items of this MediaDescriptor,
     133             :                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
     134             :                     It creates a seekable stream and put it into the descriptor.
     135             : 
     136             :                     A might existing InteractionHandler will be used automaticly,
     137             :                     to solve problems!
     138             : 
     139             :                     In case of local file the system file locking is used based on
     140             :                     configuration settings.
     141             : 
     142             :             @return TRUE, if the stream was already part of the descriptor or could
     143             :                     be created as new item. FALSE otherwhise.
     144             :          */
     145             :         sal_Bool addInputStreamOwnLock();
     146             : 
     147             :         //---------------------------------------
     148             :         /** @short  it checks if the descriptor describes a readonly stream.
     149             : 
     150             :             @descr  The descriptor itself isnt changed doing so.
     151             :                     It's only checked if the stream seems to be based
     152             :                     of a real readonly file.
     153             : 
     154             :             @Attention
     155             :                     We dont check the property "ReadOnly" here. Because
     156             :                     this property can be set from outside and overwrites
     157             :                     the readonly state of  the stream.
     158             :                     If e.g. the stream could be opened read/write ...
     159             :                     but "ReadOnly" property is set to TRUE, this means:
     160             :                     show a readonly UI on top of this read/write stream.
     161             : 
     162             :             @return TRUE, if the stream must be interpreted as readonly ...
     163             :                     FALSE otherwhise.
     164             :          */
     165             :         sal_Bool isStreamReadOnly() const;
     166             : 
     167             :         //---------------------------------------
     168             :         /** Returns a value from the sequence contained in the property
     169             :             'ComponentData' of this media descriptor.
     170             : 
     171             :             @descr  The property 'ComponentData' should be empty, or should
     172             :                 contain a value of type sequence<com.sun.star.beans.NamedValue>
     173             :                 or sequence<com.sun.star.beans.PropertyValue>.
     174             : 
     175             :             @return  The value with the specified name, if existing in the
     176             :                 sequence of the 'ComponentData' property, otherwise an empty
     177             :                 Any.
     178             :          */
     179             :         ::com::sun::star::uno::Any getComponentDataEntry(
     180             :             const ::rtl::OUString& rName ) const;
     181             : 
     182             :         //---------------------------------------
     183             :         /** Inserts a value into the sequence contained in the property
     184             :             'ComponentData' of the media descriptor.
     185             : 
     186             :             @descr  The property 'ComponentData' should be empty, or should
     187             :                 contain a value of type sequence<com.sun.star.beans.NamedValue>
     188             :                 or sequence<com.sun.star.beans.PropertyValue>. The passed value
     189             :                 will be inserted into the sequence, or, if already existing,
     190             :                 will be overwritten.
     191             : 
     192             :             @param rName  The name of the value to be inserted into the
     193             :                 sequence of the 'ComponentData' property.
     194             : 
     195             :             @param rValue  The value to be inserted into the sequence of the
     196             :                 'ComponentData' property.
     197             :          */
     198             :         void setComponentDataEntry(
     199             :             const ::rtl::OUString& rName,
     200             :             const ::com::sun::star::uno::Any& rValue );
     201             : 
     202             :         //---------------------------------------
     203             :         /** Removes a value from the sequence contained in the property
     204             :             'ComponentData' of the media descriptor.
     205             : 
     206             :             @descr  The property 'ComponentData' should be empty, or should
     207             :                 contain a value of type sequence<com.sun.star.beans.NamedValue>
     208             :                 or sequence<com.sun.star.beans.PropertyValue>. The value with
     209             :                 the passed name will be removed from the sequence, if existing.
     210             : 
     211             :             @param rName  The name of the value to be removed from the sequence
     212             :                 of the 'ComponentData' property.
     213             :          */
     214             :         void clearComponentDataEntry(
     215             :             const ::rtl::OUString& rName );
     216             : 
     217             :     //-------------------------------------------
     218             :     // helper
     219             :     private:
     220             : 
     221             :         //---------------------------------------
     222             :         /** @short  tries to open a stream by using the given PostData stream.
     223             : 
     224             :             @descr  The stream is used directly ...
     225             : 
     226             :                     The MediaDescriptor itself is changed inside this method.
     227             :                     Means: the stream is added internal and not returned by a value.
     228             : 
     229             :             @param  _rxPostData
     230             :                     the PostData stream.
     231             : 
     232             :             @return TRUE if the stream could be added successfully.
     233             :                     Note: If FALSE is returned, the error was already handled inside!
     234             : 
     235             :             @throw  [css::uno::RuntimeException]
     236             :                     if the MediaDescriptor seems to be invalid!
     237             : 
     238             :             @throw  [css::lang::IllegalArgumentException]
     239             :                     if the given PostData stream is <NULL/>.
     240             :          */
     241             :         COMPHELPER_DLLPRIVATE sal_Bool impl_openStreamWithPostData(
     242             :             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& _rxPostData
     243             :             )   throw(::com::sun::star::uno::RuntimeException);
     244             : 
     245             :         //---------------------------------------
     246             :         /** @short  tries to open a stream by using the given URL.
     247             : 
     248             :             @descr  First it tries to open the content in r/w mode (if its
     249             :                     allowed to do so). Only in case its not allowed or it failed
     250             :                     the stream will be tried to open in readonly mode.
     251             : 
     252             :                     The MediaDescriptor itself is changed inside this method.
     253             :                     Means: the stream is added internal and not returned by a value.
     254             : 
     255             :             @param  sURL
     256             :                     the URL for open.
     257             : 
     258             :             @param  bLockFile
     259             :                     specifies whether the file should be locked
     260             : 
     261             :             @return TRUE if the stream could be added successfully.
     262             :                     Note: If FALSE is returned, the error was already handled inside!
     263             : 
     264             :             @throw  [css::uno::RuntimeException]
     265             :                     if the MediaDescriptor seems to be invalid!
     266             :          */
     267             :         COMPHELPER_DLLPRIVATE sal_Bool impl_openStreamWithURL(
     268             :             const ::rtl::OUString& sURL,
     269             :             sal_Bool bLockFile
     270             :             ) throw(::com::sun::star::uno::RuntimeException);
     271             : 
     272             :         //---------------------------------------
     273             :         /** @short  some URL parts can make trouble for opening streams (e.g. jumpmarks.)
     274             :                     An URL should be "normalized" before its used.
     275             : 
     276             :             @param  sURL
     277             :                     the original URL (e.g. including a jumpmark)
     278             : 
     279             :             @return [string]
     280             :                     the "normalized" URL (e.g. without jumpmark)
     281             :          */
     282             :         COMPHELPER_DLLPRIVATE ::rtl::OUString impl_normalizeURL(const ::rtl::OUString& sURL);
     283             : 
     284             :         //---------------------------------------
     285             :         /** @short  it checks if the descriptor already has a valid
     286             :                     InputStream item and creates a new one, if not.
     287             : 
     288             :             @descr  This method uses the current items of this MediaDescriptor,
     289             :                     to open the stream (as e.g. URL, ReadOnly, PostData etcpp.).
     290             :                     It creates a seekable stream and put it into the descriptor.
     291             : 
     292             :                     A might existing InteractionHandler will be used automaticly,
     293             :                     to solve problems!
     294             : 
     295             :             @param  bLockFile
     296             :                     specifies whether the file should be locked
     297             : 
     298             :             @return TRUE, if the stream was already part of the descriptor or could
     299             :                     be created as new item. FALSE otherwhise.
     300             :          */
     301             :         COMPHELPER_DLLPRIVATE sal_Bool impl_addInputStream( sal_Bool bLockFile );
     302             : };
     303             : 
     304             : } // namespace comphelper
     305             : 
     306             : #endif // _COMPHELPER_MEDIADESCRIPTOR_HXX_
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10