forked from amazingfate/loongoffice
Into the new class DocumentContentOperationsManager. Made SwNodes in sw/inc/ndarr.hxx friend class to DocumentContentOperationsManager so it can call DelNodes at end of DocumentContentOperationsManager::DeleteSection . Added DeleteAutoCorrExceptWord to SwDoc, its needed in the Manager. Added a non const version of SwDoc::GetDfltGrfFmtColl() to SwDoc because its needed in the Manager. Made SwDoc a friend class to DocumentContentOperationsManager so it can call SwDoc::checkRedlining and SwDocL::_MakeFlySection. Moved SwDoc::CopyImpl_ , SwDoc::CopyWithFlyInFly and SwDoc::CopyFlyInFlyImpl into the Manager. Moved "struct ParaRstFmt" and "lcl_RstTxtAttr" from docfmt.cxx in DocumentContentOperationsManager.hxx . Change-Id: Icaab57f4a8c158a85e549ecb4aacc752bc95bbc9
161 lines
4.8 KiB
C++
161 lines
4.8 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* 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 .
|
|
*/
|
|
|
|
#include <editsh.hxx>
|
|
#include <doc.hxx>
|
|
#include <IDocumentUndoRedo.hxx>
|
|
#include <pam.hxx>
|
|
#include <edimp.hxx>
|
|
#include <swundo.hxx>
|
|
#include <ndtxt.hxx>
|
|
|
|
/*
|
|
* hard formatting (Attribute)
|
|
*/
|
|
|
|
void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs, SwPaM* pPaM )
|
|
{
|
|
SET_CURR_SHELL( this );
|
|
SwPaM* pCrsr = pPaM ? pPaM : GetCrsr( );
|
|
|
|
StartAllAction();
|
|
bool bUndoGroup = pCrsr->GetNext() != pCrsr;
|
|
if( bUndoGroup )
|
|
{
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL);
|
|
}
|
|
|
|
SwPaM* pStartCrsr = pCrsr;
|
|
do {
|
|
GetDoc()->ResetAttrs(*pCrsr, true, attrs);
|
|
} while ( ( pCrsr = ( SwPaM* ) pCrsr->GetNext() ) != pStartCrsr );
|
|
|
|
if( bUndoGroup )
|
|
{
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL);
|
|
}
|
|
CallChgLnk();
|
|
EndAllAction();
|
|
}
|
|
|
|
void SwEditShell::GCAttr()
|
|
{
|
|
FOREACHPAM_START(GetCrsr())
|
|
if ( !PCURCRSR->HasMark() )
|
|
{
|
|
SwTxtNode *const pTxtNode =
|
|
PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode();
|
|
if (pTxtNode)
|
|
{
|
|
pTxtNode->GCAttr();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const SwNodeIndex& rEnd = PCURCRSR->End()->nNode;
|
|
SwNodeIndex aIdx( PCURCRSR->Start()->nNode );
|
|
SwNode* pNd = &aIdx.GetNode();
|
|
do {
|
|
if( pNd->IsTxtNode() )
|
|
((SwTxtNode*)pNd)->GCAttr();
|
|
}
|
|
while( 0 != ( pNd = GetDoc()->GetNodes().GoNext( &aIdx )) &&
|
|
aIdx <= rEnd );
|
|
}
|
|
FOREACHPAM_END()
|
|
}
|
|
|
|
/// Set the attribute as new default attribute in the document.
|
|
void SwEditShell::SetDefault( const SfxPoolItem& rFmtHint )
|
|
{
|
|
// 7502: Action-Parenthesis
|
|
StartAllAction();
|
|
GetDoc()->SetDefault( rFmtHint );
|
|
EndAllAction();
|
|
}
|
|
|
|
/// request the default attribute in this document.
|
|
const SfxPoolItem& SwEditShell::GetDefault( sal_uInt16 nFmtHint ) const
|
|
{
|
|
return GetDoc()->GetDefault( nFmtHint );
|
|
}
|
|
|
|
void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, sal_uInt16 nFlags )
|
|
{
|
|
SET_CURR_SHELL( this );
|
|
StartAllAction();
|
|
SwPaM* pCrsr = GetCrsr();
|
|
if( pCrsr->GetNext() != pCrsr ) // Ring of Cursors
|
|
{
|
|
bool bIsTblMode = IsTableMode();
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
|
|
|
|
FOREACHPAM_START(GetCrsr())
|
|
if( PCURCRSR->HasMark() && ( bIsTblMode ||
|
|
*PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
|
|
{
|
|
GetDoc()->getIDocumentContentOperations().InsertPoolItem(*PCURCRSR, rHint, nFlags );
|
|
}
|
|
FOREACHPAM_END()
|
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
|
|
}
|
|
else
|
|
{
|
|
if( !HasSelection() )
|
|
UpdateAttr();
|
|
GetDoc()->getIDocumentContentOperations().InsertPoolItem( *pCrsr, rHint, nFlags );
|
|
}
|
|
EndAllAction();
|
|
}
|
|
|
|
void SwEditShell::SetAttrSet( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM* pPaM )
|
|
{
|
|
SET_CURR_SHELL( this );
|
|
|
|
SwPaM* pCrsr = pPaM ? pPaM : GetCrsr();
|
|
StartAllAction();
|
|
if( pCrsr->GetNext() != pCrsr ) // Ring of Cursors
|
|
{
|
|
bool bIsTblMode = IsTableMode();
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL);
|
|
|
|
SwPaM* pTmpCrsr = pCrsr;
|
|
SwPaM* pStartPaM = pCrsr;
|
|
do {
|
|
if( pTmpCrsr->HasMark() && ( bIsTblMode ||
|
|
*pTmpCrsr->GetPoint() != *pTmpCrsr->GetMark() ))
|
|
{
|
|
GetDoc()->getIDocumentContentOperations().InsertItemSet(*pTmpCrsr, rSet, nFlags );
|
|
}
|
|
} while ( ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ) != pStartPaM );
|
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL);
|
|
}
|
|
else
|
|
{
|
|
if( !HasSelection() )
|
|
UpdateAttr();
|
|
GetDoc()->getIDocumentContentOperations().InsertItemSet( *pCrsr, rSet, nFlags );
|
|
}
|
|
EndAllAction();
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|