LCOV - code coverage report
Current view: top level - xmloff/source/text - txtparaimphint.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 63 96 65.6 %
Date: 2014-11-03 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       10278 :     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       10278 :         nType( nTyp )
      51             :     {
      52       10278 :     }
      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       10278 :     virtual ~XMLHint_Impl() {}
      62             : 
      63       10278 :     const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
      64       10278 :     const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
      65       10152 :     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       10278 :     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       10144 :     XMLStyleHint_Impl( const OUString& rStyleName,
      83             :                          const css::uno::Reference < css::text::XTextRange > & rPos ) :
      84             :         XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
      85       10144 :         sStyleName( rStyleName )
      86             :     {
      87       10144 :     }
      88       20288 :     virtual ~XMLStyleHint_Impl() {}
      89             : 
      90       19276 :     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           8 :     XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
     123             :         XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos ),
     124           8 :         pEvents( NULL )
     125             :     {
     126           8 :     }
     127             : 
     128          16 :     virtual ~XMLHyperlinkHint_Impl()
     129          16 :     {
     130           8 :         if (NULL != pEvents)
     131           0 :             pEvents->ReleaseRef();
     132          16 :     }
     133             : 
     134           8 :     void SetHRef( const OUString& s ) { sHRef = s; }
     135          16 :     const OUString& GetHRef() const { return sHRef; }
     136           0 :     void SetName( const OUString& s ) { sName = s; }
     137           8 :     const OUString& GetName() const { return sName; }
     138           0 :     void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
     139           8 :     const OUString& GetTargetFrameName() const { return sTargetFrameName; }
     140           4 :     void SetStyleName( const OUString& s ) { sStyleName = s; }
     141           8 :     const OUString& GetStyleName() const { return sStyleName; }
     142           4 :     void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
     143           8 :     const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
     144           8 :     XMLEventsImportContext* GetEventsContext() const
     145             :     {
     146           8 :         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          22 :     XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
     196             :                            const css::uno::Reference < css::text::XTextRange > & rPos ) :
     197             :         XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
     198          22 :         xContext( pContext )
     199             :     {
     200          22 :     }
     201             : 
     202          44 :     virtual ~XMLTextFrameHint_Impl()
     203          22 :     {
     204          44 :     }
     205             : 
     206          22 :     css::uno::Reference < css::text::XTextContent > GetTextContent() const
     207             :     {
     208          22 :         css::uno::Reference < css::text::XTextContent > xTxt;
     209          22 :         SvXMLImportContext *pContext = &xContext;
     210          22 :         if( pContext->ISA( XMLTextFrameContext ) )
     211          18 :             xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
     212           4 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     213           8 :             xTxt = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     214           4 :                         ->GetTextContent();
     215             : 
     216          22 :         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          22 :     bool IsBoundAtChar() const
     233             :     {
     234          22 :         bool bRet = false;
     235          22 :         SvXMLImportContext *pContext = &xContext;
     236          22 :         if( pContext->ISA( XMLTextFrameContext ) )
     237             :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     238          18 :                 PTR_CAST( XMLTextFrameContext, pContext )
     239          18 :                     ->GetAnchorType();
     240           4 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     241             :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     242           4 :                 PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     243           4 :                     ->GetAnchorType();
     244          22 :         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         104 :     XMLDrawHint_Impl( SvXMLShapeContext* pContext,
     256             :                       const css::uno::Reference < css::text::XTextRange > & rPos ) :
     257             :         XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
     258         104 :         xContext( pContext )
     259             :     {
     260         104 :     }
     261             : 
     262         208 :     virtual ~XMLDrawHint_Impl()
     263         104 :     {
     264         208 :     }
     265             : 
     266             :     // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     267         104 :     css::uno::Reference < css::drawing::XShape > GetShape() const
     268             :     {
     269         104 :         return static_cast<SvXMLShapeContext*>(&xContext)->getShape();
     270             :     }
     271             : };
     272             : #endif
     273             : 
     274             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10