LCOV - code coverage report
Current view: top level - xmloff/source/text - txtparaimphint.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 63 96 65.6 %
Date: 2015-06-13 12:38:46 Functions: 31 48 64.6 %
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_XMLOFF_SOURCE_TEXT_TXTPARAIMPHINT_HXX
      20             : #define INCLUDED_XMLOFF_SOURCE_TEXT_TXTPARAIMPHINT_HXX
      21             : 
      22             : #include <rtl/ustring.hxx>
      23             : #include <rtl/ustrbuf.hxx>
      24             : #include <xmloff/xmlimp.hxx>
      25             : #include "XMLTextFrameContext.hxx"
      26             : #include <xmloff/XMLEventsImportContext.hxx>
      27             : 
      28             : #define XML_HINT_STYLE 1
      29             : #define XML_HINT_REFERENCE 2
      30             : #define XML_HINT_HYPERLINK 3
      31             : #define XML_HINT_INDEX_MARK 5
      32             : #define XML_HINT_TEXT_FRAME 6
      33             : // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
      34             : #define XML_HINT_DRAW 7
      35             : 
      36             : class XMLHint_Impl
      37             : {
      38             :     css::uno::Reference < css::text::XTextRange > xStart;
      39             :     css::uno::Reference < css::text::XTextRange > xEnd;
      40             : 
      41             :     sal_uInt8 nType;
      42             : 
      43             : public:
      44             : 
      45        6034 :     XMLHint_Impl( sal_uInt8 nTyp,
      46             :                   const css::uno::Reference < css::text::XTextRange > & rS,
      47             :                   const css::uno::Reference < css::text::XTextRange > & rE ) :
      48             :         xStart( rS ),
      49             :         xEnd( rE ),
      50        6034 :         nType( nTyp )
      51             :     {
      52        6034 :     }
      53             : 
      54             :     XMLHint_Impl( sal_uInt8 nTyp,
      55             :                   const css::uno::Reference < css::text::XTextRange > & rS ) :
      56             :         xStart( rS ),
      57             :         nType( nTyp )
      58             :     {
      59             :     }
      60             : 
      61        6034 :     virtual ~XMLHint_Impl() {}
      62             : 
      63        6034 :     const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
      64        6034 :     const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
      65        5929 :     void SetEnd( const css::uno::Reference < css::text::XTextRange > & rPos ) { xEnd = rPos; }
      66             : 
      67             :     // We don't use virtual methods to differ between the sub classes,
      68             :     // because this seems to be to expensive if compared to inline methods.
      69        6034 :     sal_uInt8 GetType() const { return nType; }
      70             :     bool IsStyle() { return XML_HINT_STYLE==nType; }
      71           0 :     bool IsReference() { return XML_HINT_REFERENCE==nType; }
      72             :     bool IsHyperlink() { return XML_HINT_HYPERLINK==nType; }
      73           0 :     bool IsIndexMark() { return XML_HINT_INDEX_MARK==nType; }
      74             : };
      75             : 
      76             : class XMLStyleHint_Impl : public XMLHint_Impl
      77             : {
      78             :     OUString                 sStyleName;
      79             : 
      80             : public:
      81             : 
      82        5865 :     XMLStyleHint_Impl( const OUString& rStyleName,
      83             :                          const css::uno::Reference < css::text::XTextRange > & rPos ) :
      84             :         XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
      85        5865 :         sStyleName( rStyleName )
      86             :     {
      87        5865 :     }
      88       11730 :     virtual ~XMLStyleHint_Impl() {}
      89             : 
      90       31706 :     const OUString& GetStyleName() const { return sStyleName; }
      91             : };
      92             : 
      93             : class XMLReferenceHint_Impl : public XMLHint_Impl
      94             : {
      95             :     OUString                 sRefName;
      96             : 
      97             : public:
      98             : 
      99           0 :     XMLReferenceHint_Impl( const OUString& rRefName,
     100             :                              const css::uno::Reference < css::text::XTextRange > & rPos ) :
     101             :         XMLHint_Impl( XML_HINT_REFERENCE, rPos, rPos ),
     102           0 :         sRefName( rRefName )
     103             :     {
     104           0 :     }
     105             : 
     106           0 :     virtual ~XMLReferenceHint_Impl() {}
     107             : 
     108           0 :     const OUString& GetRefName() const { return sRefName; }
     109             : };
     110             : 
     111             : class XMLHyperlinkHint_Impl : public XMLHint_Impl
     112             : {
     113             :     OUString                 sHRef;
     114             :     OUString                 sName;
     115             :     OUString                 sTargetFrameName;
     116             :     OUString                 sStyleName;
     117             :     OUString                 sVisitedStyleName;
     118             :     XMLEventsImportContext*  pEvents;
     119             : 
     120             : public:
     121             : 
     122          64 :     XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
     123             :         XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos ),
     124          64 :         pEvents( NULL )
     125             :     {
     126          64 :     }
     127             : 
     128         128 :     virtual ~XMLHyperlinkHint_Impl()
     129         128 :     {
     130          64 :         if (NULL != pEvents)
     131           0 :             pEvents->ReleaseRef();
     132         128 :     }
     133             : 
     134          64 :     void SetHRef( const OUString& s ) { sHRef = s; }
     135         128 :     const OUString& GetHRef() const { return sHRef; }
     136           0 :     void SetName( const OUString& s ) { sName = s; }
     137          64 :     const OUString& GetName() const { return sName; }
     138           0 :     void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
     139          64 :     const OUString& GetTargetFrameName() const { return sTargetFrameName; }
     140          18 :     void SetStyleName( const OUString& s ) { sStyleName = s; }
     141          64 :     const OUString& GetStyleName() const { return sStyleName; }
     142          18 :     void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
     143          64 :     const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
     144          64 :     XMLEventsImportContext* GetEventsContext() const
     145             :     {
     146          64 :         return pEvents;
     147             :     }
     148           0 :     void SetEventsContext( XMLEventsImportContext* pCtxt )
     149             :     {
     150           0 :         pEvents = pCtxt;
     151           0 :         if (pEvents != NULL)
     152           0 :             pEvents->AddFirstRef();
     153           0 :     }
     154             : };
     155             : 
     156             : class XMLIndexMarkHint_Impl : public XMLHint_Impl
     157             : {
     158             :     const css::uno::Reference<css::beans::XPropertySet> xIndexMarkPropSet;
     159             : 
     160             :     const OUString sID;
     161             : 
     162             : public:
     163             : 
     164           0 :     XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
     165             :                            const css::uno::Reference < css::text::XTextRange > & rPos ) :
     166             :         XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
     167             :         xIndexMarkPropSet( rPropSet ),
     168           0 :         sID()
     169             :     {
     170           0 :     }
     171             : 
     172           0 :     XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
     173             :                            const css::uno::Reference < css::text::XTextRange > & rPos,
     174             :                            const OUString& sIDString) :
     175             :         XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
     176             :         xIndexMarkPropSet( rPropSet ),
     177           0 :         sID(sIDString)
     178             :     {
     179           0 :     }
     180             : 
     181           0 :     virtual ~XMLIndexMarkHint_Impl() {}
     182             : 
     183           0 :     const css::uno::Reference<css::beans::XPropertySet> & GetMark() const
     184           0 :         { return xIndexMarkPropSet; }
     185           0 :     const OUString& GetID() const { return sID; }
     186             : };
     187             : 
     188             : class XMLTextFrameHint_Impl : public XMLHint_Impl
     189             : {
     190             :     // OD 2004-04-20 #i26791#
     191             :     SvXMLImportContextRef xContext;
     192             : 
     193             : public:
     194             : 
     195          12 :     XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
     196             :                            const css::uno::Reference < css::text::XTextRange > & rPos ) :
     197             :         XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
     198          12 :         xContext( pContext )
     199             :     {
     200          12 :     }
     201             : 
     202          24 :     virtual ~XMLTextFrameHint_Impl()
     203          12 :     {
     204          24 :     }
     205             : 
     206          12 :     css::uno::Reference < css::text::XTextContent > GetTextContent() const
     207             :     {
     208          12 :         css::uno::Reference < css::text::XTextContent > xTxt;
     209          12 :         SvXMLImportContext *pContext = &xContext;
     210          12 :         if( pContext->ISA( XMLTextFrameContext ) )
     211          10 :             xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
     212           2 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     213           4 :             xTxt = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     214           2 :                         ->GetTextContent();
     215             : 
     216          12 :         return xTxt;
     217             :     }
     218             : 
     219             :     // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     220           0 :     css::uno::Reference < css::drawing::XShape > GetShape() const
     221             :     {
     222           0 :         css::uno::Reference < css::drawing::XShape > xShape;
     223           0 :         SvXMLImportContext *pContext = &xContext;
     224           0 :         if( pContext->ISA( XMLTextFrameContext ) )
     225           0 :             xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
     226           0 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     227           0 :             xShape = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )->GetShape();
     228             : 
     229           0 :         return xShape;
     230             :     }
     231             : 
     232          12 :     bool IsBoundAtChar() const
     233             :     {
     234          12 :         bool bRet = false;
     235          12 :         SvXMLImportContext *pContext = &xContext;
     236          12 :         if( pContext->ISA( XMLTextFrameContext ) )
     237             :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     238          10 :                 PTR_CAST( XMLTextFrameContext, pContext )
     239          10 :                     ->GetAnchorType();
     240           2 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     241             :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     242           2 :                 PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     243           2 :                     ->GetAnchorType();
     244          12 :         return bRet;
     245             :     }
     246             : };
     247             : 
     248             : // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
     249             : class XMLDrawHint_Impl : public XMLHint_Impl
     250             : {
     251             :     SvXMLImportContextRef xContext;
     252             : 
     253             : public:
     254             : 
     255          93 :     XMLDrawHint_Impl( SvXMLShapeContext* pContext,
     256             :                       const css::uno::Reference < css::text::XTextRange > & rPos ) :
     257             :         XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
     258          93 :         xContext( pContext )
     259             :     {
     260          93 :     }
     261             : 
     262         186 :     virtual ~XMLDrawHint_Impl()
     263          93 :     {
     264         186 :     }
     265             : 
     266             :     // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     267          93 :     css::uno::Reference < css::drawing::XShape > GetShape() const
     268             :     {
     269          93 :         return static_cast<SvXMLShapeContext*>(&xContext)->getShape();
     270             :     }
     271             : };
     272             : #endif
     273             : 
     274             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11