LCOV - code coverage report
Current view: top level - xmloff/source/text - txtparaimphint.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 98 0.0 %
Date: 2014-04-14 Functions: 0 48 0.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             : #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           0 :     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           0 :         nType( nTyp )
      51             :     {
      52           0 :     }
      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           0 :     virtual ~XMLHint_Impl() {}
      62             : 
      63           0 :     const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
      64           0 :     const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
      65           0 :     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           0 :     sal_uInt8 GetType() const { return nType; }
      70             :     sal_Bool IsStyle() { return XML_HINT_STYLE==nType; }
      71           0 :     sal_Bool IsReference() { return XML_HINT_REFERENCE==nType; }
      72             :     sal_Bool IsHyperlink() { return XML_HINT_HYPERLINK==nType; }
      73           0 :     sal_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           0 :     XMLStyleHint_Impl( const OUString& rStyleName,
      83             :                          const css::uno::Reference < css::text::XTextRange > & rPos ) :
      84             :         XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
      85           0 :         sStyleName( rStyleName )
      86             :     {
      87           0 :     }
      88           0 :     virtual ~XMLStyleHint_Impl() {}
      89             : 
      90           0 :     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           0 :     XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
     123             :         XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos ),
     124           0 :         pEvents( NULL )
     125             :     {
     126           0 :     }
     127             : 
     128           0 :     virtual ~XMLHyperlinkHint_Impl()
     129           0 :     {
     130           0 :         if (NULL != pEvents)
     131           0 :             pEvents->ReleaseRef();
     132           0 :     }
     133             : 
     134           0 :     void SetHRef( const OUString& s ) { sHRef = s; }
     135           0 :     const OUString& GetHRef() const { return sHRef; }
     136           0 :     void SetName( const OUString& s ) { sName = s; }
     137           0 :     const OUString& GetName() const { return sName; }
     138           0 :     void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
     139           0 :     const OUString& GetTargetFrameName() const { return sTargetFrameName; }
     140           0 :     void SetStyleName( const OUString& s ) { sStyleName = s; }
     141           0 :     const OUString& GetStyleName() const { return sStyleName; }
     142           0 :     void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
     143           0 :     const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
     144           0 :     XMLEventsImportContext* GetEventsContext() const
     145             :     {
     146           0 :         return pEvents;
     147             :     }
     148           0 :     void SetEventsContext( XMLEventsImportContext* pCtxt )
     149             :     {
     150           0 :         pEvents = pCtxt;
     151           0 :         if (pEvents != NULL)
     152           0 :             pEvents->AddRef();
     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           0 :     XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
     196             :                            const css::uno::Reference < css::text::XTextRange > & rPos ) :
     197             :         XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
     198           0 :         xContext( pContext )
     199             :     {
     200           0 :     }
     201             : 
     202           0 :     virtual ~XMLTextFrameHint_Impl()
     203           0 :     {
     204           0 :     }
     205             : 
     206           0 :     css::uno::Reference < css::text::XTextContent > GetTextContent() const
     207             :     {
     208           0 :         css::uno::Reference < css::text::XTextContent > xTxt;
     209           0 :         SvXMLImportContext *pContext = &xContext;
     210           0 :         if( pContext->ISA( XMLTextFrameContext ) )
     211           0 :             xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
     212           0 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     213           0 :             xTxt = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     214           0 :                         ->GetTextContent();
     215             : 
     216           0 :         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           0 :     sal_Bool IsBoundAtChar() const
     233             :     {
     234           0 :         sal_Bool bRet = sal_False;
     235           0 :         SvXMLImportContext *pContext = &xContext;
     236           0 :         if( pContext->ISA( XMLTextFrameContext ) )
     237           0 :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     238           0 :                 PTR_CAST( XMLTextFrameContext, pContext )
     239           0 :                     ->GetAnchorType();
     240           0 :         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
     241           0 :             bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
     242           0 :                 PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
     243           0 :                     ->GetAnchorType();
     244           0 :         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           0 :     XMLDrawHint_Impl( SvXMLShapeContext* pContext,
     256             :                       const css::uno::Reference < css::text::XTextRange > & rPos ) :
     257             :         XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
     258           0 :         xContext( pContext )
     259             :     {
     260           0 :     }
     261             : 
     262           0 :     virtual ~XMLDrawHint_Impl()
     263           0 :     {
     264           0 :     }
     265             : 
     266             :     // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     267           0 :     css::uno::Reference < css::drawing::XShape > GetShape() const
     268             :     {
     269           0 :         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