summaryrefslogtreecommitdiff
path: root/sw/source/ui/shells/basesh.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-06-01 07:05:01 +0000
committerOliver Bolte <obo@openoffice.org>2004-06-01 07:05:01 +0000
commit36275762b98d769b6798763b30a260be51ed5621 (patch)
tree05e1de1a180e5d6dcbcdfd540821d06c55e69b6d /sw/source/ui/shells/basesh.cxx
parent2849f3f4fa0eee1ce37a5d8b8d750adb729acb58 (diff)
INTEGRATION: CWS tableintable (1.48.14); FILE MERGED
2004/05/18 19:21:15 fme 1.48.14.4: Resolved merge conflicts 2004/05/17 14:07:44 fme 1.48.14.3: RESYNC: (1.48-1.50); FILE MERGED 2004/03/22 15:08:08 fme 1.48.14.2: #i26609# No TextToTable for table selections 2004/02/13 07:59:10 pb 1.48.14.1: fix: #i20193# InsertTable() added
Diffstat (limited to 'sw/source/ui/shells/basesh.cxx')
-rw-r--r--sw/source/ui/shells/basesh.cxx147
1 files changed, 145 insertions, 2 deletions
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index c0e87e66015d..5cf6f7138268 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basesh.cxx,v $
*
- * $Revision: 1.51 $
+ * $Revision: 1.52 $
*
- * last change: $Author: hr $ $Date: 2004-05-10 16:34:49 $
+ * last change: $Author: obo $ $Date: 2004-06-01 08:05:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -297,6 +297,20 @@
#include "fldui.hrc" //CHINA001
#include "table.hrc" //CHINA001
+// includes for InsertTable
+#ifndef _SVX_HTMLMODE_HXX
+#include <svx/htmlmode.hxx>
+#endif
+#ifndef _MODOPT_HXX //autogen
+#include <modcfg.hxx>
+#endif
+#ifndef _TBLAFMT_HXX
+#include <tblafmt.hxx>
+#endif
+#ifndef _INSTABLE_HXX
+#include <instable.hxx>
+#endif
+
USHORT SwBaseShell::nFrameMode = FLY_DRAG_END;
#define C2S(cChar) UniString::CreateFromAscii(cChar)
@@ -2525,6 +2539,135 @@ SwWrtShell* SwBaseShell::GetShellPtr()
return rView.GetWrtShellPtr();
}
+// ----------------------------------------------------------------------------
+
+void SwBaseShell::InsertTable( SfxRequest& _rRequest )
+{
+ const SfxItemSet* pArgs = _rRequest.GetArgs();
+ SwWrtShell& rSh = GetShell();
+
+ if ( !( rSh.GetFrmType( 0, TRUE ) & FRMTYPE_FOOTNOTE ) )
+ {
+ SwView &rView = GetView(); // Da GetView() nach Shellwechsel nicht mehr geht
+ BOOL bHTMLMode = 0 != (::GetHtmlMode(rView.GetDocShell())&HTMLMODE_ON);
+ BOOL bCallEndUndo = FALSE;
+
+ if( !pArgs && rSh.IsSelection() && !rSh.IsInClickToEdit() &&
+ !rSh.IsTableMode() )
+ {
+ const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ SwInsertTableOptions aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
+
+ rSh.StartUndo(UNDO_INSTABLE);
+ bCallEndUndo = TRUE;
+
+ BOOL bInserted = rSh.TextToTable( aInsTblOpts, '\t', HORI_FULL );
+ rSh.EnterStdMode();
+ if (bInserted)
+ rView.AutoCaption(TABLE_CAP);
+ _rRequest.Done();
+ }
+ else
+ {
+ USHORT nCols = 0;
+ USHORT nRows = 0;
+ SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 );
+ String aTableName, aAutoName;
+ SwTableAutoFmt* pTAFmt = 0;
+
+ if( pArgs && pArgs->Count() >= 2 )
+ {
+ SFX_REQUEST_ARG( _rRequest, pName, SfxStringItem, FN_INSERT_TABLE, sal_False );
+ SFX_REQUEST_ARG( _rRequest, pCols, SfxUInt16Item, SID_ATTR_TABLE_COLUMN, sal_False );
+ SFX_REQUEST_ARG( _rRequest, pRows, SfxUInt16Item, SID_ATTR_TABLE_ROW, sal_False );
+ SFX_REQUEST_ARG( _rRequest, pFlags, SfxInt32Item, FN_PARAM_1, sal_False );
+ SFX_REQUEST_ARG( _rRequest, pAuto, SfxStringItem, FN_PARAM_2, sal_False );
+
+ if ( pName )
+ aTableName = pName->GetValue();
+ if ( pCols )
+ nCols = pCols->GetValue();
+ if ( pRows )
+ nRows = pRows->GetValue();
+ if ( pAuto )
+ {
+ aAutoName = pAuto->GetValue();
+ if ( aAutoName.Len() )
+ {
+ SwTableAutoFmtTbl aTableTbl;
+ aTableTbl.Load();
+ for ( USHORT n=0; n<aTableTbl.Count(); n++ )
+ {
+ if ( aTableTbl[n]->GetName() == aAutoName )
+ {
+ pTAFmt = new SwTableAutoFmt( *aTableTbl[n] );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( pFlags )
+ aInsTblOpts.mnInsMode = (USHORT) pFlags->GetValue();
+ else
+ {
+ const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
+ aInsTblOpts = pModOpt->GetInsTblFlags(bHTMLMode);
+ }
+ }
+
+ if( !nCols || !nRows )
+ {
+ //CHINA001 SwInsTableDlg *pDlg = new SwInsTableDlg(rView);
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");//CHINA001
+ AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg( ResId(DLG_INSERT_TABLE), rView );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
+ if( RET_OK == pDlg->Execute() )
+ {
+ pDlg->GetValues( aTableName, nRows, nCols, aInsTblOpts, aAutoName, pTAFmt );
+ }
+ else
+ _rRequest.Ignore();
+ delete pDlg;
+ }
+
+ if( nCols && nRows )
+ {
+ // record before shell change
+ _rRequest.AppendItem( SfxStringItem( FN_INSERT_TABLE, aTableName ) );
+ if ( aAutoName.Len() )
+ _rRequest.AppendItem( SfxStringItem( FN_PARAM_2, aAutoName ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_COLUMN, nCols ) );
+ _rRequest.AppendItem( SfxUInt16Item( SID_ATTR_TABLE_ROW, nRows ) );
+ _rRequest.AppendItem( SfxInt32Item( FN_PARAM_1, (sal_Int32) aInsTblOpts.mnInsMode ) );
+ _rRequest.Done();
+
+ rSh.StartUndo(UNDO_INSTABLE);
+ bCallEndUndo = TRUE;
+
+ rSh.StartAllAction();
+ if( rSh.HasSelection() )
+ rSh.DelRight();
+
+ rSh.InsertTable( aInsTblOpts, nRows, nCols, HORI_FULL, pTAFmt );
+ rSh.MoveTable( fnTablePrev, fnTableStart );
+
+ if( aTableName.Len() && !rSh.GetTblStyle( aTableName ) )
+ rSh.GetTableFmt()->SetName( aTableName );
+
+ rSh.EndAllAction();
+ rView.AutoCaption(TABLE_CAP);
+ }
+ delete pTAFmt;
+ }
+
+ if( bCallEndUndo )
+ rSh.EndUndo(UNDO_INSTABLE); // wegen moegl. Shellwechsel
+ }
+}
+
+// ----------------------------------------------------------------------------
void SwBaseShell::GetGalleryState( SfxItemSet &rSet )
{