Kaydet (Commit) 06cdbf23 authored tarafından Michael Brauer's avatar Michael Brauer

#85710#: Keep position of character bound frames

üst e5e555bd
......@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTextFrameContext.cxx,v $
*
* $Revision: 1.38 $
* $Revision: 1.39 $
*
* last change: $Author: mib $ $Date: 2001-04-10 09:07:23 $
* last change: $Author: mib $ $Date: 2001-04-25 13:35:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -345,6 +345,7 @@ XMLTextFrameContext::XMLTextFrameContext(
TextContentAnchorType eATyp,
sal_uInt16 nNewType ) :
nType( nNewType ),
eAnchorType( eATyp ),
SvXMLImportContext( rImport, nPrfx, rLName ),
sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
......@@ -389,7 +390,6 @@ XMLTextFrameContext::XMLTextFrameContext(
sal_Int16 nRelHeight = 0;
sal_Bool bMayScript = sal_False;
TextContentAnchorType eAnchorType = eATyp;
sal_Bool bMinHeight = sal_False;
sal_Bool bSyncWidth = sal_False;
......@@ -948,3 +948,7 @@ void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
}
}
Reference < XTextContent > XMLTextFrameContext::GetTextContent() const
{
return Reference < XTextContent >( xPropSet, UNO_QUERY );
}
......@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTextFrameContext.hxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: mib $ $Date: 2001-03-16 12:49:19 $
* last change: $Author: mib $ $Date: 2001-04-25 13:35:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -71,7 +71,7 @@
#endif
namespace com { namespace sun { namespace star {
namespace text { class XTextCursor; }
namespace text { class XTextCursor; class XTextContent; }
namespace beans { class XPropertySet; }
} } }
......@@ -114,6 +114,7 @@ class XMLTextFrameContext : public SvXMLImportContext
::rtl::OUString sDesc;
sal_uInt16 nType;
::com::sun::star::text::TextContentAnchorType eAnchorType;
ParamMap aParamMap;
public:
......@@ -140,6 +141,11 @@ public:
const ::rtl::OUString& rName,
const ::rtl::OUString& rTargetFrameName,
sal_Bool bMap );
::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
::com::sun::star::uno::Reference <
::com::sun::star::text::XTextContent > GetTextContent() const;
};
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTextFrameHyperlinkContext.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: mib $ $Date: 2000-09-29 13:33:43 $
* last change: $Author: mib $ $Date: 2001-04-25 13:35:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -93,9 +93,13 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
SvXMLImport& rImport,
sal_uInt16 nPrfx, const OUString& rLName,
const Reference< XAttributeList > & xAttrList,
TextContentAnchorType eATyp ) :
TextContentAnchorType eATyp,
Reference < XTextContent> *pTxtCntnt,
TextContentAnchorType *pAnchrType ) :
SvXMLImportContext( rImport, nPrfx, rLName ),
eAnchorType( eATyp ),
pTextContent( pTxtCntnt ),
pAnchorType( pAnchrType ),
bMap( sal_False )
{
OUString sShow;
......@@ -164,22 +168,29 @@ SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext(
const Reference< XAttributeList > & xAttrList )
{
SvXMLImportContext *pContext = 0;
XMLTextFrameContext *pTextFrameContext = 0;
if( XML_NAMESPACE_DRAW == nPrefix &&
rLocalName.equalsAsciiL( sXML_text_box, sizeof(sXML_text_box)-1 ) )
pContext = new XMLTextFrameContext( GetImport(), nPrefix,
pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
rLocalName, xAttrList,
eAnchorType,
XML_TEXT_FRAME_TEXTBOX);
else if( XML_NAMESPACE_DRAW == nPrefix &&
rLocalName.equalsAsciiL( sXML_image, sizeof(sXML_image)-1 ) )
pContext = new XMLTextFrameContext( GetImport(), nPrefix,
pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
rLocalName, xAttrList,
eAnchorType,
XML_TEXT_FRAME_GRAPHIC );
if( pContext )
((XMLTextFrameContext *)pContext)->
SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
if( pTextFrameContext )
{
pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
if( pAnchorType )
*pAnchorType = pTextFrameContext->GetAnchorType();
if( pTextContent )
*pTextContent = pTextFrameContext->GetTextContent();
pContext = pTextFrameContext;
}
else
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTextFrameHyperlinkContext.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: mib $ $Date: 2000-09-26 08:09:50 $
* last change: $Author: mib $ $Date: 2001-04-25 13:35:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -65,13 +65,16 @@
#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP
#include <com/sun/star/text/TextContentAnchorType.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTFRAME_HPP
#include <com/sun/star/text/XTextFrame.hpp>
#endif
#ifndef _XMLOFF_XMLICTXT_HXX
#include "xmlictxt.hxx"
#endif
namespace com { namespace sun { namespace star {
namespace text { class XTextCursor; }
namespace text { class XTextCursor; class XTextFrame; }
namespace beans { class XPropertySet; }
} } }
......@@ -82,6 +85,9 @@ class XMLTextFrameHyperlinkContext : public SvXMLImportContext
::rtl::OUString sName;
::rtl::OUString sTargetFrameName;
::com::sun::star::text::TextContentAnchorType eAnchorType;
::com::sun::star::uno::Reference <
::com::sun::star::text::XTextContent> *pTextContent;
::com::sun::star::text::TextContentAnchorType *pAnchorType;
sal_Bool bMap;
public:
......@@ -93,7 +99,10 @@ public:
const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList,
::com::sun::star::text::TextContentAnchorType eAnchorType );
::com::sun::star::text::TextContentAnchorType eAnchorType,
::com::sun::star::uno::Reference <
::com::sun::star::text::XTextContent> *pTxtCntnt = 0 ,
::com::sun::star::text::TextContentAnchorType *pAnchrType = 0 );
virtual ~XMLTextFrameHyperlinkContext();
virtual void EndElement();
......@@ -102,6 +111,7 @@ public:
const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList );
};
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: txtparai.cxx,v $
*
* $Revision: 1.22 $
* $Revision: 1.23 $
*
* last change: $Author: mib $ $Date: 2001-03-16 12:49:19 $
* last change: $Author: mib $ $Date: 2001-04-25 13:35:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -74,8 +74,8 @@
#include <svtools/svarray.hxx>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_
//#include <com/sun/star/text/XText.hpp>
#ifndef _COM_SUN_STAR_TEXT_XTEXTFRAME_HPP_
#include <com/sun/star/text/XTextFrame.hpp>
#endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTCURSOR_HPP_
#include <com/sun/star/text/XTextCursor.hpp>
......@@ -157,6 +157,7 @@ using namespace ::com::sun::star::drawing;
#define XML_HINT_HYPERLINK 3
#define XML_HINT_RUBY 4
#define XML_HINT_INDEX_MARK 5
#define XML_HINT_TEXT_FRAME 6
class XMLHint_Impl
......@@ -339,6 +340,36 @@ public:
const OUString& GetText() const { return sText; }
};
class XMLTextFrameHint_Impl : public XMLHint_Impl
{
Reference < XTextContent > xTextContent;
TextContentAnchorType eAnchorType;
public:
XMLTextFrameHint_Impl( const Reference < XTextContent > & rTxtCntnt,
const Reference < XTextRange > & rPos ) :
XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
xTextContent( rTxtCntnt ),
eAnchorType( TextContentAnchorType_AT_CHARACTER )
{
}
XMLTextFrameHint_Impl( const Reference < XTextRange > & rPos ) :
XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
eAnchorType( TextContentAnchorType_AS_CHARACTER )
{
}
virtual ~XMLTextFrameHint_Impl() {}
Reference < XTextContent >& GetTextContentRef() { return xTextContent; }
TextContentAnchorType& GetAnchorTypeRef() { return eAnchorType; }
Reference < XTextContent > GetTextContent() const { return xTextContent; }
sal_Bool IsBoundAtChar() const { return TextContentAnchorType_AT_CHARACTER == eAnchorType; }
};
typedef XMLHint_Impl *XMLHint_ImplPtr;
SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 )
SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr )
......@@ -1469,6 +1500,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
sal_Bool& rIgnoreLeadingSpace )
{
SvXMLImportContext *pContext = 0;
sal_Bool bInsertTextFrame = sal_False;
sal_uInt16 nTextFrameType = 0;
sal_Bool bObjectOLE = sal_False;
switch( nToken )
......@@ -1577,71 +1610,50 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
break;
case XML_TOK_TEXT_TEXTBOX:
if( XMLTextImportHelper::HasDrawNameAttribute( xAttrList, rImport.GetNamespaceMap() ) ||
rImport.GetTextImport()->IsInHeaderFooter() )
{
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_TEXTBOX );
}
else
{
Reference < XShapes > xShapes;
pContext = rImport.GetShapeImport()->CreateGroupChildContext(
rImport, nPrefix, rLocalName, xAttrList, xShapes );
}
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_TEXTBOX;
break;
case XML_TOK_TEXT_IMAGE:
if( XMLTextImportHelper::HasDrawNameAttribute( xAttrList, rImport.GetNamespaceMap() ) ||
rImport.GetTextImport()->IsInHeaderFooter() )
{
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_GRAPHIC );
}
else
{
Reference < XShapes > xShapes;
pContext = rImport.GetShapeImport()->CreateGroupChildContext(
rImport, nPrefix, rLocalName, xAttrList, xShapes );
}
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_GRAPHIC;
break;
case XML_TOK_TEXT_APPLET:
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_APPLET );
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_APPLET;
break;
case XML_TOK_TEXT_FLOATING_FRAME:
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_FLOATING_FRAME );
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
break;
case XML_TOK_TEXT_PLUGIN:
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_PLUGIN );
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_PLUGIN;
break;
case XML_TOK_TEXT_OBJECT_OLE:
bObjectOLE = sal_True;
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_OBJECT_OLE;
case XML_TOK_TEXT_OBJECT:
pContext = new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
bObjectOLE ? XML_TEXT_FRAME_OBJECT
: XML_TEXT_FRAME_OBJECT_OLE );
bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_OBJECT;
break;
case XML_TOK_DRAW_A:
pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER );
{
Reference < XTextRange > xAnchorPos =
rImport.GetTextImport()->GetCursor()->getStart();
XMLTextFrameHint_Impl *pHint =
new XMLTextFrameHint_Impl( xAnchorPos );
XMLTextFrameHyperlinkContext *pLinkContext =
new XMLTextFrameHyperlinkContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
&pHint->GetTextContentRef(),
&pHint->GetAnchorTypeRef() );
rHints.Insert( pHint, rHints.Count() );
pContext = pLinkContext;
}
break;
case XML_TOK_TEXT_TOC_MARK:
......@@ -1708,6 +1720,36 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
}
}
if( bInsertTextFrame )
{
if( XMLTextImportHelper::HasDrawNameAttribute( xAttrList, rImport.GetNamespaceMap() ) ||
rImport.GetTextImport()->IsInHeaderFooter() )
{
Reference < XTextRange > xAnchorPos =
rImport.GetTextImport()->GetCursor()->getStart();
XMLTextFrameContext *pTextFrameContext =
new XMLTextFrameContext( rImport, nPrefix,
rLocalName, xAttrList,
TextContentAnchorType_AS_CHARACTER,
nTextFrameType );
if( TextContentAnchorType_AT_CHARACTER ==
pTextFrameContext->GetAnchorType() &&
pTextFrameContext->GetTextContent().is() )
{
rHints.Insert( new XMLTextFrameHint_Impl(
pTextFrameContext->GetTextContent(), xAnchorPos ),
rHints.Count() );
}
pContext = pTextFrameContext;
}
else
{
Reference < XShapes > xShapes;
pContext = rImport.GetShapeImport()->CreateGroupChildContext(
rImport, nPrefix, rLocalName, xAttrList, xShapes );
}
}
return pContext;
}
......@@ -1883,6 +1925,17 @@ XMLParaContext::~XMLParaContext()
xRange, xContent, sal_True );
}
break;
case XML_HINT_TEXT_FRAME:
{
const XMLTextFrameHint_Impl *pFHint =
(const XMLTextFrameHint_Impl *)pHint;
if( pFHint->IsBoundAtChar() )
{
Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
pFHint->GetTextContent()->attach( xRange );
}
}
break;
default:
DBG_ASSERT( !this, "What's this" );
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment