fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / xmloff / source / text / XMLTextFrameHyperlinkContext.cxx
blob982f564a4691b9f195d78ab88b5c825ba0c148d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sax/tools/converter.hxx>
22 #include <xmloff/xmlimp.hxx>
23 #include <xmloff/nmspmap.hxx>
24 #include "xmloff/xmlnmspe.hxx"
25 #include <xmloff/xmltoken.hxx>
26 #include "XMLTextFrameContext.hxx"
27 #include "XMLTextFrameHyperlinkContext.hxx"
29 // OD 2004-04-21 #i26791#
30 #include <txtparaimphint.hxx>
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::text;
34 using namespace ::com::sun::star::xml::sax;
35 using namespace ::com::sun::star::beans;
36 using namespace ::xmloff::token;
38 namespace drawing = com::sun::star::drawing;
40 TYPEINIT1( XMLTextFrameHyperlinkContext, SvXMLImportContext );
42 XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
43 SvXMLImport& rImport,
44 sal_uInt16 nPrfx, const OUString& rLName,
45 const Reference< XAttributeList > & xAttrList,
46 TextContentAnchorType eATyp ) :
47 SvXMLImportContext( rImport, nPrfx, rLName ),
48 eDefaultAnchorType( eATyp ),
49 bMap( sal_False )
51 OUString sShow;
52 const SvXMLTokenMap& rTokenMap =
53 GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
55 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
56 for( sal_Int16 i=0; i < nAttrCount; i++ )
58 const OUString& rAttrName = xAttrList->getNameByIndex( i );
59 const OUString& rValue = xAttrList->getValueByIndex( i );
61 OUString aLocalName;
62 sal_uInt16 nPrefix =
63 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
64 &aLocalName );
65 switch( rTokenMap.Get( nPrefix, aLocalName ) )
67 case XML_TOK_TEXT_HYPERLINK_HREF:
68 sHRef = GetImport().GetAbsoluteReference( rValue );
69 break;
70 case XML_TOK_TEXT_HYPERLINK_NAME:
71 sName = rValue;
72 break;
73 case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
74 sTargetFrameName = rValue;
75 break;
76 case XML_TOK_TEXT_HYPERLINK_SHOW:
77 sShow = rValue;
78 break;
79 case XML_TOK_TEXT_HYPERLINK_SERVER_MAP:
81 bool bTmp(false);
82 if (::sax::Converter::convertBool( bTmp, rValue ))
84 bMap = bTmp;
87 break;
91 if( !sShow.isEmpty() && sTargetFrameName.isEmpty() )
93 if( IsXMLToken( sShow, XML_NEW ) )
94 sTargetFrameName = "_blank";
95 else if( IsXMLToken( sShow, XML_REPLACE ) )
96 sTargetFrameName = "_self";
100 XMLTextFrameHyperlinkContext::~XMLTextFrameHyperlinkContext()
104 void XMLTextFrameHyperlinkContext::EndElement()
108 SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext(
109 sal_uInt16 nPrefix,
110 const OUString& rLocalName,
111 const Reference< XAttributeList > & xAttrList )
113 SvXMLImportContext *pContext = 0;
114 XMLTextFrameContext *pTextFrameContext = 0;
116 if( XML_NAMESPACE_DRAW == nPrefix )
118 if( IsXMLToken( rLocalName, XML_FRAME ) )
119 pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
120 rLocalName, xAttrList,
121 eDefaultAnchorType );
124 if( pTextFrameContext )
126 pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
127 pContext = pTextFrameContext;
128 xFrameContext = pContext;
130 else
131 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
133 return pContext;
137 TextContentAnchorType XMLTextFrameHyperlinkContext::GetAnchorType() const
139 if( xFrameContext.Is() )
141 SvXMLImportContext *pContext = &xFrameContext;
142 return PTR_CAST( XMLTextFrameContext, pContext ) ->GetAnchorType();
144 else
145 return eDefaultAnchorType;
149 Reference < XTextContent > XMLTextFrameHyperlinkContext::GetTextContent() const
151 Reference <XTextContent > xTxt;
152 if( xFrameContext.Is() )
154 SvXMLImportContext *pContext = &xFrameContext;
155 xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
158 return xTxt;
161 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
162 Reference < drawing::XShape > XMLTextFrameHyperlinkContext::GetShape() const
164 Reference < drawing::XShape > xShape;
165 if( xFrameContext.Is() )
167 SvXMLImportContext *pContext = &xFrameContext;
168 xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
171 return xShape;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */