LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - SdtHelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 17 17 100.0 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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             : 
      10             : #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SDTHELPER_HXX
      11             : #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SDTHELPER_HXX
      12             : 
      13             : #include <vector>
      14             : 
      15             : #include <boost/optional.hpp>
      16             : 
      17             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      18             : #include <rtl/ustrbuf.hxx>
      19             : 
      20             : #include <DomainMapper_Impl.hxx>
      21             : 
      22             : namespace com
      23             : {
      24             : namespace sun
      25             : {
      26             : namespace star
      27             : {
      28             : namespace awt
      29             : {
      30             : struct Size;
      31             : class XControlModel;
      32             : }
      33             : }
      34             : }
      35             : }
      36             : 
      37             : namespace writerfilter
      38             : {
      39             : namespace dmapper
      40             : {
      41             : 
      42             : /**
      43             :  * Helper to create form controls from w:sdt tokens.
      44             :  *
      45             :  * w:sdt tokens can't be imported as form fields, as w:sdt supports
      46             :  * e.g. date picking as well.
      47             :  */
      48             : class SdtHelper
      49             : {
      50             :     DomainMapper_Impl& m_rDM_Impl;
      51             : 
      52             :     /// Items of the drop-down control.
      53             :     std::vector<OUString> m_aDropDownItems;
      54             :     /// Pieces of the default text -- currently used only by the dropdown control.
      55             :     OUStringBuffer m_aSdtTexts;
      56             :     /// Date ISO string contained in the w:date element, used by the date control.
      57             :     OUStringBuffer m_sDate;
      58             :     /// Date format string as it comes from the ooxml document.
      59             :     OUStringBuffer m_sDateFormat;
      60             :     /// Locale string as it comes from the ooxml document.
      61             :     OUStringBuffer m_sLocale;
      62             :     /// Grab bag to store unsupported SDTs, aiming to save them back on export.
      63             :     std::vector<css::beans::PropertyValue> m_aGrabBag;
      64             : 
      65             :     bool m_bHasElements;
      66             :     /// The last stored SDT element is outside paragraphs.
      67             :     bool m_bOutsideAParagraph;
      68             : 
      69             :     /// Create and append the drawing::XControlShape, containing the various models.
      70             :     void createControlShape(css::awt::Size aSize, css::uno::Reference<css::awt::XControlModel> const&);
      71             :     void createControlShape(css::awt::Size aSize, css::uno::Reference<css::awt::XControlModel> const&, const css::uno::Sequence<css::beans::PropertyValue>& rGrabBag);
      72             : public:
      73             :     SdtHelper(DomainMapper_Impl& rDM_Impl);
      74             :     virtual ~SdtHelper();
      75             : 
      76       80315 :     std::vector<OUString>& getDropDownItems()
      77             :     {
      78       80315 :         return m_aDropDownItems;
      79             :     }
      80          16 :     OUStringBuffer& getSdtTexts()
      81             :     {
      82          16 :         return m_aSdtTexts;
      83             :     }
      84           9 :     OUStringBuffer& getDate()
      85             :     {
      86           9 :         return m_sDate;
      87             :     }
      88      154655 :     OUStringBuffer& getDateFormat()
      89             :     {
      90      154655 :         return m_sDateFormat;
      91             :     }
      92          18 :     OUStringBuffer& getLocale()
      93             :     {
      94          18 :         return m_sLocale;
      95             :     }
      96             :     /// If createControlShape() was ever called.
      97        2005 :     bool hasElements()
      98             :     {
      99        2005 :         return m_bHasElements;
     100             :     }
     101             : 
     102         944 :     void setOutsideAParagraph(bool bOutsideAParagraph)
     103             :     {
     104         944 :         m_bOutsideAParagraph = bOutsideAParagraph;
     105         944 :     }
     106             : 
     107         708 :     bool isOutsideAParagraph()
     108             :     {
     109         708 :         return m_bOutsideAParagraph;
     110             :     }
     111             : 
     112             :     /// Create drop-down control from w:sdt's w:dropDownList.
     113             :     void createDropDownControl();
     114             :     /// Create date control from w:sdt's w:date.
     115             :     void createDateControl(OUString& rContentText, const css::beans::PropertyValue& rCharFormat);
     116             : 
     117             :     void appendToInteropGrabBag(const css::beans::PropertyValue& rValue);
     118             :     css::uno::Sequence<css::beans::PropertyValue> getInteropGrabBagAndClear();
     119             :     bool isInteropGrabBagEmpty();
     120             :     bool containedInInteropGrabBag(const OUString& rValueName);
     121             :     sal_Int32 getInteropGrabBagSize();
     122             : };
     123             : 
     124             : } // namespace dmapper
     125             : } // namespace writerfilter
     126             : 
     127             : #endif
     128             : 
     129             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11