2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 20:25:33 +01: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
|
|
|
|
2014-04-15 13:55:56 +02:00
|
|
|
#include <fesh.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <hintids.hxx>
|
2008-03-05 16:01:01 +00:00
|
|
|
#include <hints.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/boxitem.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <swwait.hxx>
|
|
|
|
#include <fmtfsize.hxx>
|
|
|
|
#include <frmatr.hxx>
|
|
|
|
#include <editsh.hxx>
|
|
|
|
#include <doc.hxx>
|
2010-11-25 14:31:08 +01:00
|
|
|
#include <IDocumentUndoRedo.hxx>
|
2014-06-09 18:27:24 +02:00
|
|
|
#include <IDocumentChartDataProviderAccess.hxx>
|
2014-07-24 16:46:12 +02:00
|
|
|
#include <IDocumentFieldsAccess.hxx>
|
2014-08-01 17:09:54 +02:00
|
|
|
#include <IDocumentState.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#include <pam.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <swundo.hxx>
|
|
|
|
#include <tblsel.hxx>
|
|
|
|
#include <edimp.hxx>
|
|
|
|
#include <tabfrm.hxx>
|
|
|
|
#include <cellfrm.hxx>
|
|
|
|
#include <cellatr.hxx>
|
|
|
|
#include <swtblfmt.hxx>
|
|
|
|
#include <swddetbl.hxx>
|
|
|
|
#include <mdiexp.hxx>
|
2007-05-22 15:27:06 +00:00
|
|
|
#include <unochart.hxx>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-06-22 09:01:55 +00:00
|
|
|
//Added for bug #i119954# Application crashed if undo/redo covert nest table to text
|
2014-04-25 14:00:35 +02:00
|
|
|
bool ConvertTableToText( const SwTableNode *pTableNode, sal_Unicode cCh );
|
2012-06-22 09:01:55 +00:00
|
|
|
|
|
|
|
void ConvertNestedTablesToText( const SwTableLines &rTableLines, sal_Unicode cCh )
|
|
|
|
{
|
|
|
|
for (size_t n = 0; n < rTableLines.size(); ++n)
|
|
|
|
{
|
|
|
|
SwTableLine* pTableLine = rTableLines[ n ];
|
|
|
|
for (size_t i = 0; i < pTableLine->GetTabBoxes().size(); ++i)
|
|
|
|
{
|
|
|
|
SwTableBox* pTableBox = pTableLine->GetTabBoxes()[ i ];
|
|
|
|
if (pTableBox->GetTabLines().empty())
|
|
|
|
{
|
|
|
|
SwNodeIndex nodeIndex( *pTableBox->GetSttNd(), 1 );
|
|
|
|
SwNodeIndex endNodeIndex( *pTableBox->GetSttNd()->EndOfSectionNode() );
|
2015-03-19 13:13:02 +02:00
|
|
|
for( ; nodeIndex < endNodeIndex ; ++nodeIndex )
|
2012-06-22 09:01:55 +00:00
|
|
|
{
|
|
|
|
if ( SwTableNode* pTableNode = nodeIndex.GetNode().GetTableNode() )
|
|
|
|
ConvertTableToText( pTableNode, cCh );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ConvertNestedTablesToText( pTableBox->GetTabLines(), cCh );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool ConvertTableToText( const SwTableNode *pConstTableNode, sal_Unicode cCh )
|
2012-06-22 09:01:55 +00:00
|
|
|
{
|
|
|
|
SwTableNode *pTableNode = const_cast< SwTableNode* >( pConstTableNode );
|
|
|
|
ConvertNestedTablesToText( pTableNode->GetTable().GetTabLines(), cCh );
|
|
|
|
return pTableNode->GetDoc()->TableToText( pTableNode, cCh );
|
|
|
|
}
|
|
|
|
//End for bug #i119954#
|
2013-06-09 00:44:03 +02:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTable& SwEditShell::InsertTable( const SwInsertTableOptions& rInsTableOpts,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRows, sal_uInt16 nCols,
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTableAutoFormat* pTAFormat )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
2015-11-25 06:03:10 -05:00
|
|
|
SwPosition* pPos = GetCursor()->GetPoint();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-11-23 11:06:51 +09:00
|
|
|
bool bEndUndo = 0 != pPos->nContent.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bEndUndo )
|
|
|
|
{
|
2017-03-16 09:11:42 +02:00
|
|
|
StartUndo( SwUndoId::START );
|
2014-07-07 14:32:02 +02:00
|
|
|
GetDoc()->getIDocumentContentOperations().SplitNode( *pPos, false );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2003-05-28 11:51:31 +00:00
|
|
|
|
2013-06-09 00:31:37 +02:00
|
|
|
// If called from a shell the adjust item is propagated
|
|
|
|
// from pPos to the new content nodes in the table.
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTable *pTable = GetDoc()->InsertTable( rInsTableOpts, *pPos,
|
2004-05-03 12:45:06 +00:00
|
|
|
nRows, nCols,
|
2016-09-08 10:21:09 +02:00
|
|
|
css::text::HoriOrientation::FULL, pTAFormat,
|
2015-11-10 10:25:48 +01:00
|
|
|
nullptr, true );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bEndUndo )
|
2017-03-16 09:11:42 +02:00
|
|
|
EndUndo( SwUndoId::END );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
EndAllAction();
|
|
|
|
return *pTable;
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
bool SwEditShell::TextToTable( const SwInsertTableOptions& rInsTableOpts,
|
2004-05-03 12:45:06 +00:00
|
|
|
sal_Unicode cCh,
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTableAutoFormat* pTAFormat )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-01-16 07:33:02 +09:00
|
|
|
SwWait aWait( *GetDoc()->GetDocShell(), true );
|
2014-01-22 14:58:57 +01:00
|
|
|
bool bRet = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
StartAllAction();
|
2015-11-25 06:03:10 -05:00
|
|
|
for(SwPaM& rPaM : GetCursor()->GetRingContainer())
|
2014-12-13 19:30:48 +01:00
|
|
|
{
|
|
|
|
if( rPaM.HasMark() )
|
2015-11-10 10:25:48 +01:00
|
|
|
bRet |= nullptr != GetDoc()->TextToTable( rInsTableOpts, rPaM, cCh,
|
2016-09-08 10:21:09 +02:00
|
|
|
css::text::HoriOrientation::FULL, pTAFormat );
|
2014-12-13 19:30:48 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
EndAllAction();
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwEditShell::TableToText( sal_Unicode cCh )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-01-16 07:33:02 +09:00
|
|
|
SwWait aWait( *GetDoc()->GetDocShell(), true );
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = false;
|
2015-11-25 06:03:10 -05:00
|
|
|
SwPaM* pCursor = GetCursor();
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTableNode* pTableNd =
|
2015-11-25 06:03:10 -05:00
|
|
|
GetDoc()->IsIdxInTable( pCursor->GetPoint()->nNode );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( IsTableMode() )
|
|
|
|
{
|
|
|
|
ClearMark();
|
2015-11-25 06:03:10 -05:00
|
|
|
pCursor = GetCursor();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2015-11-25 06:03:10 -05:00
|
|
|
else if( !pTableNd || pCursor->GetNext() != pCursor )
|
2000-09-18 23:08:29 +00:00
|
|
|
return bRet;
|
|
|
|
|
2007-05-22 15:27:06 +00:00
|
|
|
// TL_CHART2:
|
|
|
|
// tell the charts about the table to be deleted and have them use their own data
|
2015-05-20 13:05:49 +02:00
|
|
|
GetDoc()->getIDocumentChartDataProviderAccess().CreateChartInternalDataProviders( &pTableNd->GetTable() );
|
2007-05-22 15:27:06 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
StartAllAction();
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// move current Cursor out of the listing area
|
2015-05-20 13:05:49 +02:00
|
|
|
SwNodeIndex aTabIdx( *pTableNd );
|
2015-11-25 06:03:10 -05:00
|
|
|
pCursor->DeleteMark();
|
|
|
|
pCursor->GetPoint()->nNode = *pTableNd->EndOfSectionNode();
|
|
|
|
pCursor->GetPoint()->nContent.Assign( nullptr, 0 );
|
2013-06-09 00:07:31 +02:00
|
|
|
// move sPoint and Mark out of the area!
|
2015-11-25 06:03:10 -05:00
|
|
|
pCursor->SetMark();
|
|
|
|
pCursor->DeleteMark();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-06-22 09:01:55 +00:00
|
|
|
//Modified for bug #i119954# Application crashed if undo/redo covert nest table to text
|
|
|
|
StartUndo();
|
2015-05-20 13:05:49 +02:00
|
|
|
bRet = ConvertTableToText( pTableNd, cCh );
|
2012-06-22 09:01:55 +00:00
|
|
|
EndUndo();
|
|
|
|
//End for bug #i119954#
|
2015-11-25 06:03:10 -05:00
|
|
|
pCursor->GetPoint()->nNode = aTabIdx;
|
2004-08-12 11:24:05 +00:00
|
|
|
|
2015-11-25 06:03:10 -05:00
|
|
|
SwContentNode* pCNd = pCursor->GetContentNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !pCNd )
|
2016-08-29 12:52:04 +03:00
|
|
|
pCursor->Move( fnMoveForward, GoInContent );
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2015-11-25 06:03:10 -05:00
|
|
|
pCursor->GetPoint()->nContent.Assign( pCNd, 0 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
EndAllAction();
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwEditShell::IsTextToTableAvailable() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bOnlyText = false;
|
2015-11-25 06:03:10 -05:00
|
|
|
for(SwPaM& rPaM : GetCursor()->GetRingContainer())
|
2014-12-13 19:30:48 +01:00
|
|
|
{
|
|
|
|
if( rPaM.HasMark() && *rPaM.GetPoint() != *rPaM.GetMark() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bOnlyText = true;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// check if selection is in listing
|
2014-12-13 19:30:48 +01:00
|
|
|
sal_uLong nStt = rPaM.GetMark()->nNode.GetIndex(),
|
|
|
|
nEnd = rPaM.GetPoint()->nNode.GetIndex();
|
2011-01-17 15:06:54 +01:00
|
|
|
if( nStt > nEnd ) { sal_uLong n = nStt; nStt = nEnd; nEnd = n; }
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
for( ; nStt <= nEnd; ++nStt )
|
2015-05-20 13:05:49 +02:00
|
|
|
if( !GetDoc()->GetNodes()[ nStt ]->IsTextNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bOnlyText = false;
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bOnlyText )
|
|
|
|
break;
|
|
|
|
}
|
2014-12-13 19:30:48 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return bOnlyText;
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
void SwEditShell::InsertDDETable( const SwInsertTableOptions& rInsTableOpts,
|
2004-05-03 12:45:06 +00:00
|
|
|
SwDDEFieldType* pDDEType,
|
2016-02-29 10:59:14 +02:00
|
|
|
sal_uInt16 nRows, sal_uInt16 nCols )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
SwPosition* pPos = GetCursor()->GetPoint();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
StartAllAction();
|
|
|
|
|
2012-11-23 11:06:51 +09:00
|
|
|
bool bEndUndo = 0 != pPos->nContent.GetIndex();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bEndUndo )
|
|
|
|
{
|
2017-03-16 09:11:42 +02:00
|
|
|
StartUndo( SwUndoId::START );
|
2014-07-07 14:32:02 +02:00
|
|
|
GetDoc()->getIDocumentContentOperations().SplitNode( *pPos, false );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwInsertTableOptions aInsTableOpts( rInsTableOpts.mnInsMode | tabopts::DEFAULT_BORDER,
|
|
|
|
rInsTableOpts.mnRowsToRepeat );
|
|
|
|
SwTable* pTable = const_cast<SwTable*>(GetDoc()->InsertTable( aInsTableOpts, *pPos,
|
2016-02-29 10:59:14 +02:00
|
|
|
nRows, nCols, css::text::HoriOrientation::FULL ));
|
2004-05-03 12:45:06 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
SwTableNode* pTableNode = const_cast<SwTableNode*>(pTable->GetTabSortBoxes()[ 0 ]->
|
2015-03-26 15:31:55 +01:00
|
|
|
GetSttNd()->FindTableNode());
|
2015-05-20 13:05:49 +02:00
|
|
|
SwDDETable* pDDETable = new SwDDETable( *pTable, pDDEType );
|
2017-04-08 05:34:28 +00:00
|
|
|
pTableNode->SetNewTable( pDDETable ); // set the DDE table
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( bEndUndo )
|
2017-03-16 09:11:42 +02:00
|
|
|
EndUndo( SwUndoId::END );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** update fields of a listing */
|
2000-09-18 23:08:29 +00:00
|
|
|
void SwEditShell::UpdateTable()
|
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
const SwTableNode* pTableNd = IsCursorInTable();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
if( pTableNd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
2007-05-22 15:27:06 +00:00
|
|
|
if( DoesUndo() )
|
|
|
|
StartUndo();
|
2015-05-20 13:05:49 +02:00
|
|
|
EndAllTableBoxEdit();
|
|
|
|
SwTableFormulaUpdate aTableUpdate( &pTableNd->GetTable() );
|
|
|
|
GetDoc()->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
|
2007-05-22 15:27:06 +00:00
|
|
|
if( DoesUndo() )
|
|
|
|
EndUndo();
|
2000-09-18 23:08:29 +00:00
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// get/set Change Mode
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
TableChgMode SwEditShell::GetTableChgMode() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
TableChgMode eMode;
|
2015-11-25 06:03:10 -05:00
|
|
|
const SwTableNode* pTableNd = IsCursorInTable();
|
2015-05-20 13:05:49 +02:00
|
|
|
if( pTableNd )
|
|
|
|
eMode = pTableNd->GetTable().GetTableChgMode();
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2015-05-20 13:05:49 +02:00
|
|
|
eMode = GetTableChgDefaultMode();
|
2007-09-27 07:46:42 +00:00
|
|
|
return eMode;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
void SwEditShell::SetTableChgMode( TableChgMode eMode )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
const SwTableNode* pTableNd = IsCursorInTable();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
if( pTableNd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
const_cast<SwTable&>(pTableNd->GetTable()).SetTableChgMode( eMode );
|
2014-08-01 17:09:54 +02:00
|
|
|
if( !GetDoc()->getIDocumentState().IsModified() ) // Bug 57028
|
2010-11-25 14:31:08 +01:00
|
|
|
{
|
|
|
|
GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified();
|
|
|
|
}
|
2014-08-01 17:09:54 +02:00
|
|
|
GetDoc()->getIDocumentState().SetModified();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
bool SwEditShell::GetTableBoxFormulaAttrs( SfxItemSet& rSet ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwSelBoxes aBoxes;
|
|
|
|
if( IsTableMode() )
|
2015-05-20 13:05:49 +02:00
|
|
|
::GetTableSelCrs( *this, aBoxes );
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
SwFrame *pFrame = GetCurrFrame();
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
pFrame = pFrame->GetUpper();
|
|
|
|
} while ( pFrame && !pFrame->IsCellFrame() );
|
|
|
|
if ( pFrame )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2016-07-08 16:40:53 +02:00
|
|
|
SwTableBox *pBox = const_cast<SwTableBox*>(static_cast<SwCellFrame*>(pFrame)->GetTabBox());
|
2012-07-19 14:03:42 +02:00
|
|
|
aBoxes.insert( pBox );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-11-23 11:06:51 +09:00
|
|
|
} while( false );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-09-21 15:18:23 +02:00
|
|
|
for (size_t n = 0; n < aBoxes.size(); ++n)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-05-05 10:25:52 +01:00
|
|
|
const SwTableBox* pSelBox = aBoxes[ n ];
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTableBoxFormat* pTableFormat = static_cast<SwTableBoxFormat*>(pSelBox->GetFrameFormat());
|
2012-05-05 10:25:52 +01:00
|
|
|
if( !n )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2013-06-09 00:07:31 +02:00
|
|
|
// Convert formulae into external presentation
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTable& rTable = pSelBox->GetSttNd()->FindTableNode()->GetTable();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
SwTableFormulaUpdate aTableUpdate( &rTable );
|
2015-10-27 08:42:35 +01:00
|
|
|
aTableUpdate.m_eFlags = TBL_BOXNAME;
|
2016-07-08 16:40:53 +02:00
|
|
|
GetDoc()->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
rSet.Put( pTableFormat->GetAttrSet() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2015-05-20 13:05:49 +02:00
|
|
|
rSet.MergeValues( pTableFormat->GetAttrSet() );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return 0 != rSet.Count();
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
void SwEditShell::SetTableBoxFormulaAttrs( const SfxItemSet& rSet )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SET_CURR_SHELL( this );
|
|
|
|
SwSelBoxes aBoxes;
|
|
|
|
if( IsTableMode() )
|
2015-05-20 13:05:49 +02:00
|
|
|
::GetTableSelCrs( *this, aBoxes );
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
SwFrame *pFrame = GetCurrFrame();
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
pFrame = pFrame->GetUpper();
|
|
|
|
} while ( pFrame && !pFrame->IsCellFrame() );
|
|
|
|
if ( pFrame )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2016-07-08 16:40:53 +02:00
|
|
|
SwTableBox *pBox = const_cast<SwTableBox*>(static_cast<SwCellFrame*>(pFrame)->GetTabBox());
|
2012-07-19 14:03:42 +02:00
|
|
|
aBoxes.insert( pBox );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2012-11-23 11:06:51 +09:00
|
|
|
} while( false );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
// When setting a formula, do not check further!
|
2014-09-10 17:53:41 +02:00
|
|
|
if( SfxItemState::SET == rSet.GetItemState( RES_BOXATR_FORMULA ))
|
2015-05-20 13:05:49 +02:00
|
|
|
ClearTableBoxContent();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
StartAllAction();
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
|
2012-09-21 15:18:23 +02:00
|
|
|
for (size_t n = 0; n < aBoxes.size(); ++n)
|
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
GetDoc()->SetTableBoxFormulaAttrs( *aBoxes[ n ], rSet );
|
2012-09-21 15:18:23 +02:00
|
|
|
}
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
|
2000-09-18 23:08:29 +00:00
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwEditShell::IsTableBoxTextFormat() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( IsTableMode() )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-11-10 10:25:48 +01:00
|
|
|
const SwTableBox *pBox = nullptr;
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
SwFrame *pFrame = GetCurrFrame();
|
2000-09-18 23:08:29 +00:00
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
pFrame = pFrame->GetUpper();
|
|
|
|
} while ( pFrame && !pFrame->IsCellFrame() );
|
|
|
|
if ( pFrame )
|
2016-07-08 16:40:53 +02:00
|
|
|
pBox = static_cast<SwCellFrame*>(pFrame)->GetTabBox();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !pBox )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
sal_uInt32 nFormat = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
const SfxPoolItem* pItem;
|
2015-05-20 13:05:49 +02:00
|
|
|
if( SfxItemState::SET == pBox->GetFrameFormat()->GetAttrSet().GetItemState(
|
2014-02-19 21:49:02 +01:00
|
|
|
RES_BOXATR_FORMAT, true, &pItem ))
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
nFormat = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
|
|
|
|
return GetDoc()->GetNumberFormatter()->IsTextFormat( nFormat ) ||
|
|
|
|
static_cast<sal_uInt32>(css::util::NumberFormat::TEXT) == nFormat;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
sal_uLong nNd = pBox->IsValidNumTextNd();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( ULONG_MAX == nNd )
|
2014-04-25 14:00:35 +02:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-05-20 13:05:49 +02:00
|
|
|
const OUString& rText = GetDoc()->GetNodes()[ nNd ]->GetTextNode()->GetText();
|
|
|
|
if( rText.isEmpty() )
|
2014-04-25 14:00:35 +02:00
|
|
|
return false;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
double fVal;
|
2017-01-11 14:33:39 +03:00
|
|
|
return !GetDoc()->IsNumberFormat( rText, nFormat, fVal );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2013-10-10 17:32:45 +02:00
|
|
|
OUString SwEditShell::GetTableBoxText() const
|
2001-03-12 17:48:10 +00:00
|
|
|
{
|
2013-10-10 17:32:45 +02:00
|
|
|
OUString sRet;
|
2001-03-12 17:48:10 +00:00
|
|
|
if( !IsTableMode() )
|
|
|
|
{
|
2015-11-10 10:25:48 +01:00
|
|
|
const SwTableBox *pBox = nullptr;
|
2001-03-12 17:48:10 +00:00
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
SwFrame *pFrame = GetCurrFrame();
|
2001-03-12 17:48:10 +00:00
|
|
|
do {
|
2015-11-25 06:03:10 -05:00
|
|
|
pFrame = pFrame->GetUpper();
|
|
|
|
} while ( pFrame && !pFrame->IsCellFrame() );
|
|
|
|
if ( pFrame )
|
2016-07-08 16:40:53 +02:00
|
|
|
pBox = static_cast<SwCellFrame*>(pFrame)->GetTabBox();
|
2001-03-12 17:48:10 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNd;
|
2015-05-20 13:05:49 +02:00
|
|
|
if( pBox && ULONG_MAX != ( nNd = pBox->IsValidNumTextNd() ) )
|
|
|
|
sRet = GetDoc()->GetNodes()[ nNd ]->GetTextNode()->GetText();
|
2001-03-12 17:48:10 +00:00
|
|
|
}
|
|
|
|
return sRet;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2017-02-10 12:06:06 +02:00
|
|
|
bool SwEditShell::SplitTable( SplitTable_HeadlineOption eMode )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = false;
|
2015-11-25 06:03:10 -05:00
|
|
|
SwPaM *pCursor = GetCursor();
|
|
|
|
if( pCursor->GetNode().FindTableNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-11-25 06:03:10 -05:00
|
|
|
bRet = GetDoc()->SplitTable( *pCursor->GetPoint(), eMode, true );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
|
2000-09-18 23:08:29 +00:00
|
|
|
ClearFEShellTabCols();
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2016-03-22 10:58:54 +02:00
|
|
|
bool SwEditShell::MergeTable( bool bWithPrev )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = false;
|
2015-11-25 06:03:10 -05:00
|
|
|
SwPaM *pCursor = GetCursor();
|
|
|
|
if( pCursor->GetNode().FindTableNode() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
StartAllAction();
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::EMPTY, nullptr);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2016-03-22 10:58:54 +02:00
|
|
|
bRet = GetDoc()->MergeTable( *pCursor->GetPoint(), bWithPrev );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2017-03-16 09:11:42 +02:00
|
|
|
GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::EMPTY, nullptr);
|
2000-09-18 23:08:29 +00:00
|
|
|
ClearFEShellTabCols();
|
|
|
|
EndAllAction();
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2014-04-25 14:00:35 +02:00
|
|
|
bool SwEditShell::CanMergeTable( bool bWithPrev, bool* pChkNxtPrv ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2014-04-25 14:00:35 +02:00
|
|
|
bool bRet = false;
|
2015-11-25 06:03:10 -05:00
|
|
|
const SwPaM *pCursor = GetCursor();
|
|
|
|
const SwTableNode* pTableNd = pCursor->GetNode().FindTableNode();
|
2015-09-30 16:10:07 +02:00
|
|
|
if( pTableNd && dynamic_cast< const SwDDETable* >(&pTableNd->GetTable()) == nullptr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
bool bNew = pTableNd->GetTable().IsNewModel();
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwNodes& rNds = GetDoc()->GetNodes();
|
|
|
|
if( pChkNxtPrv )
|
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
const SwTableNode* pChkNd = rNds[ pTableNd->GetIndex() - 1 ]->FindTableNode();
|
2015-09-30 16:10:07 +02:00
|
|
|
if( pChkNd && dynamic_cast< const SwDDETable* >(&pChkNd->GetTable()) == nullptr &&
|
2007-11-01 12:44:39 +00:00
|
|
|
bNew == pChkNd->GetTable().IsNewModel() &&
|
2011-02-08 08:51:51 +01:00
|
|
|
// Consider table in table case
|
2015-05-20 13:05:49 +02:00
|
|
|
pChkNd->EndOfSectionIndex() == pTableNd->GetIndex() - 1 )
|
2016-02-22 16:04:08 +02:00
|
|
|
{
|
|
|
|
*pChkNxtPrv = true;
|
|
|
|
bRet = true; // using Prev is possible
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
pChkNd = rNds[ pTableNd->EndOfSectionIndex() + 1 ]->GetTableNode();
|
2015-09-30 16:10:07 +02:00
|
|
|
if( pChkNd && dynamic_cast< const SwDDETable* >(&pChkNd->GetTable()) == nullptr &&
|
2007-11-01 12:44:39 +00:00
|
|
|
bNew == pChkNd->GetTable().IsNewModel() )
|
2016-02-22 16:04:08 +02:00
|
|
|
{
|
|
|
|
*pChkNxtPrv = false;
|
|
|
|
bRet = true; // using Next is possible
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-10 10:25:48 +01:00
|
|
|
const SwTableNode* pTmpTableNd = nullptr;
|
2004-10-22 07:12:34 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
if( bWithPrev )
|
2004-10-22 07:12:34 +00:00
|
|
|
{
|
2015-05-20 13:05:49 +02:00
|
|
|
pTmpTableNd = rNds[ pTableNd->GetIndex() - 1 ]->FindTableNode();
|
2011-02-08 08:51:51 +01:00
|
|
|
// Consider table in table case
|
2015-05-20 13:05:49 +02:00
|
|
|
if ( pTmpTableNd && pTmpTableNd->EndOfSectionIndex() != pTableNd->GetIndex() - 1 )
|
2015-11-10 10:25:48 +01:00
|
|
|
pTmpTableNd = nullptr;
|
2004-10-22 07:12:34 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2015-05-20 13:05:49 +02:00
|
|
|
pTmpTableNd = rNds[ pTableNd->EndOfSectionIndex() + 1 ]->GetTableNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2015-09-30 16:10:07 +02:00
|
|
|
bRet = pTmpTableNd && dynamic_cast< const SwDDETable* >(&pTmpTableNd->GetTable()) == nullptr &&
|
2015-05-20 13:05:49 +02:00
|
|
|
bNew == pTmpTableNd->GetTable().IsNewModel();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:07:31 +02:00
|
|
|
/** create InsertDB as table Undo */
|
2014-04-25 14:00:35 +02:00
|
|
|
void SwEditShell::AppendUndoForInsertFromDB( bool bIsTable )
|
2001-02-08 13:32:55 +00:00
|
|
|
{
|
2015-11-25 06:03:10 -05:00
|
|
|
GetDoc()->AppendUndoForInsertFromDB( *GetCursor(), bIsTable );
|
2001-02-08 13:32:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|