LCOV - code coverage report
Current view: top level - include/unotools - configitem.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1 1 100.0 %
Date: 2014-04-11 Functions: 1 1 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 INCLUDED_UNOTOOLS_CONFIGITEM_HXX
      21             : #define INCLUDED_UNOTOOLS_CONFIGITEM_HXX
      22             : 
      23             : #include <sal/types.h>
      24             : #include <rtl/ustring.hxx>
      25             : #include <com/sun/star/uno/Sequence.h>
      26             : #include <com/sun/star/uno/Reference.h>
      27             : #include <unotools/unotoolsdllapi.h>
      28             : #include <unotools/options.hxx>
      29             : 
      30             : namespace com{ namespace sun{ namespace star{
      31             :     namespace uno{
      32             :         class Any;
      33             :     }
      34             :     namespace beans{
      35             :         struct PropertyValue;
      36             :     }
      37             :     namespace container{
      38             :         class XHierarchicalNameAccess;
      39             :     }
      40             :     namespace util{
      41             :         class XChangesListener;
      42             :     }
      43             : }}}
      44             : 
      45             : namespace utl
      46             : {
      47             : #define CONFIG_MODE_IMMEDIATE_UPDATE    0x00
      48             : #define CONFIG_MODE_DELAYED_UPDATE      0x01
      49             : #define CONFIG_MODE_ALL_LOCALES         0x02
      50             : #define CONFIG_MODE_RELEASE_TREE        0x04
      51             : 
      52             :     enum  ConfigNameFormat
      53             :     {
      54             :         CONFIG_NAME_PLAINTEXT_NAME, // unescaped local node name, for user display etc.
      55             :         CONFIG_NAME_LOCAL_NAME,     // local node name, for use in XNameAccess etc. ("Item", "Q & A")
      56             :         CONFIG_NAME_LOCAL_PATH,     // one-level relative path, for use when building paths etc.  ("Item", "Typ['Q &amp; A']")
      57             :         CONFIG_NAME_FULL_PATH,       // full absolute path. ("/org.openoffice.Sample/Group/Item", "/org.openoffice.Sample/Set/Typ['Q &amp; A']")
      58             : 
      59             :         CONFIG_NAME_DEFAULT = CONFIG_NAME_LOCAL_PATH // default format
      60             :     };
      61             : 
      62             :     class ConfigChangeListener_Impl;
      63             :     class ConfigManager;
      64             : 
      65             :     class UNOTOOLS_DLLPUBLIC ConfigItem : public ConfigurationBroadcaster
      66             :     {
      67             :             friend class ConfigChangeListener_Impl;
      68             :             friend class ConfigManager;
      69             : 
      70             :             const OUString              sSubTree;
      71             :             com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess>
      72             :                                         m_xHierarchyAccess;
      73             :             com::sun::star::uno::Reference< com::sun::star::util::XChangesListener >
      74             :                                         xChangeLstnr;
      75             :             sal_Int16 m_nMode;
      76             :             bool m_bIsModified;
      77             :             bool m_bEnableInternalNotification;
      78             :             sal_Int16 m_nInValueChange;
      79             : 
      80             :             void                    RemoveChangesListener();
      81             :             void                    CallNotify(
      82             :                                 const com::sun::star::uno::Sequence<OUString>& aPropertyNames);
      83             : 
      84             :             // In special mode ALL_LOCALES we must support reading/writing of localized cfg entries as Sequence< PropertyValue >.
      85             :             // These methods are helper to convert given lists of names and Any-values.
      86             :             // format:  PropertyValue.Name  = <locale as ISO string>
      87             :             //          PropertyValue.Value = <value; type depends from cfg entry!>
      88             :             // e.g.
      89             :             //          LOCALIZED NODE
      90             :             //          "UIName"
      91             :             //                      LOCALE      VALUE
      92             :             //                      "de"        "Mein Name"
      93             :             //                      "en-US"     "my name"
      94             :             void impl_packLocalizedProperties   (   const   com::sun::star::uno::Sequence< OUString >&                  lInNames    ,
      95             :                                                     const   com::sun::star::uno::Sequence< com::sun::star::uno::Any >&  lInValues   ,
      96             :                                                             com::sun::star::uno::Sequence< com::sun::star::uno::Any >&  lOutValues  );
      97             :             void impl_unpackLocalizedProperties (   const   com::sun::star::uno::Sequence< OUString >&                  lInNames    ,
      98             :                                                     const   com::sun::star::uno::Sequence< com::sun::star::uno::Any >&  lInValues   ,
      99             :                                                             com::sun::star::uno::Sequence< OUString >&                  lOutNames   ,
     100             :                                                             com::sun::star::uno::Sequence< com::sun::star::uno::Any >&  lOutValues  );
     101             : 
     102             :             com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess>
     103             :                                         GetTree();
     104             : 
     105             :         protected:
     106             :             explicit ConfigItem(const OUString &rSubTree,
     107             :                         sal_Int16 nMode = CONFIG_MODE_DELAYED_UPDATE);
     108             : 
     109             :             void                    SetModified  (); // mark item as modified
     110             :             void                    ClearModified(); // reset state after commit!
     111             : 
     112             :             com::sun::star::uno::Sequence< com::sun::star::uno::Any>
     113             :                                     GetProperties(const com::sun::star::uno::Sequence< OUString >& rNames);
     114             : 
     115             :             com::sun::star::uno::Sequence< sal_Bool >
     116             :                                     GetReadOnlyStates(const com::sun::star::uno::Sequence< OUString >& rNames);
     117             : 
     118             :             bool                PutProperties(
     119             :                                         const com::sun::star::uno::Sequence< OUString >& rNames,
     120             :                                         const com::sun::star::uno::Sequence< com::sun::star::uno::Any>& rValues);
     121             : 
     122             :             /** enables notifications about changes on selected sub nodes/values
     123             : 
     124             :                 Before calling this method a second time for a possibly changed node/value set,
     125             :                 you must disable the current notifications by calling DisableNotification.
     126             : 
     127             :                 @see Notify
     128             :                 @see DisableNotification
     129             :             */
     130             :             bool                EnableNotification(const com::sun::star::uno::Sequence< OUString >& rNames,
     131             :                                         bool bEnableInternalNotification = false);
     132             :             /** disables notifications about changes on sub nodes/values, which previosly had
     133             :                 been enabled with EnableNotification
     134             :                 @see Notify
     135             :                 @see EnableNotification
     136             :             */
     137             :             void                    DisableNotification();
     138             :             bool                IsInternalNotification()const {return IsInValueChange();}
     139             : 
     140             :             //returns all members of a node in a specific format
     141             :             com::sun::star::uno::Sequence< OUString >
     142             :                                     GetNodeNames(const OUString& rNode);
     143             :             //returns all members of a node in a specific format
     144             :             com::sun::star::uno::Sequence< OUString >
     145             :                                     GetNodeNames(const OUString& rNode, ConfigNameFormat eFormat);
     146             :             // remove all members of a set
     147             :             bool                ClearNodeSet(const OUString& rNode);
     148             :             // remove selected members of a set
     149             :             bool                ClearNodeElements(const OUString& rNode,
     150             :                                         com::sun::star::uno::Sequence< OUString >& rElements);
     151             :             // change or add members to a set
     152             :             bool                SetSetProperties(const OUString& rNode, com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues);
     153             :             // remove, change or add members of a set
     154             :             bool                ReplaceSetProperties(const OUString& rNode, com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > rValues);
     155             :             // add a new node without setting any properties
     156             :             bool                AddNode(const OUString& rNode, const OUString& rNewNode);
     157             : 
     158             :         public:
     159             :             virtual ~ConfigItem();
     160             : 
     161             :             /** is called from the ConfigManager before application ends of from the
     162             :                 PropertyChangeListener if the sub tree broadcasts changes. */
     163             :             virtual void            Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames)=0;
     164             : 
     165       16125 :             const OUString&         GetSubTreeName() const {return sSubTree;}
     166             : 
     167             :             bool IsModified() const;
     168             : 
     169             :             /** writes the changed values into the sub tree. Always called in the Dtor of the derived class.  */
     170             :             virtual void            Commit()=0;
     171             : 
     172             :             bool IsInValueChange() const;
     173             : 
     174             :             sal_Int16               GetMode() const;
     175             :     };
     176             : }//namespace utl
     177             : #endif // INCLUDED_UNOTOOLS_CONFIGITEM_HXX
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10