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

Generated by: LCOV version 1.10