1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <hints.hxx>
30cdf0e10cSrcweir
31cdf0e10cSrcweir #define _SVSTDARR_ULONGS
32cdf0e10cSrcweir #include <svl/svstdarr.hxx>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #include <vcl/window.hxx>
36cdf0e10cSrcweir #include <editeng/boxitem.hxx>
37cdf0e10cSrcweir #include <swwait.hxx>
38cdf0e10cSrcweir #include <fmtfsize.hxx>
39cdf0e10cSrcweir #include <frmatr.hxx>
40cdf0e10cSrcweir #include <editsh.hxx>
41cdf0e10cSrcweir #include <doc.hxx>
42cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
43cdf0e10cSrcweir #include <cntfrm.hxx>
44cdf0e10cSrcweir #include <pam.hxx>
45cdf0e10cSrcweir #include <ndtxt.hxx>
46cdf0e10cSrcweir #include <fldbas.hxx>
47cdf0e10cSrcweir #include <swtable.hxx>
48cdf0e10cSrcweir #include <swundo.hxx>
49cdf0e10cSrcweir #include <tblsel.hxx>
50cdf0e10cSrcweir #include <edimp.hxx>
51cdf0e10cSrcweir #include <tabfrm.hxx>
52cdf0e10cSrcweir #include <cellfrm.hxx>
53cdf0e10cSrcweir #include <cellatr.hxx>
54cdf0e10cSrcweir #include <swtblfmt.hxx>
55cdf0e10cSrcweir #include <swddetbl.hxx>
56cdf0e10cSrcweir #include <mdiexp.hxx>
57cdf0e10cSrcweir #include <unochart.hxx>
58cdf0e10cSrcweir
59cdf0e10cSrcweir using namespace ::com::sun::star;
60cdf0e10cSrcweir using namespace ::com::sun::star::uno;
61cdf0e10cSrcweir
62cdf0e10cSrcweir extern void ClearFEShellTabCols();
63cdf0e10cSrcweir
64abd49ff3SOliver-Rainer Wittmann //Added for bug 119954:Application crashed if undo/redo covert nest table to text
65abd49ff3SOliver-Rainer Wittmann sal_Bool ConvertTableToText( const SwTableNode *pTableNode, sal_Unicode cCh );
66abd49ff3SOliver-Rainer Wittmann
ConvertNestedTablesToText(const SwTableLines & rTableLines,sal_Unicode cCh)67abd49ff3SOliver-Rainer Wittmann void ConvertNestedTablesToText( const SwTableLines &rTableLines, sal_Unicode cCh )
68abd49ff3SOliver-Rainer Wittmann {
69abd49ff3SOliver-Rainer Wittmann for( sal_uInt16 n = 0; n < rTableLines.Count(); ++n )
70abd49ff3SOliver-Rainer Wittmann {
71abd49ff3SOliver-Rainer Wittmann SwTableLine* pTableLine = rTableLines[ n ];
72abd49ff3SOliver-Rainer Wittmann for( sal_uInt16 i = 0; i < pTableLine->GetTabBoxes().Count(); ++i )
73abd49ff3SOliver-Rainer Wittmann {
74abd49ff3SOliver-Rainer Wittmann SwTableBox* pTableBox = pTableLine->GetTabBoxes()[ i ];
75abd49ff3SOliver-Rainer Wittmann if ( !pTableBox->GetTabLines().Count() )
76abd49ff3SOliver-Rainer Wittmann {
77abd49ff3SOliver-Rainer Wittmann SwNodeIndex nodeIndex( *pTableBox->GetSttNd(), 1 );
78abd49ff3SOliver-Rainer Wittmann SwNodeIndex endNodeIndex( *pTableBox->GetSttNd()->EndOfSectionNode() );
79abd49ff3SOliver-Rainer Wittmann for( ; nodeIndex < endNodeIndex ; nodeIndex++ )
80abd49ff3SOliver-Rainer Wittmann {
81abd49ff3SOliver-Rainer Wittmann if ( SwTableNode* pTableNode = nodeIndex.GetNode().GetTableNode() )
82abd49ff3SOliver-Rainer Wittmann ConvertTableToText( pTableNode, cCh );
83abd49ff3SOliver-Rainer Wittmann }
84abd49ff3SOliver-Rainer Wittmann }
85abd49ff3SOliver-Rainer Wittmann else
86abd49ff3SOliver-Rainer Wittmann {
87abd49ff3SOliver-Rainer Wittmann ConvertNestedTablesToText( pTableBox->GetTabLines(), cCh );
88abd49ff3SOliver-Rainer Wittmann }
89abd49ff3SOliver-Rainer Wittmann }
90abd49ff3SOliver-Rainer Wittmann }
91abd49ff3SOliver-Rainer Wittmann }
92abd49ff3SOliver-Rainer Wittmann
ConvertTableToText(const SwTableNode * pConstTableNode,sal_Unicode cCh)93abd49ff3SOliver-Rainer Wittmann sal_Bool ConvertTableToText( const SwTableNode *pConstTableNode, sal_Unicode cCh )
94abd49ff3SOliver-Rainer Wittmann {
95abd49ff3SOliver-Rainer Wittmann SwTableNode *pTableNode = const_cast< SwTableNode* >( pConstTableNode );
96abd49ff3SOliver-Rainer Wittmann ConvertNestedTablesToText( pTableNode->GetTable().GetTabLines(), cCh );
97abd49ff3SOliver-Rainer Wittmann return pTableNode->GetDoc()->TableToText( pTableNode, cCh );
98abd49ff3SOliver-Rainer Wittmann }
99abd49ff3SOliver-Rainer Wittmann //End for bug 119954
InsertTable(const SwInsertTableOptions & rInsTblOpts,sal_uInt16 nRows,sal_uInt16 nCols,sal_Int16 eAdj,const SwTableAutoFmt * pTAFmt)100cdf0e10cSrcweir const SwTable& SwEditShell::InsertTable( const SwInsertTableOptions& rInsTblOpts,
101cdf0e10cSrcweir sal_uInt16 nRows, sal_uInt16 nCols,
102cdf0e10cSrcweir sal_Int16 eAdj,
103cdf0e10cSrcweir const SwTableAutoFmt* pTAFmt )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir StartAllAction();
106cdf0e10cSrcweir SwPosition* pPos = GetCrsr()->GetPoint();
107cdf0e10cSrcweir
108cdf0e10cSrcweir sal_Bool bEndUndo = 0 != pPos->nContent.GetIndex();
109cdf0e10cSrcweir if( bEndUndo )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir StartUndo( UNDO_START );
112cdf0e10cSrcweir GetDoc()->SplitNode( *pPos, false );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
115cdf0e10cSrcweir /* #109161# If called from a shell the adjust item is propagated
116cdf0e10cSrcweir from pPos to the new content nodes in the table.
117cdf0e10cSrcweir */
118cdf0e10cSrcweir const SwTable *pTable = GetDoc()->InsertTable( rInsTblOpts, *pPos,
119cdf0e10cSrcweir nRows, nCols,
120cdf0e10cSrcweir eAdj, pTAFmt,
121cdf0e10cSrcweir 0, sal_True );
122cdf0e10cSrcweir if( bEndUndo )
123cdf0e10cSrcweir EndUndo( UNDO_END );
124cdf0e10cSrcweir
125cdf0e10cSrcweir EndAllAction();
126cdf0e10cSrcweir return *pTable;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
TextToTable(const SwInsertTableOptions & rInsTblOpts,sal_Unicode cCh,sal_Int16 eAdj,const SwTableAutoFmt * pTAFmt)129cdf0e10cSrcweir sal_Bool SwEditShell::TextToTable( const SwInsertTableOptions& rInsTblOpts,
130cdf0e10cSrcweir sal_Unicode cCh,
131cdf0e10cSrcweir sal_Int16 eAdj,
132cdf0e10cSrcweir const SwTableAutoFmt* pTAFmt )
133cdf0e10cSrcweir {
134*8ef2f12bSOliver-Rainer Wittmann SwWait aWait( *GetDoc()->GetDocShell(), true );
135cdf0e10cSrcweir sal_Bool bRet = sal_False;
136cdf0e10cSrcweir StartAllAction();
137cdf0e10cSrcweir FOREACHPAM_START(this)
138cdf0e10cSrcweir if( PCURCRSR->HasMark() )
139cdf0e10cSrcweir bRet |= 0 != GetDoc()->TextToTable( rInsTblOpts, *PCURCRSR, cCh,
140cdf0e10cSrcweir eAdj, pTAFmt );
141cdf0e10cSrcweir FOREACHPAM_END()
142cdf0e10cSrcweir EndAllAction();
143cdf0e10cSrcweir return bRet;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
TableToText(sal_Unicode cCh)146cdf0e10cSrcweir sal_Bool SwEditShell::TableToText( sal_Unicode cCh )
147cdf0e10cSrcweir {
148*8ef2f12bSOliver-Rainer Wittmann SwWait aWait( *GetDoc()->GetDocShell(), true );
149cdf0e10cSrcweir sal_Bool bRet = sal_False;
150cdf0e10cSrcweir SwPaM* pCrsr = GetCrsr();
151cdf0e10cSrcweir const SwTableNode* pTblNd =
152cdf0e10cSrcweir GetDoc()->IsIdxInTbl( pCrsr->GetPoint()->nNode );
153cdf0e10cSrcweir if( IsTableMode() )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir ClearMark();
156cdf0e10cSrcweir pCrsr = GetCrsr();
157cdf0e10cSrcweir }
158cdf0e10cSrcweir else if( !pTblNd || pCrsr->GetNext() != pCrsr )
159cdf0e10cSrcweir return bRet;
160cdf0e10cSrcweir
161cdf0e10cSrcweir // TL_CHART2:
162cdf0e10cSrcweir // tell the charts about the table to be deleted and have them use their own data
163cdf0e10cSrcweir GetDoc()->CreateChartInternalDataProviders( &pTblNd->GetTable() );
164cdf0e10cSrcweir
165cdf0e10cSrcweir StartAllAction();
166cdf0e10cSrcweir
167cdf0e10cSrcweir // verschiebe den akt. Cursor aus dem Tabellen Bereich
168cdf0e10cSrcweir // angemeldet ist
169cdf0e10cSrcweir SwNodeIndex aTabIdx( *pTblNd );
170cdf0e10cSrcweir pCrsr->DeleteMark();
171cdf0e10cSrcweir pCrsr->GetPoint()->nNode = *pTblNd->EndOfSectionNode();
172cdf0e10cSrcweir pCrsr->GetPoint()->nContent.Assign( 0, 0 );
173cdf0e10cSrcweir // SPoint und Mark aus dem Bereich verschieben !!!
174cdf0e10cSrcweir pCrsr->SetMark();
175cdf0e10cSrcweir pCrsr->DeleteMark();
176cdf0e10cSrcweir
177abd49ff3SOliver-Rainer Wittmann //Modified for bug 119954:Application crashed if undo/redo covert nest table to text
178abd49ff3SOliver-Rainer Wittmann StartUndo();//UNDO_START
179abd49ff3SOliver-Rainer Wittmann bRet = ConvertTableToText( pTblNd, cCh );
180abd49ff3SOliver-Rainer Wittmann EndUndo();//UNDO_END
181abd49ff3SOliver-Rainer Wittmann //End for bug 119954
182cdf0e10cSrcweir pCrsr->GetPoint()->nNode = aTabIdx;
183cdf0e10cSrcweir
184cdf0e10cSrcweir SwCntntNode* pCNd = pCrsr->GetCntntNode();
185cdf0e10cSrcweir if( !pCNd )
186cdf0e10cSrcweir pCrsr->Move( fnMoveForward, fnGoCntnt );
187cdf0e10cSrcweir else
188cdf0e10cSrcweir pCrsr->GetPoint()->nContent.Assign( pCNd, 0 );
189cdf0e10cSrcweir
190cdf0e10cSrcweir EndAllAction();
191cdf0e10cSrcweir return bRet;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir
IsTextToTableAvailable() const194cdf0e10cSrcweir sal_Bool SwEditShell::IsTextToTableAvailable() const
195cdf0e10cSrcweir {
196cdf0e10cSrcweir sal_Bool bOnlyText = sal_False;
197cdf0e10cSrcweir FOREACHPAM_START(this)
198cdf0e10cSrcweir if( PCURCRSR->HasMark() && *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir bOnlyText = sal_True;
201cdf0e10cSrcweir
202cdf0e10cSrcweir // pruefe ob in der Selection eine Tabelle liegt
203cdf0e10cSrcweir sal_uLong nStt = PCURCRSR->GetMark()->nNode.GetIndex(),
204cdf0e10cSrcweir nEnd = PCURCRSR->GetPoint()->nNode.GetIndex();
205cdf0e10cSrcweir if( nStt > nEnd ) { sal_uLong n = nStt; nStt = nEnd; nEnd = n; }
206cdf0e10cSrcweir
207cdf0e10cSrcweir for( ; nStt <= nEnd; ++nStt )
208cdf0e10cSrcweir if( !GetDoc()->GetNodes()[ nStt ]->IsTxtNode() )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir bOnlyText = sal_False;
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir }
213cdf0e10cSrcweir
214cdf0e10cSrcweir if( !bOnlyText )
215cdf0e10cSrcweir break;
216cdf0e10cSrcweir }
217cdf0e10cSrcweir FOREACHPAM_END()
218cdf0e10cSrcweir
219cdf0e10cSrcweir return bOnlyText;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
InsertDDETable(const SwInsertTableOptions & rInsTblOpts,SwDDEFieldType * pDDEType,sal_uInt16 nRows,sal_uInt16 nCols,sal_Int16 eAdj)222cdf0e10cSrcweir void SwEditShell::InsertDDETable( const SwInsertTableOptions& rInsTblOpts,
223cdf0e10cSrcweir SwDDEFieldType* pDDEType,
224cdf0e10cSrcweir sal_uInt16 nRows, sal_uInt16 nCols,
225cdf0e10cSrcweir sal_Int16 eAdj )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir SwPosition* pPos = GetCrsr()->GetPoint();
228cdf0e10cSrcweir
229cdf0e10cSrcweir StartAllAction();
230cdf0e10cSrcweir
231cdf0e10cSrcweir sal_Bool bEndUndo = 0 != pPos->nContent.GetIndex();
232cdf0e10cSrcweir if( bEndUndo )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir StartUndo( UNDO_START );
235cdf0e10cSrcweir GetDoc()->SplitNode( *pPos, false );
236cdf0e10cSrcweir }
237cdf0e10cSrcweir
238cdf0e10cSrcweir const SwInsertTableOptions aInsTblOpts( rInsTblOpts.mnInsMode | tabopts::DEFAULT_BORDER,
239cdf0e10cSrcweir rInsTblOpts.mnRowsToRepeat );
240cdf0e10cSrcweir SwTable* pTbl = (SwTable*)GetDoc()->InsertTable( aInsTblOpts, *pPos,
241cdf0e10cSrcweir nRows, nCols, eAdj );
242cdf0e10cSrcweir
243cdf0e10cSrcweir SwTableNode* pTblNode = (SwTableNode*)pTbl->GetTabSortBoxes()[ 0 ]->
244cdf0e10cSrcweir GetSttNd()->FindTableNode();
245cdf0e10cSrcweir SwDDETable* pDDETbl = new SwDDETable( *pTbl, pDDEType );
246cdf0e10cSrcweir pTblNode->SetNewTable( pDDETbl ); // setze die DDE-Tabelle
247cdf0e10cSrcweir
248cdf0e10cSrcweir if( bEndUndo )
249cdf0e10cSrcweir EndUndo( UNDO_END );
250cdf0e10cSrcweir
251cdf0e10cSrcweir EndAllAction();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir /*--------------------------------------------------------------------
255cdf0e10cSrcweir Beschreibung: Tabellenfelder einer Tabelle updaten
256cdf0e10cSrcweir --------------------------------------------------------------------*/
UpdateTable()257cdf0e10cSrcweir void SwEditShell::UpdateTable()
258cdf0e10cSrcweir {
259cdf0e10cSrcweir const SwTableNode* pTblNd = IsCrsrInTbl();
260cdf0e10cSrcweir
261cdf0e10cSrcweir // Keine Arme keine Kekse
262cdf0e10cSrcweir if( pTblNd )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir StartAllAction();
265cdf0e10cSrcweir if( DoesUndo() )
266cdf0e10cSrcweir StartUndo();
267cdf0e10cSrcweir EndAllTblBoxEdit();
268cdf0e10cSrcweir SwTableFmlUpdate aTblUpdate( (SwTable*)&pTblNd->GetTable() );
269cdf0e10cSrcweir GetDoc()->UpdateTblFlds( &aTblUpdate );
270cdf0e10cSrcweir if( DoesUndo() )
271cdf0e10cSrcweir EndUndo();
272cdf0e10cSrcweir EndAllAction();
273cdf0e10cSrcweir }
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
276cdf0e10cSrcweir // Change Modus erfragen/setzen
GetTblChgMode() const277cdf0e10cSrcweir TblChgMode SwEditShell::GetTblChgMode() const
278cdf0e10cSrcweir {
279cdf0e10cSrcweir TblChgMode eMode;
280cdf0e10cSrcweir const SwTableNode* pTblNd = IsCrsrInTbl();
281cdf0e10cSrcweir if( pTblNd )
282cdf0e10cSrcweir eMode = pTblNd->GetTable().GetTblChgMode();
283cdf0e10cSrcweir else
284cdf0e10cSrcweir eMode = GetTblChgDefaultMode();
285cdf0e10cSrcweir return eMode;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir
SetTblChgMode(TblChgMode eMode)288cdf0e10cSrcweir void SwEditShell::SetTblChgMode( TblChgMode eMode )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir const SwTableNode* pTblNd = IsCrsrInTbl();
291cdf0e10cSrcweir
292cdf0e10cSrcweir // Keine Arme keine Kekse
293cdf0e10cSrcweir if( pTblNd )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir ((SwTable&)pTblNd->GetTable()).SetTblChgMode( eMode );
296cdf0e10cSrcweir if( !GetDoc()->IsModified() ) // Bug 57028
297cdf0e10cSrcweir {
298cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified();
299cdf0e10cSrcweir }
300cdf0e10cSrcweir GetDoc()->SetModified();
301cdf0e10cSrcweir }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
GetTblBoxFormulaAttrs(SfxItemSet & rSet) const304cdf0e10cSrcweir sal_Bool SwEditShell::GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const
305cdf0e10cSrcweir {
306cdf0e10cSrcweir SwSelBoxes aBoxes;
307cdf0e10cSrcweir if( IsTableMode() )
308cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
309cdf0e10cSrcweir else
310cdf0e10cSrcweir {
311cdf0e10cSrcweir do {
312cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
313cdf0e10cSrcweir do {
314cdf0e10cSrcweir pFrm = pFrm->GetUpper();
315cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
316cdf0e10cSrcweir if ( pFrm )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
319cdf0e10cSrcweir aBoxes.Insert( pBox );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir } while( sal_False );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir
324cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir const SwTableBox* pSelBox = aBoxes[ n ];
327cdf0e10cSrcweir const SwTableBoxFmt* pTblFmt = (SwTableBoxFmt*)pSelBox->GetFrmFmt();
328cdf0e10cSrcweir if( !n )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir // Formeln in die externe Darstellung bringen!
331cdf0e10cSrcweir const SwTable& rTbl = pSelBox->GetSttNd()->FindTableNode()->GetTable();
332cdf0e10cSrcweir
333cdf0e10cSrcweir SwTableFmlUpdate aTblUpdate( (SwTable*)&rTbl );
334cdf0e10cSrcweir aTblUpdate.eFlags = TBL_BOXNAME;
335cdf0e10cSrcweir ((SwDoc*)GetDoc())->UpdateTblFlds( &aTblUpdate );
336cdf0e10cSrcweir
337cdf0e10cSrcweir rSet.Put( pTblFmt->GetAttrSet() );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir else
340cdf0e10cSrcweir rSet.MergeValues( pTblFmt->GetAttrSet() );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir return 0 != rSet.Count();
343cdf0e10cSrcweir }
344cdf0e10cSrcweir
SetTblBoxFormulaAttrs(const SfxItemSet & rSet)345cdf0e10cSrcweir void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet )
346cdf0e10cSrcweir {
347cdf0e10cSrcweir SET_CURR_SHELL( this );
348cdf0e10cSrcweir SwSelBoxes aBoxes;
349cdf0e10cSrcweir if( IsTableMode() )
350cdf0e10cSrcweir ::GetTblSelCrs( *this, aBoxes );
351cdf0e10cSrcweir else
352cdf0e10cSrcweir {
353cdf0e10cSrcweir do {
354cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
355cdf0e10cSrcweir do {
356cdf0e10cSrcweir pFrm = pFrm->GetUpper();
357cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
358cdf0e10cSrcweir if ( pFrm )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir SwTableBox *pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
361cdf0e10cSrcweir aBoxes.Insert( pBox );
362cdf0e10cSrcweir }
363cdf0e10cSrcweir } while( sal_False );
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir // beim setzen einer Formel keine Ueberpruefung mehr vornehmen!
367cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMULA ))
368cdf0e10cSrcweir ClearTblBoxCntnt();
369cdf0e10cSrcweir
370cdf0e10cSrcweir StartAllAction();
371cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
372cdf0e10cSrcweir for( sal_uInt16 n = 0; n < aBoxes.Count(); ++n )
373cdf0e10cSrcweir GetDoc()->SetTblBoxFormulaAttrs( *aBoxes[ n ], rSet );
374cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
375cdf0e10cSrcweir EndAllAction();
376cdf0e10cSrcweir }
377cdf0e10cSrcweir
IsTableBoxTextFormat() const378cdf0e10cSrcweir sal_Bool SwEditShell::IsTableBoxTextFormat() const
379cdf0e10cSrcweir {
380cdf0e10cSrcweir if( IsTableMode() )
381cdf0e10cSrcweir return sal_False;
382cdf0e10cSrcweir
383cdf0e10cSrcweir SwTableBox *pBox = 0;
384cdf0e10cSrcweir {
385cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
386cdf0e10cSrcweir do {
387cdf0e10cSrcweir pFrm = pFrm->GetUpper();
388cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
389cdf0e10cSrcweir if ( pFrm )
390cdf0e10cSrcweir pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir if( !pBox )
394cdf0e10cSrcweir return sal_False;
395cdf0e10cSrcweir
396cdf0e10cSrcweir sal_uInt32 nFmt;
397cdf0e10cSrcweir const SfxPoolItem* pItem;
398cdf0e10cSrcweir if( SFX_ITEM_SET == pBox->GetFrmFmt()->GetAttrSet().GetItemState(
399cdf0e10cSrcweir RES_BOXATR_FORMAT, sal_True, &pItem ))
400cdf0e10cSrcweir {
401cdf0e10cSrcweir nFmt = ((SwTblBoxNumFormat*)pItem)->GetValue();
402cdf0e10cSrcweir return GetDoc()->GetNumberFormatter()->IsTextFormat( nFmt ) ||
403cdf0e10cSrcweir NUMBERFORMAT_TEXT == nFmt;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir sal_uLong nNd = pBox->IsValidNumTxtNd();
407cdf0e10cSrcweir if( ULONG_MAX == nNd )
408cdf0e10cSrcweir return sal_True;
409cdf0e10cSrcweir
410cdf0e10cSrcweir const String& rTxt = GetDoc()->GetNodes()[ nNd ]->GetTxtNode()->GetTxt();
411cdf0e10cSrcweir if( !rTxt.Len() )
412cdf0e10cSrcweir return sal_False;
413cdf0e10cSrcweir
414cdf0e10cSrcweir double fVal;
415cdf0e10cSrcweir return !GetDoc()->GetNumberFormatter()->IsNumberFormat( rTxt, nFmt, fVal );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir
GetTableBoxText() const418cdf0e10cSrcweir String SwEditShell::GetTableBoxText() const
419cdf0e10cSrcweir {
420cdf0e10cSrcweir String sRet;
421cdf0e10cSrcweir if( !IsTableMode() )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir SwTableBox *pBox = 0;
424cdf0e10cSrcweir {
425cdf0e10cSrcweir SwFrm *pFrm = GetCurrFrm();
426cdf0e10cSrcweir do {
427cdf0e10cSrcweir pFrm = pFrm->GetUpper();
428cdf0e10cSrcweir } while ( pFrm && !pFrm->IsCellFrm() );
429cdf0e10cSrcweir if ( pFrm )
430cdf0e10cSrcweir pBox = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir sal_uLong nNd;
434cdf0e10cSrcweir if( pBox && ULONG_MAX != ( nNd = pBox->IsValidNumTxtNd() ) )
435cdf0e10cSrcweir sRet = GetDoc()->GetNodes()[ nNd ]->GetTxtNode()->GetTxt();
436cdf0e10cSrcweir }
437cdf0e10cSrcweir return sRet;
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
SplitTable(sal_uInt16 eMode)440cdf0e10cSrcweir sal_Bool SwEditShell::SplitTable( sal_uInt16 eMode )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir sal_Bool bRet = sal_False;
443cdf0e10cSrcweir SwPaM *pCrsr = GetCrsr();
444cdf0e10cSrcweir if( pCrsr->GetNode()->FindTableNode() )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir StartAllAction();
447cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
448cdf0e10cSrcweir
449cdf0e10cSrcweir bRet = GetDoc()->SplitTable( *pCrsr->GetPoint(), eMode, sal_True );
450cdf0e10cSrcweir
451cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
452cdf0e10cSrcweir ClearFEShellTabCols();
453cdf0e10cSrcweir EndAllAction();
454cdf0e10cSrcweir }
455cdf0e10cSrcweir return bRet;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
MergeTable(sal_Bool bWithPrev,sal_uInt16 nMode)458cdf0e10cSrcweir sal_Bool SwEditShell::MergeTable( sal_Bool bWithPrev, sal_uInt16 nMode )
459cdf0e10cSrcweir {
460cdf0e10cSrcweir sal_Bool bRet = sal_False;
461cdf0e10cSrcweir SwPaM *pCrsr = GetCrsr();
462cdf0e10cSrcweir if( pCrsr->GetNode()->FindTableNode() )
463cdf0e10cSrcweir {
464cdf0e10cSrcweir StartAllAction();
465cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
466cdf0e10cSrcweir
467cdf0e10cSrcweir bRet = GetDoc()->MergeTable( *pCrsr->GetPoint(), bWithPrev, nMode );
468cdf0e10cSrcweir
469cdf0e10cSrcweir GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
470cdf0e10cSrcweir ClearFEShellTabCols();
471cdf0e10cSrcweir EndAllAction();
472cdf0e10cSrcweir }
473cdf0e10cSrcweir return bRet;
474cdf0e10cSrcweir }
475cdf0e10cSrcweir
CanMergeTable(sal_Bool bWithPrev,sal_Bool * pChkNxtPrv) const476cdf0e10cSrcweir sal_Bool SwEditShell::CanMergeTable( sal_Bool bWithPrev, sal_Bool* pChkNxtPrv ) const
477cdf0e10cSrcweir {
478cdf0e10cSrcweir sal_Bool bRet = sal_False;
479cdf0e10cSrcweir const SwPaM *pCrsr = GetCrsr();
480cdf0e10cSrcweir const SwTableNode* pTblNd = pCrsr->GetNode()->FindTableNode();
481cdf0e10cSrcweir if( pTblNd && !pTblNd->GetTable().ISA( SwDDETable ))
482cdf0e10cSrcweir {
483cdf0e10cSrcweir sal_Bool bNew = pTblNd->GetTable().IsNewModel();
484cdf0e10cSrcweir const SwNodes& rNds = GetDoc()->GetNodes();
485cdf0e10cSrcweir if( pChkNxtPrv )
486cdf0e10cSrcweir {
487cdf0e10cSrcweir const SwTableNode* pChkNd = rNds[ pTblNd->GetIndex() - 1 ]->FindTableNode();
488cdf0e10cSrcweir if( pChkNd && !pChkNd->GetTable().ISA( SwDDETable ) &&
489cdf0e10cSrcweir bNew == pChkNd->GetTable().IsNewModel() &&
490cdf0e10cSrcweir // --> FME 2004-09-17 #117418# Consider table in table case
491cdf0e10cSrcweir pChkNd->EndOfSectionIndex() == pTblNd->GetIndex() - 1 )
492cdf0e10cSrcweir // <--
493cdf0e10cSrcweir *pChkNxtPrv = sal_True, bRet = sal_True; // mit Prev ist moeglich
494cdf0e10cSrcweir else
495cdf0e10cSrcweir {
496cdf0e10cSrcweir pChkNd = rNds[ pTblNd->EndOfSectionIndex() + 1 ]->GetTableNode();
497cdf0e10cSrcweir if( pChkNd && !pChkNd->GetTable().ISA( SwDDETable ) &&
498cdf0e10cSrcweir bNew == pChkNd->GetTable().IsNewModel() )
499cdf0e10cSrcweir *pChkNxtPrv = sal_False, bRet = sal_True; // mit Next ist moeglich
500cdf0e10cSrcweir }
501cdf0e10cSrcweir }
502cdf0e10cSrcweir else
503cdf0e10cSrcweir {
504cdf0e10cSrcweir const SwTableNode* pTmpTblNd = 0;
505cdf0e10cSrcweir
506cdf0e10cSrcweir if( bWithPrev )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir pTmpTblNd = rNds[ pTblNd->GetIndex() - 1 ]->FindTableNode();
509cdf0e10cSrcweir // --> FME 2004-09-17 #117418# Consider table in table case
510cdf0e10cSrcweir if ( pTmpTblNd && pTmpTblNd->EndOfSectionIndex() != pTblNd->GetIndex() - 1 )
511cdf0e10cSrcweir pTmpTblNd = 0;
512cdf0e10cSrcweir // <--
513cdf0e10cSrcweir }
514cdf0e10cSrcweir else
515cdf0e10cSrcweir pTmpTblNd = rNds[ pTblNd->EndOfSectionIndex() + 1 ]->GetTableNode();
516cdf0e10cSrcweir
517cdf0e10cSrcweir bRet = pTmpTblNd && !pTmpTblNd->GetTable().ISA( SwDDETable ) &&
518cdf0e10cSrcweir bNew == pTmpTblNd->GetTable().IsNewModel();
519cdf0e10cSrcweir }
520cdf0e10cSrcweir }
521cdf0e10cSrcweir return bRet;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir
524cdf0e10cSrcweir // setze das InsertDB als Tabelle Undo auf:
AppendUndoForInsertFromDB(sal_Bool bIsTable)525cdf0e10cSrcweir void SwEditShell::AppendUndoForInsertFromDB( sal_Bool bIsTable )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir GetDoc()->AppendUndoForInsertFromDB( *GetCrsr(), bIsTable );
528cdf0e10cSrcweir }
529cdf0e10cSrcweir
530