summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore/unodraw.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/unocore/unodraw.cxx')
-rw-r--r--sw/source/core/unocore/unodraw.cxx69
1 files changed, 44 insertions, 25 deletions
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 3a22c81daaab..2511dfadb591 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -38,16 +38,20 @@
#include <unodraw.hxx>
#include <unocoll.hxx>
#include <unoframe.hxx>
+#include <unoparagraph.hxx>
+#include <unotextrange.hxx>
#include <unoprnms.hxx>
#include <svx/unoprnms.hxx>
#include <swunohelper.hxx>
#include <doc.hxx>
+#include <fmtcntnt.hxx>
#include <fmtflcnt.hxx>
#include <txtatr.hxx>
#include <docsh.hxx>
#include <unomap.hxx>
#include <unoport.hxx>
#include <unocrsr.hxx>
+#include <TextCursorHelper.hxx>
#include <swundo.hxx>
#include <dflyobj.hxx>
#include <ndtxt.hxx>
@@ -156,7 +160,9 @@ public:
SwFmtAnchor* GetAnchor(sal_Bool bCreate = sal_False)
{
if(bCreate && !pAnchor)
- pAnchor = new SwFmtAnchor(FLY_IN_CNTNT);
+ {
+ pAnchor = new SwFmtAnchor(FLY_AS_CHAR);
+ }
return pAnchor;
}
SwFmtHoriOrient* GetHOrient(sal_Bool bCreate = sal_False)
@@ -429,7 +435,8 @@ uno::Reference< drawing::XShape > SwFmDrawPage::_CreateShape( SdrObject *pObj )
****************************************************************************/
namespace
{
- class SwXShapesEnumeration : public SwSimpleEnumerationBaseClass
+ class SwXShapesEnumeration
+ : public SwSimpleEnumeration_Base
{
private:
typedef ::std::slist< ::com::sun::star::uno::Any > shapescontainer_t;
@@ -693,7 +700,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
SfxItemSet aSet( pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
RES_FRMATR_END-1 );
- SwFmtAnchor aAnchor( FLY_IN_CNTNT );
+ SwFmtAnchor aAnchor( FLY_AS_CHAR );
sal_Bool bOpaque = sal_False;
if( pDesc )
{
@@ -770,18 +777,22 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
if( pDesc && (xRg = pDesc->GetTextRange()).is() )
{
pInternalPam = new SwUnoInternalPaM(*pDoc);
- if(SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg))
+ if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg))
{
if(FLY_AT_FLY == aAnchor.GetAnchorId() &&
!pInternalPam->GetNode()->FindFlyStartNode())
- aAnchor.SetType(FLY_IN_CNTNT);
- else if(FLY_PAGE == aAnchor.GetAnchorId())
+ {
+ aAnchor.SetType(FLY_AS_CHAR);
+ }
+ else if (FLY_AT_PAGE == aAnchor.GetAnchorId())
+ {
aAnchor.SetAnchor(pInternalPam->Start());
+ }
}
else
throw uno::RuntimeException();
}
- else if( aAnchor.GetAnchorId() != FLY_PAGE && pDoc->GetRootFrm() )
+ else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && pDoc->GetRootFrm())
{
SwCrsrMoveState aState( MV_SETONLYTEXT );
Point aTmp(MM100_TO_TWIP(aMM100Pos.X), MM100_TO_TWIP(aMM100Pos.Y));
@@ -793,7 +804,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
}
else
{
- aAnchor.SetType(FLY_PAGE);
+ aAnchor.SetType(FLY_AT_PAGE);
// --> OD 2004-08-18 #i32349# - adjustment of vertical positioning
// attributes no longer needed, because its already got a default.
@@ -846,8 +857,11 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference<
for ( sal_uInt16 i = 0; !bFlyInCnt && i < rMarkList.GetMarkCount(); ++i )
{
const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
- if ( FLY_IN_CNTNT == ::FindFrmFmt( (SdrObject*)pObj )->GetAnchor().GetAnchorId() )
+ if (FLY_AS_CHAR == ::FindFrmFmt(const_cast<SdrObject*>(
+ pObj))->GetAnchor().GetAnchorId())
+ {
bFlyInCnt = sal_True;
+ }
}
if( bFlyInCnt )
throw uno::RuntimeException();
@@ -857,7 +871,9 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference<
pDoc->StartUndo( UNDO_START, NULL );
SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() );
- pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/,
+ pDoc->ChgAnchor(
+ pPage->GetDrawView()->GetMarkedObjectList(),
+ FLY_AT_PARA/*int eAnchorId*/,
sal_True, sal_False );
pPage->GetDrawView()->UnmarkAll();
@@ -892,7 +908,8 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeG
pDoc->StartUndo( UNDO_START, NULL );
pDoc->UnGroupSelection( *pPage->GetDrawView() );
- pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_CNTNT/*int eAnchorId*/,
+ pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(),
+ FLY_AT_PARA/*int eAnchorId*/,
sal_True, sal_False );
pDoc->EndUndo( UNDO_END, NULL );
}
@@ -1267,7 +1284,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
else if ( FN_TEXT_RANGE == pEntry->nWID )
{
SwFmtAnchor aAnchor( static_cast<const SwFmtAnchor&>(aSet.Get( RES_ANCHOR )) );
- if ( aAnchor.GetAnchorId() == FLY_PAGE )
+ if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
{
// set property <TextRange> not valid for to-page anchored shapes
throw lang::IllegalArgumentException();
@@ -1278,9 +1295,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
new SwUnoInternalPaM( *(pFmt->GetDoc()) );
uno::Reference< text::XTextRange > xRg;
aValue >>= xRg;
- if ( SwXTextRange::XTextRangeToSwPaM(*pInternalPam, xRg) )
+ if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
{
- if(aAnchor.GetAnchorId() == FLY_IN_CNTNT)
+ if (aAnchor.GetAnchorId() == FLY_AS_CHAR)
{
//delete old SwFmtFlyCnt
//With AnchorAsCharacter the current TxtAttribute has to be deleted.
@@ -1368,7 +1385,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
SwFrmFmt *pFlyFmt = FindFrmFmt( pObj );
pFlyFmt->DelFrms();
if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
- FLY_IN_CNTNT == eOldAnchorId )
+ (FLY_AS_CHAR == eOldAnchorId))
{
//With AnchorAsCharacter the current TxtAttribute has to be deleted.
//Tbis removes the frame format too.
@@ -1391,7 +1408,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
}
else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
- FLY_PAGE == eOldAnchorId )
+ (FLY_AT_PAGE == eOldAnchorId))
{
SwFmtAnchor aNewAnchor( dynamic_cast< const SwFmtAnchor& >( aSet.Get( RES_ANCHOR ) ) );
//if the fly has been anchored at page then it needs to be connected
@@ -1414,7 +1431,7 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A
pFmt->SetFmtAttr(aSet);
bSetAttr = false;
if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
- FLY_IN_CNTNT != eOldAnchorId )
+ (FLY_AS_CHAR != eOldAnchorId))
{
//the RES_TXTATR_FLYCNT needs to be added now
SwTxtNode *pNd = aPam.GetNode()->GetTxtNode();
@@ -1599,7 +1616,7 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName)
else if ( FN_TEXT_RANGE == pEntry->nWID )
{
const SwFmtAnchor aAnchor = pFmt->GetAnchor();
- if ( aAnchor.GetAnchorId() == FLY_PAGE )
+ if (aAnchor.GetAnchorId() == FLY_AT_PAGE)
{
// return nothing, because property <TextRange> isn't
// valid for to-page anchored shapes
@@ -1610,9 +1627,9 @@ uno::Any SwXShape::getPropertyValue(const rtl::OUString& rPropertyName)
{
if ( aAnchor.GetCntntAnchor() )
{
- uno::Reference< text::XTextRange > xTextRange =
- SwXTextRange::CreateTextRangeFromPosition(
- pFmt->GetDoc(),
+ const uno::Reference< text::XTextRange > xTextRange
+ = SwXTextRange::CreateXTextRange(
+ *pFmt->GetDoc(),
*aAnchor.GetCntntAnchor(),
0L );
aRet.setValue(&xTextRange, ::getCppuType((uno::Reference<text::XTextRange>*)0));
@@ -2134,7 +2151,9 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
pDoc = pPortion->GetCursor()->GetDoc();
}
else if ( !pDoc && pParagraph && pParagraph->GetTxtNode( ) )
- pDoc = pParagraph->GetTxtNode( )->GetDoc( );
+ {
+ pDoc = const_cast<SwDoc*>(pParagraph->GetTxtNode()->GetDoc());
+ }
}
@@ -2173,11 +2192,11 @@ uno::Reference< text::XTextRange > SwXShape::getAnchor(void) throw( uno::Runtim
const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
// return an anchor for non-page bound frames
// and for page bound frames that have a page no == NULL and a content position
- if( rAnchor.GetAnchorId() != FLY_PAGE ||
+ if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) ||
(rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum()))
{
const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
- aRef = SwXTextRange::CreateTextRangeFromPosition(pFmt->GetDoc(), rPos, 0);
+ aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0);
}
}
else
@@ -2217,7 +2236,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException )
pObj->IsInserted() )
// <--
{
- if( pFmt->GetAnchor().GetAnchorId() == FLY_IN_CNTNT )
+ if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR)
{
const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor());
SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();