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

Generated by: LCOV version 1.11