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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLTextFrameContext.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -345,6 +345,7 @@ XMLTextFrameContext::XMLTextFrameContext( ...@@ -345,6 +345,7 @@ XMLTextFrameContext::XMLTextFrameContext(
TextContentAnchorType eATyp, TextContentAnchorType eATyp,
sal_uInt16 nNewType ) : sal_uInt16 nNewType ) :
nType( nNewType ), nType( nNewType ),
eAnchorType( eATyp ),
SvXMLImportContext( rImport, nPrfx, rLName ), SvXMLImportContext( rImport, nPrfx, rLName ),
sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")), sWidth(RTL_CONSTASCII_USTRINGPARAM("Width")),
sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")), sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth")),
...@@ -389,7 +390,6 @@ XMLTextFrameContext::XMLTextFrameContext( ...@@ -389,7 +390,6 @@ XMLTextFrameContext::XMLTextFrameContext(
sal_Int16 nRelHeight = 0; sal_Int16 nRelHeight = 0;
sal_Bool bMayScript = sal_False; sal_Bool bMayScript = sal_False;
TextContentAnchorType eAnchorType = eATyp;
sal_Bool bMinHeight = sal_False; sal_Bool bMinHeight = sal_False;
sal_Bool bSyncWidth = sal_False; sal_Bool bSyncWidth = sal_False;
...@@ -948,3 +948,7 @@ void XMLTextFrameContext::SetHyperlink( const OUString& rHRef, ...@@ -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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLTextFrameContext.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#endif #endif
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace text { class XTextCursor; } namespace text { class XTextCursor; class XTextContent; }
namespace beans { class XPropertySet; } namespace beans { class XPropertySet; }
} } } } } }
...@@ -114,6 +114,7 @@ class XMLTextFrameContext : public SvXMLImportContext ...@@ -114,6 +114,7 @@ class XMLTextFrameContext : public SvXMLImportContext
::rtl::OUString sDesc; ::rtl::OUString sDesc;
sal_uInt16 nType; sal_uInt16 nType;
::com::sun::star::text::TextContentAnchorType eAnchorType;
ParamMap aParamMap; ParamMap aParamMap;
public: public:
...@@ -140,6 +141,11 @@ public: ...@@ -140,6 +141,11 @@ public:
const ::rtl::OUString& rName, const ::rtl::OUString& rName,
const ::rtl::OUString& rTargetFrameName, const ::rtl::OUString& rTargetFrameName,
sal_Bool bMap ); 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 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLTextFrameHyperlinkContext.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -93,9 +93,13 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext( ...@@ -93,9 +93,13 @@ XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
SvXMLImport& rImport, SvXMLImport& rImport,
sal_uInt16 nPrfx, const OUString& rLName, sal_uInt16 nPrfx, const OUString& rLName,
const Reference< XAttributeList > & xAttrList, const Reference< XAttributeList > & xAttrList,
TextContentAnchorType eATyp ) : TextContentAnchorType eATyp,
Reference < XTextContent> *pTxtCntnt,
TextContentAnchorType *pAnchrType ) :
SvXMLImportContext( rImport, nPrfx, rLName ), SvXMLImportContext( rImport, nPrfx, rLName ),
eAnchorType( eATyp ), eAnchorType( eATyp ),
pTextContent( pTxtCntnt ),
pAnchorType( pAnchrType ),
bMap( sal_False ) bMap( sal_False )
{ {
OUString sShow; OUString sShow;
...@@ -164,22 +168,29 @@ SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext( ...@@ -164,22 +168,29 @@ SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext(
const Reference< XAttributeList > & xAttrList ) const Reference< XAttributeList > & xAttrList )
{ {
SvXMLImportContext *pContext = 0; SvXMLImportContext *pContext = 0;
XMLTextFrameContext *pTextFrameContext = 0;
if( XML_NAMESPACE_DRAW == nPrefix && if( XML_NAMESPACE_DRAW == nPrefix &&
rLocalName.equalsAsciiL( sXML_text_box, sizeof(sXML_text_box)-1 ) ) rLocalName.equalsAsciiL( sXML_text_box, sizeof(sXML_text_box)-1 ) )
pContext = new XMLTextFrameContext( GetImport(), nPrefix, pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
rLocalName, xAttrList, rLocalName, xAttrList,
eAnchorType, eAnchorType,
XML_TEXT_FRAME_TEXTBOX); XML_TEXT_FRAME_TEXTBOX);
else if( XML_NAMESPACE_DRAW == nPrefix && else if( XML_NAMESPACE_DRAW == nPrefix &&
rLocalName.equalsAsciiL( sXML_image, sizeof(sXML_image)-1 ) ) rLocalName.equalsAsciiL( sXML_image, sizeof(sXML_image)-1 ) )
pContext = new XMLTextFrameContext( GetImport(), nPrefix, pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
rLocalName, xAttrList, rLocalName, xAttrList,
eAnchorType, eAnchorType,
XML_TEXT_FRAME_GRAPHIC ); XML_TEXT_FRAME_GRAPHIC );
if( pContext ) if( pTextFrameContext )
((XMLTextFrameContext *)pContext)-> {
SetHyperlink( sHRef, sName, sTargetFrameName, bMap ); pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
if( pAnchorType )
*pAnchorType = pTextFrameContext->GetAnchorType();
if( pTextContent )
*pTextContent = pTextFrameContext->GetTextContent();
pContext = pTextFrameContext;
}
else else
pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: XMLTextFrameHyperlinkContext.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -65,13 +65,16 @@ ...@@ -65,13 +65,16 @@
#ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP #ifndef _COM_SUN_STAR_TEXT_TEXTCONTENTANCHORTYPE_HPP
#include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTFRAME_HPP
#include <com/sun/star/text/XTextFrame.hpp>
#endif
#ifndef _XMLOFF_XMLICTXT_HXX #ifndef _XMLOFF_XMLICTXT_HXX
#include "xmlictxt.hxx" #include "xmlictxt.hxx"
#endif #endif
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace text { class XTextCursor; } namespace text { class XTextCursor; class XTextFrame; }
namespace beans { class XPropertySet; } namespace beans { class XPropertySet; }
} } } } } }
...@@ -82,6 +85,9 @@ class XMLTextFrameHyperlinkContext : public SvXMLImportContext ...@@ -82,6 +85,9 @@ class XMLTextFrameHyperlinkContext : public SvXMLImportContext
::rtl::OUString sName; ::rtl::OUString sName;
::rtl::OUString sTargetFrameName; ::rtl::OUString sTargetFrameName;
::com::sun::star::text::TextContentAnchorType eAnchorType; ::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; sal_Bool bMap;
public: public:
...@@ -93,7 +99,10 @@ public: ...@@ -93,7 +99,10 @@ public:
const ::rtl::OUString& rLName, const ::rtl::OUString& rLName,
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList, ::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 ~XMLTextFrameHyperlinkContext();
virtual void EndElement(); virtual void EndElement();
...@@ -102,6 +111,7 @@ public: ...@@ -102,6 +111,7 @@ public:
const ::rtl::OUString& rLocalName, const ::rtl::OUString& rLocalName,
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & xAttrList ); ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
}; };
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: txtparai.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
#include <svtools/svarray.hxx> #include <svtools/svarray.hxx>
#endif #endif
#ifndef _COM_SUN_STAR_TEXT_XTEXT_HPP_ #ifndef _COM_SUN_STAR_TEXT_XTEXTFRAME_HPP_
//#include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextFrame.hpp>
#endif #endif
#ifndef _COM_SUN_STAR_TEXT_XTEXTCURSOR_HPP_ #ifndef _COM_SUN_STAR_TEXT_XTEXTCURSOR_HPP_
#include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/text/XTextCursor.hpp>
...@@ -157,6 +157,7 @@ using namespace ::com::sun::star::drawing; ...@@ -157,6 +157,7 @@ using namespace ::com::sun::star::drawing;
#define XML_HINT_HYPERLINK 3 #define XML_HINT_HYPERLINK 3
#define XML_HINT_RUBY 4 #define XML_HINT_RUBY 4
#define XML_HINT_INDEX_MARK 5 #define XML_HINT_INDEX_MARK 5
#define XML_HINT_TEXT_FRAME 6
class XMLHint_Impl class XMLHint_Impl
...@@ -339,6 +340,36 @@ public: ...@@ -339,6 +340,36 @@ public:
const OUString& GetText() const { return sText; } 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; typedef XMLHint_Impl *XMLHint_ImplPtr;
SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 ) SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 )
SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr ) SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr )
...@@ -1469,6 +1500,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( ...@@ -1469,6 +1500,8 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
sal_Bool& rIgnoreLeadingSpace ) sal_Bool& rIgnoreLeadingSpace )
{ {
SvXMLImportContext *pContext = 0; SvXMLImportContext *pContext = 0;
sal_Bool bInsertTextFrame = sal_False;
sal_uInt16 nTextFrameType = 0;
sal_Bool bObjectOLE = sal_False; sal_Bool bObjectOLE = sal_False;
switch( nToken ) switch( nToken )
...@@ -1577,71 +1610,50 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( ...@@ -1577,71 +1610,50 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
break; break;
case XML_TOK_TEXT_TEXTBOX: case XML_TOK_TEXT_TEXTBOX:
if( XMLTextImportHelper::HasDrawNameAttribute( xAttrList, rImport.GetNamespaceMap() ) || bInsertTextFrame = sal_True;
rImport.GetTextImport()->IsInHeaderFooter() ) nTextFrameType = XML_TEXT_FRAME_TEXTBOX;
{
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 );
}
break; break;
case XML_TOK_TEXT_IMAGE: case XML_TOK_TEXT_IMAGE:
if( XMLTextImportHelper::HasDrawNameAttribute( xAttrList, rImport.GetNamespaceMap() ) || bInsertTextFrame = sal_True;
rImport.GetTextImport()->IsInHeaderFooter() ) nTextFrameType = XML_TEXT_FRAME_GRAPHIC;
{
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 );
}
break; break;
case XML_TOK_TEXT_APPLET: case XML_TOK_TEXT_APPLET:
pContext = new XMLTextFrameContext( rImport, nPrefix, bInsertTextFrame = sal_True;
rLocalName, xAttrList, nTextFrameType = XML_TEXT_FRAME_APPLET;
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_APPLET );
break; break;
case XML_TOK_TEXT_FLOATING_FRAME: case XML_TOK_TEXT_FLOATING_FRAME:
pContext = new XMLTextFrameContext( rImport, nPrefix, bInsertTextFrame = sal_True;
rLocalName, xAttrList, nTextFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_FLOATING_FRAME );
break; break;
case XML_TOK_TEXT_PLUGIN: case XML_TOK_TEXT_PLUGIN:
pContext = new XMLTextFrameContext( rImport, nPrefix, bInsertTextFrame = sal_True;
rLocalName, xAttrList, nTextFrameType = XML_TEXT_FRAME_PLUGIN;
TextContentAnchorType_AS_CHARACTER,
XML_TEXT_FRAME_PLUGIN );
break; break;
case XML_TOK_TEXT_OBJECT_OLE: case XML_TOK_TEXT_OBJECT_OLE:
bObjectOLE = sal_True; bInsertTextFrame = sal_True;
nTextFrameType = XML_TEXT_FRAME_OBJECT_OLE;
case XML_TOK_TEXT_OBJECT: case XML_TOK_TEXT_OBJECT:
pContext = new XMLTextFrameContext( rImport, nPrefix, bInsertTextFrame = sal_True;
rLocalName, xAttrList, nTextFrameType = XML_TEXT_FRAME_OBJECT;
TextContentAnchorType_AS_CHARACTER,
bObjectOLE ? XML_TEXT_FRAME_OBJECT
: XML_TEXT_FRAME_OBJECT_OLE );
break; break;
case XML_TOK_DRAW_A: case XML_TOK_DRAW_A:
pContext = new XMLTextFrameHyperlinkContext( rImport, nPrefix, {
rLocalName, xAttrList, Reference < XTextRange > xAnchorPos =
TextContentAnchorType_AS_CHARACTER ); 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; break;
case XML_TOK_TEXT_TOC_MARK: case XML_TOK_TEXT_TOC_MARK:
...@@ -1708,6 +1720,36 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext( ...@@ -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; return pContext;
} }
...@@ -1883,6 +1925,17 @@ XMLParaContext::~XMLParaContext() ...@@ -1883,6 +1925,17 @@ XMLParaContext::~XMLParaContext()
xRange, xContent, sal_True ); xRange, xContent, sal_True );
} }
break; 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: default:
DBG_ASSERT( !this, "What's this" ); DBG_ASSERT( !this, "What's this" );
break; 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