2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <editsh.hxx>
|
2010-11-25 14:31:08 +01:00
|
|
|
#include <doc.hxx>
|
|
|
|
#include <IDocumentUndoRedo.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <pam.hxx>
|
|
|
|
#include <docary.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <swundo.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <section.hxx>
|
|
|
|
#include <edimp.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <sectfrm.hxx>
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#include <tabfrm.hxx>
|
|
|
|
#include <rootfrm.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
2010-03-16 11:28:30 +01:00
|
|
|
SwSection const*
|
|
|
|
SwEditShell::InsertSection(
|
|
|
|
SwSectionData & rNewData, SfxItemSet const*const pAttr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwSection* pRet = 0;
|
|
|
|
if( !IsTableMode() )
|
|
|
|
{
|
|
|
|
StartAllAction();
|
2010-11-25 14:31:08 +01:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-09-21 13:57:41 +02:00
|
|
|
FOREACHPAM_START(GetCrsr())
|
2010-03-16 11:28:29 +01:00
|
|
|
SwSection const*const pNew =
|
2010-03-16 11:28:30 +01:00
|
|
|
GetDoc()->InsertSwSection( *PCURCRSR, rNewData, 0, pAttr );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pRet )
|
|
|
|
pRet = pNew;
|
|
|
|
FOREACHPAM_END()
|
|
|
|
|
2010-11-25 14:31:08 +01:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL );
|
2000-09-18 23:08:29 +00:00
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwEditShell::IsInsRegionAvailable() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2009-08-27 15:54:55 +00:00
|
|
|
if( IsTableMode() )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2009-08-27 15:54:55 +00:00
|
|
|
SwPaM* pCrsr = GetCrsr();
|
|
|
|
if( pCrsr->GetNext() != pCrsr )
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pCrsr->HasMark() )
|
|
|
|
return 0 != GetDoc()->IsInsRegionAvailable( *pCrsr );
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const SwSection* SwEditShell::GetCurrSection() const
|
|
|
|
{
|
|
|
|
if( IsTableMode() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return GetDoc()->GetCurrSection( *GetCrsr()->GetPoint() );
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:31:37 +02:00
|
|
|
/** Deliver the responsible area of the columns.
|
|
|
|
*
|
|
|
|
* In footnotes it may not be the area within the footnote.
|
2013-02-24 00:42:37 +01:00
|
|
|
*/
|
2011-01-17 15:06:54 +01:00
|
|
|
const SwSection* SwEditShell::GetAnySection( sal_Bool bOutOfTab, const Point* pPt ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-05-08 07:58:18 +00:00
|
|
|
SwFrm *pFrm;
|
|
|
|
if ( pPt )
|
|
|
|
{
|
|
|
|
SwPosition aPos( *GetCrsr()->GetPoint() );
|
|
|
|
Point aPt( *pPt );
|
|
|
|
GetLayout()->GetCrsrOfst( &aPos, aPt );
|
|
|
|
SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
|
2010-06-13 15:22:56 +02:00
|
|
|
pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
|
2001-05-08 07:58:18 +00:00
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
pFrm = GetCurrFrm( sal_False );
|
2001-05-08 07:58:18 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bOutOfTab && pFrm )
|
|
|
|
pFrm = pFrm->FindTabFrm();
|
|
|
|
if( pFrm && pFrm->IsInSct() )
|
|
|
|
{
|
|
|
|
SwSectionFrm* pSect = pFrm->FindSctFrm();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pSect, "GetAnySection: Where's my Sect?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pSect->IsInFtn() && pSect->GetUpper()->IsInSct() )
|
|
|
|
{
|
|
|
|
pSect = pSect->GetUpper()->FindSctFrm();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pSect, "GetAnySection: Where's my SectFrm?" );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return pSect->GetSection();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwEditShell::GetSectionFmtCount() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-06-20 16:36:51 +02:00
|
|
|
return GetDoc()->GetSections().size();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwEditShell::IsAnySectionInDoc( sal_Bool bChkReadOnly, sal_Bool bChkHidden, sal_Bool bChkTOX ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwSectionFmts& rFmts = GetDoc()->GetSections();
|
2012-06-20 16:36:51 +02:00
|
|
|
sal_uInt16 nCnt = rFmts.size();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 n;
|
2003-12-01 16:03:35 +00:00
|
|
|
|
|
|
|
for( n = 0; n < nCnt; ++n )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SectionType eTmpType;
|
|
|
|
const SwSectionFmt* pFmt = rFmts[ n ];
|
|
|
|
if( pFmt->IsInNodesArr() &&
|
|
|
|
(bChkTOX ||
|
2010-11-04 13:05:15 +01:00
|
|
|
( (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION
|
|
|
|
&& TOX_HEADER_SECTION != eTmpType ) ) )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwSection& rSect = *rFmts[ n ]->GetSection();
|
|
|
|
if( (!bChkReadOnly && !bChkHidden ) ||
|
|
|
|
(bChkReadOnly && rSect.IsProtectFlag() ) ||
|
|
|
|
(bChkHidden && rSect.IsHiddenFlag() ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return n != nCnt;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwEditShell::GetSectionFmtPos( const SwSectionFmt& rFmt ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwSectionFmt* pFmt = (SwSectionFmt*)&rFmt;
|
|
|
|
return GetDoc()->GetSections().GetPos( pFmt );
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
const SwSectionFmt& SwEditShell::GetSectionFmt( sal_uInt16 nFmt ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return *GetDoc()->GetSections()[ nFmt ];
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwEditShell::DelSectionFmt( sal_uInt16 nFmt )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
|
|
|
GetDoc()->DelSectionFmt( GetDoc()->GetSections()[ nFmt ] );
|
2013-02-24 00:42:37 +01:00
|
|
|
// Call the AttrChangeNotify on the UI page.
|
2000-09-18 23:08:29 +00:00
|
|
|
CallChgLnk();
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2010-03-16 11:28:30 +01:00
|
|
|
void SwEditShell::UpdateSection(sal_uInt16 const nSect,
|
|
|
|
SwSectionData & rNewData, SfxItemSet const*const pAttr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
2010-03-16 11:28:30 +01:00
|
|
|
GetDoc()->UpdateSection( nSect, rNewData, pAttr );
|
2013-02-24 00:42:37 +01:00
|
|
|
// Call the AttrChangeNotify on the UI page.
|
2000-09-18 23:08:29 +00:00
|
|
|
CallChgLnk();
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2013-08-15 21:13:04 +02:00
|
|
|
OUString SwEditShell::GetUniqueSectionName( const OUString* pChkStr ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return GetDoc()->GetUniqueSectionName( pChkStr );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::SetSectionAttr( const SfxItemSet& rSet,
|
|
|
|
SwSectionFmt* pSectFmt )
|
|
|
|
{
|
|
|
|
if( pSectFmt )
|
|
|
|
_SetSectionAttr( *pSectFmt, rSet );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// for all section in the selection
|
|
|
|
|
2013-09-21 13:57:41 +02:00
|
|
|
FOREACHPAM_START(GetCrsr())
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
const SwPosition* pStt = PCURCRSR->Start(),
|
|
|
|
* pEnd = PCURCRSR->End();
|
|
|
|
|
|
|
|
const SwSectionNode* pSttSectNd = pStt->nNode.GetNode().FindSectionNode(),
|
|
|
|
* pEndSectNd = pEnd->nNode.GetNode().FindSectionNode();
|
|
|
|
|
|
|
|
if( pSttSectNd || pEndSectNd )
|
|
|
|
{
|
|
|
|
if( pSttSectNd )
|
|
|
|
_SetSectionAttr( *pSttSectNd->GetSection().GetFmt(),
|
|
|
|
rSet );
|
|
|
|
if( pEndSectNd && pSttSectNd != pEndSectNd )
|
|
|
|
_SetSectionAttr( *pEndSectNd->GetSection().GetFmt(),
|
|
|
|
rSet );
|
|
|
|
|
|
|
|
if( pSttSectNd && pEndSectNd )
|
|
|
|
{
|
|
|
|
SwNodeIndex aSIdx( pStt->nNode );
|
|
|
|
SwNodeIndex aEIdx( pEnd->nNode );
|
|
|
|
if( pSttSectNd->EndOfSectionIndex() <
|
|
|
|
pEndSectNd->GetIndex() )
|
|
|
|
{
|
|
|
|
aSIdx = pSttSectNd->EndOfSectionIndex() + 1;
|
|
|
|
aEIdx = *pEndSectNd;
|
|
|
|
}
|
|
|
|
|
|
|
|
while( aSIdx < aEIdx )
|
|
|
|
{
|
|
|
|
if( 0 != (pSttSectNd = aSIdx.GetNode().GetSectionNode())
|
|
|
|
|| ( aSIdx.GetNode().IsEndNode() &&
|
|
|
|
0 != ( pSttSectNd = aSIdx.GetNode().
|
2006-08-14 15:10:01 +00:00
|
|
|
StartOfSectionNode()->GetSectionNode())) )
|
2000-09-18 23:08:29 +00:00
|
|
|
_SetSectionAttr( *pSttSectNd->GetSection().GetFmt(),
|
|
|
|
rSet );
|
2012-10-15 23:31:02 +02:00
|
|
|
++aSIdx;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwEditShell::_SetSectionAttr( SwSectionFmt& rSectFmt,
|
|
|
|
const SfxItemSet& rSet )
|
|
|
|
{
|
|
|
|
StartAllAction();
|
2011-01-17 15:06:54 +01:00
|
|
|
if(SFX_ITEM_SET == rSet.GetItemState(RES_CNTNT, sal_False))
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SfxItemSet aSet(rSet);
|
|
|
|
aSet.ClearItem(RES_CNTNT);
|
|
|
|
GetDoc()->SetAttr( aSet, rSectFmt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
GetDoc()->SetAttr( rSet, rSectFmt );
|
|
|
|
|
2013-02-24 00:42:37 +01:00
|
|
|
// Call the AttrChangeNotify on the UI page.
|
2000-09-18 23:08:29 +00:00
|
|
|
CallChgLnk();
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:31:37 +02:00
|
|
|
/** Search inside the cursor selection for full selected sections.
|
|
|
|
*
|
|
|
|
* @return If any part of section in the selection return 0, if more than one return the count.
|
|
|
|
*/
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwEditShell::GetFullSelectedSectionCount() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRet = 0;
|
2013-09-21 13:57:41 +02:00
|
|
|
FOREACHPAM_START(GetCrsr())
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
const SwPosition* pStt = PCURCRSR->Start(),
|
|
|
|
* pEnd = PCURCRSR->End();
|
|
|
|
const SwCntntNode* pCNd;
|
|
|
|
// check the selection, if Start at Node begin and End at Node end
|
|
|
|
if( pStt->nContent.GetIndex() ||
|
|
|
|
( 0 == ( pCNd = pEnd->nNode.GetNode().GetCntntNode() )) ||
|
|
|
|
pCNd->Len() != pEnd->nContent.GetIndex() )
|
|
|
|
{
|
|
|
|
nRet = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-02-24 00:42:37 +01:00
|
|
|
// !!!
|
2000-09-18 23:08:29 +00:00
|
|
|
// what about table at start or end ?
|
|
|
|
// There is no selection possible!
|
|
|
|
// What about only a table inside the section ?
|
|
|
|
// There is only a table selection possible!
|
|
|
|
|
|
|
|
SwNodeIndex aSIdx( pStt->nNode, -1 ), aEIdx( pEnd->nNode, +1 );
|
|
|
|
if( !aSIdx.GetNode().IsSectionNode() ||
|
|
|
|
!aEIdx.GetNode().IsEndNode() ||
|
2006-08-14 15:10:01 +00:00
|
|
|
!aEIdx.GetNode().StartOfSectionNode()->IsSectionNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
nRet = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++nRet;
|
2006-08-14 15:10:01 +00:00
|
|
|
if( &aSIdx.GetNode() != aEIdx.GetNode().StartOfSectionNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
++nRet;
|
|
|
|
|
|
|
|
FOREACHPAM_END()
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
|
2013-06-09 00:31:37 +02:00
|
|
|
/** Find the suitable node for a special insert (alt-enter).
|
|
|
|
*
|
2003-03-27 14:45:43 +00:00
|
|
|
* This should enable inserting text before/after sections and tables.
|
|
|
|
*
|
|
|
|
* A node is found if:
|
|
|
|
* 1) the innermost table/section is not in a write-protected area
|
|
|
|
* 2) pCurrentPos is at or just before an end node
|
|
|
|
* (or at or just after a start node)
|
|
|
|
* 3) there are only start/end nodes between pCurrentPos and the innermost
|
|
|
|
* table/section
|
|
|
|
*
|
|
|
|
* If a suitable node is found, an SwNode* is returned; else it is NULL.
|
|
|
|
*/
|
2012-10-12 16:49:40 +02:00
|
|
|
static const SwNode* lcl_SpecialInsertNode(const SwPosition* pCurrentPos)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
const SwNode* pReturn = NULL;
|
|
|
|
|
|
|
|
// the current position
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( pCurrentPos != NULL, "Strange, we have no position!" );
|
2003-03-27 14:45:43 +00:00
|
|
|
const SwNode& rCurrentNode = pCurrentPos->nNode.GetNode();
|
|
|
|
|
|
|
|
// find innermost section or table. At the end of this scope,
|
|
|
|
// pInntermostNode contain the section/table before/after which we should
|
|
|
|
// insert our empty paragraph, or it will be NULL if none is found.
|
|
|
|
const SwNode* pInnermostNode = NULL;
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
const SwNode* pTableNode = rCurrentNode.FindTableNode();
|
|
|
|
const SwNode* pSectionNode = rCurrentNode.FindSectionNode();
|
|
|
|
|
|
|
|
// find the table/section which is close
|
|
|
|
if( pTableNode == NULL )
|
|
|
|
pInnermostNode = pSectionNode;
|
|
|
|
else if ( pSectionNode == NULL )
|
|
|
|
pInnermostNode = pTableNode;
|
|
|
|
else
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
// compare and choose the larger one
|
|
|
|
pInnermostNode =
|
|
|
|
( pSectionNode->GetIndex() > pTableNode->GetIndex() )
|
|
|
|
? pSectionNode : pTableNode;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// The previous version had a check to skip empty read-only sections. Those
|
|
|
|
// shouldn't occur, so we only need to check whether our pInnermostNode is
|
|
|
|
// inside a protected area.
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// Now, pInnermostNode is NULL or the innermost section or table node.
|
|
|
|
if( (pInnermostNode != NULL) && !pInnermostNode->IsProtect() )
|
|
|
|
{
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( pInnermostNode->IsTableNode() ||
|
2003-03-27 14:45:43 +00:00
|
|
|
pInnermostNode->IsSectionNode(), "wrong node found" );
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( ( pInnermostNode->GetIndex() <= rCurrentNode.GetIndex() )&&
|
2003-03-27 14:45:43 +00:00
|
|
|
( pInnermostNode->EndOfSectionNode()->GetIndex() >=
|
|
|
|
rCurrentNode.GetIndex() ), "wrong node found" );
|
|
|
|
|
|
|
|
// we now need to find the possible start/end positions
|
|
|
|
|
|
|
|
// we found a start if
|
|
|
|
// - we're at or just before a start node
|
|
|
|
// - there are only start nodes between the current and pInnermostNode
|
|
|
|
SwNodeIndex aBegin( pCurrentPos->nNode );
|
|
|
|
if( rCurrentNode.IsCntntNode() &&
|
|
|
|
(pCurrentPos->nContent.GetIndex() == 0))
|
|
|
|
aBegin--;
|
|
|
|
while( (aBegin != pInnermostNode->GetIndex()) &&
|
|
|
|
aBegin.GetNode().IsStartNode() )
|
|
|
|
aBegin--;
|
|
|
|
bool bStart = ( aBegin == pInnermostNode->GetIndex() );
|
|
|
|
|
|
|
|
// we found an end if
|
|
|
|
// - we're at or just before an end node
|
|
|
|
// - there are only end nodes between the current node and
|
|
|
|
// pInnermostNode's end node
|
|
|
|
SwNodeIndex aEnd( pCurrentPos->nNode );
|
|
|
|
if( rCurrentNode.IsCntntNode() &&
|
|
|
|
( pCurrentPos->nContent.GetIndex() ==
|
|
|
|
rCurrentNode.GetCntntNode()->Len() ) )
|
2012-10-15 23:31:02 +02:00
|
|
|
++aEnd;
|
2003-03-27 14:45:43 +00:00
|
|
|
while( (aEnd != pInnermostNode->EndOfSectionNode()->GetIndex()) &&
|
|
|
|
aEnd.GetNode().IsEndNode() )
|
2012-10-15 23:31:02 +02:00
|
|
|
++aEnd;
|
2003-03-27 14:45:43 +00:00
|
|
|
bool bEnd = ( aEnd == pInnermostNode->EndOfSectionNode()->GetIndex() );
|
|
|
|
|
|
|
|
// evalutate result: if both start + end, end is preferred
|
|
|
|
if( bEnd )
|
|
|
|
pReturn = pInnermostNode->EndOfSectionNode();
|
|
|
|
else if ( bStart )
|
|
|
|
pReturn = pInnermostNode;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2003-03-27 14:45:43 +00:00
|
|
|
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( ( pReturn == NULL ) || pReturn->IsStartNode() ||
|
2003-03-27 14:45:43 +00:00
|
|
|
pReturn->IsEndNode(),
|
|
|
|
"SpecialInsertNode failed" );
|
|
|
|
return pReturn;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
/** a node can be special-inserted (alt-Enter) whenever lcl_SpecialInsertNode
|
|
|
|
finds a suitable position
|
|
|
|
*/
|
|
|
|
bool SwEditShell::CanSpecialInsert() const
|
|
|
|
{
|
|
|
|
return NULL != lcl_SpecialInsertNode( GetCrsr()->GetPoint() );
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:31:37 +02:00
|
|
|
/** check whether a node can be special-inserted (alt-Enter), and do so. Return
|
2003-03-27 14:45:43 +00:00
|
|
|
whether insertion was possible.
|
|
|
|
*/
|
|
|
|
bool SwEditShell::DoSpecialInsert()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
bool bRet = false;
|
|
|
|
|
|
|
|
// get current node
|
|
|
|
SwPosition* pCursorPos = GetCrsr()->GetPoint();
|
|
|
|
const SwNode* pInsertNode = lcl_SpecialInsertNode( pCursorPos );
|
|
|
|
if( pInsertNode != NULL )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// adjust insert position to insert before start nodes and after end
|
|
|
|
// nodes
|
|
|
|
SwNodeIndex aInsertIndex( *pInsertNode,
|
|
|
|
pInsertNode->IsStartNode() ? -1 : 0 );
|
|
|
|
SwPosition aInsertPos( aInsertIndex );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// insert a new text node, and set the cursor
|
|
|
|
bRet = GetDoc()->AppendTxtNode( aInsertPos );
|
|
|
|
*pCursorPos = aInsertPos;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
// call AttrChangeNotify for the UI
|
2000-09-18 23:08:29 +00:00
|
|
|
CallChgLnk();
|
2003-03-27 14:45:43 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2003-03-27 14:45:43 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|