LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/sfx2 - Metadatable.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 3 100.0 %
Date: 2013-07-09 Functions: 3 4 75.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             : #ifndef METADATABLE_HXX
      20             : #define METADATABLE_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <sfx2/dllapi.h>
      25             : 
      26             : #include <cppuhelper/implbase1.hxx>
      27             : #include <com/sun/star/rdf/XMetadatable.hpp>
      28             : 
      29             : #include <boost/utility.hpp>
      30             : #include <boost/shared_ptr.hpp>
      31             : 
      32             : 
      33             : namespace com { namespace sun { namespace star {
      34             :     namespace frame { class XModel; }
      35             : } } }
      36             : 
      37             : namespace sfx2 {
      38             :     class IXmlIdRegistry;
      39             : }
      40             : 
      41             : namespace sfx2 {
      42             : 
      43             : class XmlIdRegistry;
      44             : class MetadatableUndo;
      45             : 
      46             : 
      47             : // XML ID handling ---------------------------------------------------
      48             : 
      49             : 
      50             : /// create a sfx2::XmlIdRegistryDocument or a sfx2::XmlIdRegistryClipboard
      51             : SFX2_DLLPUBLIC ::sfx2::IXmlIdRegistry *
      52             : createXmlIdRegistry(const bool i_DocIsClipboard);
      53             : 
      54             : 
      55             : /** base class for core objects that may have xml:id.
      56             : 
      57             :     <p>The interface of this class consists of 3 parts:
      58             :     <ul><li>implementations that are used by the MetadatableMixin
      59             :             below</li>
      60             :         <li>hooks to be called by the sw core whenever actions that are
      61             :             relevant to the uniqueness of xml:ids are taken (copying,
      62             :             splitting, merging, deletion, undo, etc.)</li>
      63             :         <li>abstract methods that are called by the implementation of the
      64             :             previous hooks</li></ul>
      65             :     </p>
      66             :  */
      67             : class SFX2_DLLPUBLIC Metadatable : private boost::noncopyable
      68             : {
      69             : 
      70             : public:
      71       11211 :     Metadatable() : m_pReg(0) {}
      72             : 
      73             :     // destructor calls RemoveMetadataReference
      74             :     virtual ~Metadatable();
      75             : 
      76             :     // for MetadatableMixin ----------------------------------------------
      77             : 
      78             :     ::com::sun::star::beans::StringPair GetMetadataReference() const;
      79             :     void SetMetadataReference(
      80             :         const ::com::sun::star::beans::StringPair & i_rReference);
      81             :     void EnsureMetadataReference();
      82             : 
      83             :     // hooks -------------------------------------------------------------
      84             : 
      85             :     // called from dtor!
      86             :     void RemoveMetadataReference();
      87             : 
      88             :     /** register this as a copy of i_rSource */
      89             :     void RegisterAsCopyOf(Metadatable const & i_rSource,
      90             :         const bool i_bCopyPrecedesSource = false);
      91             : 
      92             :     /** create an Undo Metadatable, which remembers this' reference */
      93             :     ::boost::shared_ptr<MetadatableUndo> CreateUndo() const;
      94             :     ::boost::shared_ptr<MetadatableUndo> CreateUndoForDelete();
      95             : 
      96             :     /** restore this from Undo Metadatable */
      97             :     void RestoreMetadata(::boost::shared_ptr<MetadatableUndo> const& i_pUndo);
      98             : 
      99             :     /** merge this and i_rOther into this */
     100             :     void JoinMetadatable(Metadatable const & i_rOther,
     101             :         const bool i_isMergedEmpty, const bool i_isOtherEmpty);
     102             : 
     103             :     // abstract methods --------------------------------------------------
     104             : 
     105             :     /** get the registry from the SwDoc */
     106             :     virtual ::sfx2::IXmlIdRegistry& GetRegistry() = 0;
     107             : 
     108             :     /** is this in a clipboard document? */
     109             :     virtual bool IsInClipboard() const = 0;
     110             : 
     111             :     /** is this in undo array? */
     112             :     virtual bool IsInUndo() const = 0;
     113             : 
     114             :     /** which stream is this in? true: content.xml; false: styles.xml */
     115             :     virtual bool IsInContent() const = 0;
     116             : 
     117             :     /** create XMetadatable from this.
     118             :         note: if IsInUndo or IsInClipboard return true,
     119             :         MakeUnoObject <em>must not</em> be called!
     120             :      */
     121             :     virtual ::com::sun::star::uno::Reference<
     122             :         ::com::sun::star::rdf::XMetadatable > MakeUnoObject() = 0;
     123             : 
     124             : private:
     125             :     friend class MetadatableClipboard;
     126             :     friend class MetadatableUndo;
     127             : 
     128             :     // note that Reg may be a XmlIdRegistryDocument or a XmlIdRegistryClipboard
     129             :     XmlIdRegistry* m_pReg; // null => no XmlId
     130             : };
     131             : 
     132             : 
     133             : /** base class for UNO objects that implement XMetadatable.
     134             : 
     135             :     <p>An instance of this base class is associated with an instance of
     136             :        Metadatable.</p>
     137             :  */
     138             : class SFX2_DLLPUBLIC MetadatableMixin :
     139             :     public ::cppu::WeakImplHelper1<
     140             :         ::com::sun::star::rdf::XMetadatable>
     141             : {
     142             : 
     143             : public:
     144       10823 :     MetadatableMixin() {};
     145             : 
     146       10823 :     virtual ~MetadatableMixin() {}
     147             : 
     148             :     // ::com::sun::star::rdf::XNode:
     149             :     virtual OUString SAL_CALL getStringValue()
     150             :         throw (::com::sun::star::uno::RuntimeException);
     151             : 
     152             :     // ::com::sun::star::rdf::XURI:
     153             :     virtual OUString SAL_CALL getLocalName()
     154             :         throw (::com::sun::star::uno::RuntimeException);
     155             :     virtual OUString SAL_CALL getNamespace()
     156             :         throw (::com::sun::star::uno::RuntimeException);
     157             : 
     158             :     // ::com::sun::star::rdf::XMetadatable:
     159             :     virtual ::com::sun::star::beans::StringPair SAL_CALL getMetadataReference()
     160             :         throw (::com::sun::star::uno::RuntimeException);
     161             :     virtual void SAL_CALL setMetadataReference(
     162             :         const ::com::sun::star::beans::StringPair & i_rReference)
     163             :         throw (::com::sun::star::uno::RuntimeException,
     164             :             ::com::sun::star::lang::IllegalArgumentException);
     165             :     virtual void SAL_CALL ensureMetadataReference()
     166             :         throw (::com::sun::star::uno::RuntimeException);
     167             : 
     168             : protected:
     169             :     /// get the core object corresponding to this UNO object.
     170             :     virtual Metadatable * GetCoreObject() = 0;
     171             :     /// get the XModel for the document
     172             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
     173             :         GetModel() = 0;
     174             : 
     175             : };
     176             : 
     177             : } // namespace sfx2
     178             : 
     179             : #endif // METADATABLE_HXX
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10