diff options
author | Michael Brauer <mib@openoffice.org> | 2001-03-09 06:23:23 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2001-03-09 06:23:23 +0000 |
commit | f8910a64102bc9f784dcb8e9772fc8479e5ec8a0 (patch) | |
tree | 8e6bd8e80f451182b9d3fbc37e9356bf78fc5f41 | |
parent | f1d265645f2252debe9bddc715520ad6e75ddbe1 (diff) |
remove section's last paragraph safely
-rw-r--r-- | xmloff/inc/XMLTextHeaderFooterContext.hxx | 8 | ||||
-rw-r--r-- | xmloff/source/text/XMLChangedRegionImportContext.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/text/XMLFootnoteImportContext.cxx | 11 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextHeaderFooterContext.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 44 |
6 files changed, 57 insertions, 57 deletions
diff --git a/xmloff/inc/XMLTextHeaderFooterContext.hxx b/xmloff/inc/XMLTextHeaderFooterContext.hxx index 44a79e197691..5d98acaab751 100644 --- a/xmloff/inc/XMLTextHeaderFooterContext.hxx +++ b/xmloff/inc/XMLTextHeaderFooterContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextHeaderFooterContext.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-10-26 09:17:54 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:21:26 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,7 +67,7 @@ #endif namespace com { namespace sun { namespace star { - namespace text { class XTextCursor; class XTextContent; } + namespace text { class XTextCursor; } namespace beans { class XPropertySet; } } } } @@ -76,8 +76,6 @@ class XMLTextHeaderFooterContext: public SvXMLImportContext ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextCursor > xOldTextCursor; ::com::sun::star::uno::Reference < - ::com::sun::star::text::XTextContent > xTextContent; - ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > xPropSet; const ::rtl::OUString sOn; diff --git a/xmloff/source/text/XMLChangedRegionImportContext.cxx b/xmloff/source/text/XMLChangedRegionImportContext.cxx index d662ddccfc83..1475dffd9b29 100644 --- a/xmloff/source/text/XMLChangedRegionImportContext.cxx +++ b/xmloff/source/text/XMLChangedRegionImportContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLChangedRegionImportContext.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dvo $ $Date: 2001-01-16 10:51:15 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:23:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -191,10 +191,7 @@ void XMLChangedRegionImportContext::EndElement() // (one extra paragraph was inserted in the beginning) UniReference<XMLTextImportHelper> rHelper = GetImport().GetTextImport(); - rHelper->GetCursor()->goRight(1, sal_False); - rHelper->GetCursor()->goLeft(1, sal_True); - rHelper->GetText()->insertString(rHelper->GetCursorAsRange(), - sEmpty, sal_True); + rHelper->DeleteParagraph(); GetImport().GetTextImport()->SetCursor(xOldCursor); xOldCursor = NULL; diff --git a/xmloff/source/text/XMLFootnoteImportContext.cxx b/xmloff/source/text/XMLFootnoteImportContext.cxx index d40875b0b776..0b07d28c2d72 100644 --- a/xmloff/source/text/XMLFootnoteImportContext.cxx +++ b/xmloff/source/text/XMLFootnoteImportContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLFootnoteImportContext.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2001-01-02 14:41:37 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:23:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -225,12 +225,7 @@ void XMLFootnoteImportContext::Characters( void XMLFootnoteImportContext::EndElement() { // get rid of last dummy paragraph - if( rHelper.GetCursor()->goLeft( 1, sal_True )) - { - OUString sEmpty; - rHelper.GetText()->insertString( rHelper.GetCursorAsRange(), - sEmpty, sal_True ); - } + rHelper.DeleteParagraph(); // reinstall old cursor rHelper.SetCursor(xOldCursor); diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 0db1015942ad..3aa1511a4504 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextFrameContext.cxx,v $ * - * $Revision: 1.26 $ + * $Revision: 1.27 $ * - * last change: $Author: mib $ $Date: 2001-03-06 11:17:30 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:23:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -829,13 +829,7 @@ void XMLTextFrameContext::EndElement() if( xOldTextCursor.is() ) { - if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) - { - OUString sEmpty; - GetImport().GetTextImport()->GetText()->insertString( - GetImport().GetTextImport()->GetCursorAsRange(), sEmpty, - sal_True ); - } + GetImport().GetTextImport()->DeleteParagraph(); GetImport().GetTextImport()->SetCursor( xOldTextCursor ); } if ( nType == XML_TEXT_FRAME_APPLET ) diff --git a/xmloff/source/text/XMLTextHeaderFooterContext.cxx b/xmloff/source/text/XMLTextHeaderFooterContext.cxx index 4e869d9d82e9..3032fd2d45ec 100644 --- a/xmloff/source/text/XMLTextHeaderFooterContext.cxx +++ b/xmloff/source/text/XMLTextHeaderFooterContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextHeaderFooterContext.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mib $ $Date: 2000-11-01 12:15:32 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:23:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -216,13 +216,6 @@ SvXMLImportContext *XMLTextHeaderFooterContext::CreateChildContext( GetImport().GetTextImport()->CreateTextChildContext( GetImport(), nPrefix, rLocalName, xAttrList, XML_TEXT_TYPE_HEADER_FOOTER ); - if( pContext && pContext->ISA( XMLTextTableContext ) ) - { - xTextContent = PTR_CAST( XMLTextTableContext, pContext ) - ->GetXTextContent(); - } - else - xTextContent = 0; } if( !pContext ) pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); @@ -234,24 +227,7 @@ void XMLTextHeaderFooterContext::EndElement() { if( xOldTextCursor.is() ) { - if( xTextContent.is() ) - { - Reference< XRelativeTextContentRemove > xRemove( - GetImport().GetTextImport()->GetText(), UNO_QUERY ); - if( xRemove.is() ) - { - GetImport().GetTextImport()->ResetCursor(); - xRemove->removeTextContentAfter( xTextContent ); - } - } - else if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) ) - { - OUString sEmpty; - GetImport().GetTextImport()->GetText()->insertString( - GetImport().GetTextImport()->GetCursorAsRange(), sEmpty, - sal_True ); - } - + GetImport().GetTextImport()->DeleteParagraph(); GetImport().GetTextImport()->SetCursor( xOldTextCursor ); } else if( !bLeft ) diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 749e0d0b4787..d49cb8c5d80e 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.53 $ + * $Revision: 1.54 $ * - * last change: $Author: mib $ $Date: 2001-03-06 11:17:30 $ + * last change: $Author: mib $ $Date: 2001-03-09 07:23:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,9 @@ #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include <com/sun/star/beans/PropertyValue.hpp> #endif +#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XEnumerationAccess.hpp> +#endif #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> #endif @@ -915,6 +918,43 @@ void XMLTextImportHelper::InsertTextContent( xText->insertTextContent( xCursorAsRange, xContent, sal_False ); } +void XMLTextImportHelper::DeleteParagraph() +{ + DBG_ASSERT( xText.is(), "no text" ); + DBG_ASSERT( xCursor.is(), "no cursor" ); + DBG_ASSERT( xCursorAsRange.is(), "no range" ); + + sal_Bool bDelete = sal_True; + Reference < XEnumerationAccess > xEnumAccess( xCursor, UNO_QUERY ); + if( xEnumAccess.is() ) + { + Reference < XEnumeration > xEnum = xEnumAccess->createEnumeration(); + DBG_ASSERT( xEnum->hasMoreElements(), "empty text enumeration" ); + if( xEnum->hasMoreElements() ) + { + Any aAny = xEnum->nextElement(); + Reference < XTextRange > xTxtRange; + aAny >>= xTxtRange; + Reference < XComponent > xComp( xTxtRange, UNO_QUERY ); + DBG_ASSERT( xComp.is(), "got no component" ); + if( xComp.is() ) + { + xComp->dispose(); + bDelete = sal_False; + } + } + } + if( bDelete ) + { + if( xCursor->goLeft( 1, sal_True ) ) + { + OUString sEmpty; + xText->insertString( xCursorAsRange, sEmpty, sal_True ); + } + } +} + + OUString XMLTextImportHelper::SetStyleAndAttrs( const Reference < XTextCursor >& rCursor, const OUString& rStyleName, |