2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2007-06-27 12:22:26 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
2008-04-10 15:24:03 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-06-27 12:22:26 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
#include <unotextmarkup.hxx>
|
|
|
|
|
2010-10-16 03:22:02 -05:00
|
|
|
#include <osl/mutex.hxx>
|
2007-06-27 12:22:26 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <SwSmartTagMgr.hxx>
|
|
|
|
#include <com/sun/star/text/TextMarkupType.hpp>
|
2008-12-15 12:01:46 +00:00
|
|
|
#include <com/sun/star/text/TextMarkupDescriptor.hpp>
|
2007-06-27 12:22:26 +00:00
|
|
|
#include <com/sun/star/container/XStringKeyMap.hpp>
|
|
|
|
#include <ndtxt.hxx>
|
2008-07-16 12:31:58 +00:00
|
|
|
#include <SwGrammarMarkUp.hxx>
|
|
|
|
|
|
|
|
#include <IGrammarContact.hxx>
|
2007-06-27 12:22:26 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SwXTextMarkup
|
|
|
|
*/
|
|
|
|
SwXTextMarkup::SwXTextMarkup( SwTxtNode& rTxtNode, const ModelToViewHelper::ConversionMap* pMap )
|
|
|
|
: mpTxtNode( &rTxtNode ), mpConversionMap( pMap )
|
|
|
|
{
|
|
|
|
mpTxtNode->Add(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SwXTextMarkup::~SwXTextMarkup()
|
|
|
|
{
|
|
|
|
delete mpConversionMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< container::XStringKeyMap > SAL_CALL SwXTextMarkup::getMarkupInfoContainer() throw (uno::RuntimeException)
|
|
|
|
{
|
2010-10-13 01:44:10 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2007-06-27 12:22:26 +00:00
|
|
|
|
|
|
|
uno::Reference< container::XStringKeyMap > xProp = new SwXStringKeyMap;
|
|
|
|
return xProp;
|
|
|
|
}
|
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
void SAL_CALL SwXTextMarkup::commitTextMarkup(
|
|
|
|
::sal_Int32 nType,
|
|
|
|
const ::rtl::OUString & rIdentifier,
|
|
|
|
::sal_Int32 nStart,
|
|
|
|
::sal_Int32 nLength,
|
|
|
|
const uno::Reference< container::XStringKeyMap > & xMarkupInfoContainer)
|
|
|
|
throw (uno::RuntimeException)
|
2007-06-27 12:22:26 +00:00
|
|
|
{
|
2010-10-13 01:44:10 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2007-06-27 12:22:26 +00:00
|
|
|
|
|
|
|
// paragraph already dead or modified?
|
2008-07-16 12:31:58 +00:00
|
|
|
if ( !mpTxtNode || nLength <= 0 )
|
2007-06-27 12:22:26 +00:00
|
|
|
return;
|
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
if ( nType == text::TextMarkupType::SMARTTAG &&
|
|
|
|
!SwSmartTagMgr::Get().IsSmartTagTypeEnabled( rIdentifier ) )
|
2007-06-27 12:22:26 +00:00
|
|
|
return;
|
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
// get appropriate list to use...
|
|
|
|
SwWrongList* pWList = 0;
|
2008-07-16 12:31:58 +00:00
|
|
|
bool bRepaint = false;
|
|
|
|
if ( nType == text::TextMarkupType::SPELLCHECK )
|
2007-06-27 12:22:26 +00:00
|
|
|
{
|
2008-02-26 08:48:36 +00:00
|
|
|
pWList = mpTxtNode->GetWrong();
|
|
|
|
if ( !pWList )
|
2007-06-27 12:22:26 +00:00
|
|
|
{
|
2008-07-16 12:31:58 +00:00
|
|
|
pWList = new SwWrongList( WRONGLIST_SPELL );
|
2008-02-26 08:48:36 +00:00
|
|
|
mpTxtNode->SetWrong( pWList );
|
2007-06-27 12:22:26 +00:00
|
|
|
}
|
2008-02-26 08:48:36 +00:00
|
|
|
}
|
2008-12-15 12:01:46 +00:00
|
|
|
else if ( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
|
2008-02-26 08:48:36 +00:00
|
|
|
{
|
2008-07-16 12:31:58 +00:00
|
|
|
IGrammarContact *pGrammarContact = getGrammarContact( *mpTxtNode );
|
|
|
|
if( pGrammarContact )
|
|
|
|
{
|
|
|
|
pWList = pGrammarContact->getGrammarCheck( *mpTxtNode, true );
|
|
|
|
ASSERT( pWList, "GrammarContact _has_ to deliver a wrong list" )
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pWList = mpTxtNode->GetGrammarCheck();
|
|
|
|
if ( !pWList )
|
|
|
|
{
|
|
|
|
mpTxtNode->SetGrammarCheck( new SwGrammarMarkUp() );
|
|
|
|
pWList = mpTxtNode->GetGrammarCheck();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bRepaint = pWList == mpTxtNode->GetGrammarCheck();
|
|
|
|
if( pWList->GetBeginInv() < STRING_LEN )
|
|
|
|
((SwGrammarMarkUp*)pWList)->ClearGrammarList();
|
2008-02-26 08:48:36 +00:00
|
|
|
}
|
2008-07-16 12:31:58 +00:00
|
|
|
else if ( nType == text::TextMarkupType::SMARTTAG )
|
2008-02-26 08:48:36 +00:00
|
|
|
{
|
|
|
|
pWList = mpTxtNode->GetSmartTags();
|
|
|
|
if ( !pWList )
|
|
|
|
{
|
2008-07-16 12:31:58 +00:00
|
|
|
pWList = new SwWrongList( WRONGLIST_SMARTTAG );
|
2008-02-26 08:48:36 +00:00
|
|
|
mpTxtNode->SetSmartTags( pWList );
|
|
|
|
}
|
|
|
|
}
|
2008-07-16 12:31:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ASSERT( false, "Unknown mark-up type" )
|
|
|
|
return;
|
|
|
|
}
|
2007-06-27 12:22:26 +00:00
|
|
|
|
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
const ModelToViewHelper::ModelPosition aStartPos =
|
|
|
|
ModelToViewHelper::ConvertToModelPosition( mpConversionMap, nStart );
|
|
|
|
const ModelToViewHelper::ModelPosition aEndPos =
|
|
|
|
ModelToViewHelper::ConvertToModelPosition( mpConversionMap, nStart + nLength - 1);
|
2007-06-27 12:22:26 +00:00
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
const bool bStartInField = aStartPos.mbIsField;
|
|
|
|
const bool bEndInField = aEndPos.mbIsField;
|
|
|
|
bool bCommit = false;
|
|
|
|
|
|
|
|
if ( bStartInField && bEndInField && aStartPos.mnPos == aEndPos.mnPos )
|
|
|
|
{
|
2008-07-16 12:31:58 +00:00
|
|
|
nStart = aStartPos.mnSubPos;
|
2008-02-26 08:48:36 +00:00
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
|
|
|
|
SwWrongList* pSubList = pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
2007-06-27 12:22:26 +00:00
|
|
|
{
|
2008-12-15 12:01:46 +00:00
|
|
|
if( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
|
2008-07-16 12:31:58 +00:00
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
else
|
|
|
|
pSubList = new SwWrongList( pWList->GetWrongListType() );
|
2008-02-26 08:48:36 +00:00
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
2007-06-27 12:22:26 +00:00
|
|
|
}
|
|
|
|
|
2008-02-26 08:48:36 +00:00
|
|
|
pWList = pSubList;
|
|
|
|
bCommit = true;
|
|
|
|
}
|
|
|
|
else if ( !bStartInField && !bEndInField )
|
|
|
|
{
|
|
|
|
nStart = aStartPos.mnPos;
|
|
|
|
bCommit = true;
|
2008-07-16 12:31:58 +00:00
|
|
|
nLength = aEndPos.mnPos + 1 - aStartPos.mnPos;
|
|
|
|
}
|
2008-12-15 12:01:46 +00:00
|
|
|
else if( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE )
|
2008-07-16 12:31:58 +00:00
|
|
|
{
|
|
|
|
bCommit = true;
|
|
|
|
nStart = aStartPos.mnPos;
|
|
|
|
sal_Int32 nEnd = aEndPos.mnPos;
|
|
|
|
if( bStartInField && nType != text::TextMarkupType::SENTENCE )
|
|
|
|
{
|
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
SwWrongList* pSubList = pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
|
|
|
{
|
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
|
|
|
}
|
|
|
|
const sal_uInt32 nTmpStart = ModelToViewHelper::ConvertToViewPosition( mpConversionMap, aStartPos.mnPos );
|
|
|
|
const sal_uInt32 nTmpLen = ModelToViewHelper::ConvertToViewPosition( mpConversionMap, aStartPos.mnPos + 1 )
|
|
|
|
- nTmpStart - aStartPos.mnSubPos;
|
|
|
|
if( nTmpLen > 0 )
|
|
|
|
{
|
|
|
|
if( nType == text::TextMarkupType::SENTENCE )
|
|
|
|
{
|
|
|
|
((SwGrammarMarkUp*)pSubList)->setSentence( static_cast< xub_StrLen >(aStartPos.mnSubPos) );
|
|
|
|
bCommit = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pSubList->Insert( rIdentifier, xMarkupInfoContainer,
|
|
|
|
static_cast< xub_StrLen >(aStartPos.mnSubPos), static_cast< xub_StrLen >(nTmpLen) );
|
|
|
|
}
|
|
|
|
++nStart;
|
|
|
|
}
|
|
|
|
if( bEndInField && nType != text::TextMarkupType::SENTENCE )
|
|
|
|
{
|
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aEndPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
SwWrongList* pSubList = pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
|
|
|
{
|
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
|
|
|
}
|
|
|
|
const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1;
|
|
|
|
pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++nEnd;
|
|
|
|
if( nEnd > nStart )
|
|
|
|
nLength = nEnd - nStart;
|
|
|
|
else
|
|
|
|
bCommit = false;
|
2008-02-26 08:48:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCommit )
|
|
|
|
{
|
2008-07-16 12:31:58 +00:00
|
|
|
if( nType == text::TextMarkupType::SENTENCE )
|
|
|
|
((SwGrammarMarkUp*)pWList)->setSentence( static_cast< xub_StrLen >(nStart) );
|
|
|
|
else
|
|
|
|
pWList->Insert( rIdentifier, xMarkupInfoContainer,
|
2008-02-26 08:48:36 +00:00
|
|
|
static_cast< xub_StrLen >(nStart), static_cast< xub_StrLen >(nLength) );
|
2007-06-27 12:22:26 +00:00
|
|
|
}
|
2008-07-16 12:31:58 +00:00
|
|
|
|
|
|
|
if( bRepaint )
|
|
|
|
finishGrammarCheck( *mpTxtNode );
|
2007-06-27 12:22:26 +00:00
|
|
|
}
|
|
|
|
|
2008-12-15 12:01:46 +00:00
|
|
|
|
|
|
|
void lcl_commitGrammarMarkUp(
|
|
|
|
const ModelToViewHelper::ConversionMap* pConversionMap,
|
|
|
|
SwGrammarMarkUp* pWList,
|
|
|
|
::sal_Int32 nType,
|
|
|
|
const ::rtl::OUString & rIdentifier,
|
|
|
|
::sal_Int32 nStart,
|
|
|
|
::sal_Int32 nLength,
|
|
|
|
const uno::Reference< container::XStringKeyMap > & xMarkupInfoContainer)
|
|
|
|
{
|
2008-12-18 14:10:00 +00:00
|
|
|
ASSERT( nType == text::TextMarkupType::PROOFREADING || nType == text::TextMarkupType::SENTENCE, "Wrong mark-up type" )
|
2008-12-15 12:01:46 +00:00
|
|
|
const ModelToViewHelper::ModelPosition aStartPos =
|
|
|
|
ModelToViewHelper::ConvertToModelPosition( pConversionMap, nStart );
|
|
|
|
const ModelToViewHelper::ModelPosition aEndPos =
|
|
|
|
ModelToViewHelper::ConvertToModelPosition( pConversionMap, nStart + nLength - 1);
|
|
|
|
|
|
|
|
const bool bStartInField = aStartPos.mbIsField;
|
|
|
|
const bool bEndInField = aEndPos.mbIsField;
|
|
|
|
bool bCommit = false;
|
|
|
|
|
|
|
|
if ( bStartInField && bEndInField && aStartPos.mnPos == aEndPos.mnPos )
|
|
|
|
{
|
|
|
|
nStart = aStartPos.mnSubPos;
|
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
|
|
|
|
SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
|
|
|
{
|
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
|
|
|
}
|
|
|
|
|
|
|
|
pWList = pSubList;
|
|
|
|
bCommit = true;
|
|
|
|
}
|
|
|
|
else if ( !bStartInField && !bEndInField )
|
|
|
|
{
|
|
|
|
nStart = aStartPos.mnPos;
|
|
|
|
bCommit = true;
|
|
|
|
nLength = aEndPos.mnPos + 1 - aStartPos.mnPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bCommit = true;
|
|
|
|
nStart = aStartPos.mnPos;
|
|
|
|
sal_Int32 nEnd = aEndPos.mnPos;
|
|
|
|
if( bStartInField && nType != text::TextMarkupType::SENTENCE )
|
|
|
|
{
|
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aStartPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
|
|
|
{
|
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
|
|
|
}
|
|
|
|
const sal_uInt32 nTmpStart = ModelToViewHelper::ConvertToViewPosition( pConversionMap, aStartPos.mnPos );
|
|
|
|
const sal_uInt32 nTmpLen = ModelToViewHelper::ConvertToViewPosition( pConversionMap, aStartPos.mnPos + 1 )
|
|
|
|
- nTmpStart - aStartPos.mnSubPos;
|
|
|
|
if( nTmpLen > 0 )
|
|
|
|
pSubList->Insert( rIdentifier, xMarkupInfoContainer,
|
|
|
|
static_cast< xub_StrLen >(aStartPos.mnSubPos), static_cast< xub_StrLen >(nTmpLen) );
|
|
|
|
++nStart;
|
|
|
|
}
|
|
|
|
if( bEndInField && nType != text::TextMarkupType::SENTENCE )
|
|
|
|
{
|
|
|
|
const xub_StrLen nFieldPosModel = static_cast< xub_StrLen >(aEndPos.mnPos);
|
|
|
|
const USHORT nInsertPos = pWList->GetWrongPos( nFieldPosModel );
|
|
|
|
SwGrammarMarkUp* pSubList = (SwGrammarMarkUp*)pWList->SubList( nInsertPos );
|
|
|
|
if ( !pSubList )
|
|
|
|
{
|
|
|
|
pSubList = new SwGrammarMarkUp();
|
|
|
|
pWList->InsertSubList( nFieldPosModel, 1, nInsertPos, pSubList );
|
|
|
|
}
|
|
|
|
const sal_uInt32 nTmpLen = aEndPos.mnSubPos + 1;
|
|
|
|
pSubList->Insert( rIdentifier, xMarkupInfoContainer, 0, static_cast< xub_StrLen >(nTmpLen) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++nEnd;
|
|
|
|
if( nEnd > nStart )
|
|
|
|
nLength = nEnd - nStart;
|
|
|
|
else
|
|
|
|
bCommit = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bCommit )
|
|
|
|
{
|
|
|
|
if( nType == text::TextMarkupType::SENTENCE )
|
|
|
|
((SwGrammarMarkUp*)pWList)->setSentence( static_cast< xub_StrLen >(nStart+nLength) );
|
|
|
|
else
|
|
|
|
pWList->Insert( rIdentifier, xMarkupInfoContainer,
|
|
|
|
static_cast< xub_StrLen >(nStart), static_cast< xub_StrLen >(nLength) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
|
|
|
|
const uno::Sequence< text::TextMarkupDescriptor > &rMarkups )
|
|
|
|
throw (lang::IllegalArgumentException, uno::RuntimeException)
|
|
|
|
{
|
2010-10-13 01:44:10 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2008-12-15 12:01:46 +00:00
|
|
|
|
|
|
|
// paragraph already dead or modified?
|
|
|
|
if ( !mpTxtNode )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// check for equal length of all sequnces
|
|
|
|
sal_Int32 nLen = rMarkups.getLength();
|
|
|
|
|
|
|
|
// for grammar checking there should be exactly one sentence markup
|
|
|
|
// and 0..n grammar markups.
|
|
|
|
// Different markups are not expected but may be applied anyway since
|
|
|
|
// that should be no problem...
|
|
|
|
// but it has to be implemented, at the moment only this function is for
|
|
|
|
// grammar markups and sentence markup only!
|
|
|
|
sal_Int32 nSentenceMarkUpIndex = -1;
|
|
|
|
const text::TextMarkupDescriptor *pMarkups = rMarkups.getConstArray();
|
|
|
|
sal_Int32 i;
|
|
|
|
for( i = 0; i < nLen; ++i )
|
|
|
|
{
|
|
|
|
if (pMarkups[i].nType == text::TextMarkupType::SENTENCE)
|
|
|
|
{
|
|
|
|
if (nSentenceMarkUpIndex == -1)
|
|
|
|
nSentenceMarkUpIndex = i;
|
|
|
|
else // there is already one sentence markup
|
|
|
|
throw lang::IllegalArgumentException();
|
|
|
|
}
|
|
|
|
else if( pMarkups[i].nType != text::TextMarkupType::PROOFREADING )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( nSentenceMarkUpIndex == -1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// get appropriate list to use...
|
|
|
|
SwGrammarMarkUp* pWList = 0;
|
|
|
|
bool bRepaint = false;
|
|
|
|
IGrammarContact *pGrammarContact = getGrammarContact( *mpTxtNode );
|
|
|
|
if( pGrammarContact )
|
|
|
|
{
|
|
|
|
pWList = pGrammarContact->getGrammarCheck( *mpTxtNode, true );
|
|
|
|
ASSERT( pWList, "GrammarContact _has_ to deliver a wrong list" )
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pWList = mpTxtNode->GetGrammarCheck();
|
|
|
|
if ( !pWList )
|
|
|
|
{
|
|
|
|
mpTxtNode->SetGrammarCheck( new SwGrammarMarkUp() );
|
|
|
|
pWList = mpTxtNode->GetGrammarCheck();
|
|
|
|
pWList->SetInvalid( 0, STRING_LEN );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bRepaint = pWList == mpTxtNode->GetGrammarCheck();
|
|
|
|
|
|
|
|
bool bAcceptGrammarError = false;
|
|
|
|
if( pWList->GetBeginInv() < STRING_LEN )
|
|
|
|
{
|
|
|
|
const ModelToViewHelper::ModelPosition aSentenceEnd =
|
|
|
|
ModelToViewHelper::ConvertToModelPosition( mpConversionMap,
|
|
|
|
pMarkups[nSentenceMarkUpIndex].nOffset + pMarkups[nSentenceMarkUpIndex].nLength );
|
|
|
|
bAcceptGrammarError = (xub_StrLen)aSentenceEnd.mnPos > pWList->GetBeginInv();
|
|
|
|
pWList->ClearGrammarList( (xub_StrLen)aSentenceEnd.mnPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bAcceptGrammarError )
|
|
|
|
{
|
|
|
|
for( i = 0; i < nLen; ++i )
|
|
|
|
{
|
|
|
|
const text::TextMarkupDescriptor &rDesc = pMarkups[i];
|
|
|
|
lcl_commitGrammarMarkUp( mpConversionMap, pWList, rDesc.nType,
|
|
|
|
rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bRepaint = false;
|
|
|
|
i = nSentenceMarkUpIndex;
|
|
|
|
const text::TextMarkupDescriptor &rDesc = pMarkups[i];
|
|
|
|
lcl_commitGrammarMarkUp( mpConversionMap, pWList, rDesc.nType,
|
|
|
|
rDesc.aIdentifier, rDesc.nOffset, rDesc.nLength, rDesc.xMarkupInfoContainer );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bRepaint )
|
|
|
|
finishGrammarCheck( *mpTxtNode );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-27 12:22:26 +00:00
|
|
|
void SwXTextMarkup::Modify( SfxPoolItem* /*pOld*/, SfxPoolItem* /*pNew*/ )
|
|
|
|
{
|
2007-07-26 07:21:34 +00:00
|
|
|
// FME 2007-07-16 #i79641# In my opinion this is perfectly legal,
|
|
|
|
// therefore I remove the assertion in SwModify::_Remove()
|
|
|
|
if ( pRegisteredIn )
|
|
|
|
pRegisteredIn->Remove( this );
|
|
|
|
// <--
|
|
|
|
|
2010-10-13 01:44:10 -05:00
|
|
|
SolarMutexGuard aGuard;
|
2007-06-27 12:22:26 +00:00
|
|
|
mpTxtNode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SwXStringKeyMap
|
|
|
|
*/
|
|
|
|
SwXStringKeyMap::SwXStringKeyMap()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL SwXStringKeyMap::getValue(const ::rtl::OUString & aKey) throw (uno::RuntimeException, container::NoSuchElementException)
|
|
|
|
{
|
|
|
|
std::map< rtl::OUString, uno::Any >::const_iterator aIter = maMap.find( aKey );
|
|
|
|
if ( aIter == maMap.end() )
|
|
|
|
throw container::NoSuchElementException();
|
|
|
|
|
|
|
|
return (*aIter).second;
|
|
|
|
}
|
|
|
|
|
|
|
|
::sal_Bool SAL_CALL SwXStringKeyMap::hasValue(const ::rtl::OUString & aKey) throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return maMap.find( aKey ) != maMap.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL SwXStringKeyMap::insertValue(const ::rtl::OUString & aKey, const uno::Any & aValue) throw (uno::RuntimeException, lang::IllegalArgumentException, container::ElementExistException)
|
|
|
|
{
|
|
|
|
std::map< rtl::OUString, uno::Any >::const_iterator aIter = maMap.find( aKey );
|
|
|
|
if ( aIter != maMap.end() )
|
|
|
|
throw container::ElementExistException();
|
|
|
|
|
|
|
|
maMap[ aKey ] = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
::sal_Int32 SAL_CALL SwXStringKeyMap::getCount() throw (uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return maMap.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
::rtl::OUString SAL_CALL SwXStringKeyMap::getKeyByIndex(::sal_Int32 nIndex) throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
|
|
|
|
{
|
|
|
|
if ( (sal_uInt32)nIndex >= maMap.size() )
|
|
|
|
throw lang::IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Any SAL_CALL SwXStringKeyMap::getValueByIndex(::sal_Int32 nIndex) throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
|
|
|
|
{
|
|
|
|
if ( (sal_uInt32)nIndex >= maMap.size() )
|
|
|
|
throw lang::IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
return uno::Any();
|
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|