xref: /aoo41x/main/sw/source/ui/uiview/viewdlg2.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <sfx2/request.hxx>
29cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
30cdf0e10cSrcweir #include <sfx2/objface.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <fldmgr.hxx>
33cdf0e10cSrcweir #include <expfld.hxx>
34cdf0e10cSrcweir #include <modcfg.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <tools/shl.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include "swmodule.hxx"
39cdf0e10cSrcweir #include "view.hxx"
40cdf0e10cSrcweir #include "wview.hxx"
41cdf0e10cSrcweir #include "wrtsh.hxx"
42cdf0e10cSrcweir #include "cmdid.h"
43cdf0e10cSrcweir #include "caption.hxx"
44cdf0e10cSrcweir #include "poolfmt.hxx"
45cdf0e10cSrcweir #include "edtwin.hxx"
46cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "swabstdlg.hxx"
49cdf0e10cSrcweir #include "frmui.hrc"
50cdf0e10cSrcweir #include "misc.hrc"
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include "view.hrc"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir extern String* pOldGrfCat;
55cdf0e10cSrcweir extern String* pOldTabCat;
56cdf0e10cSrcweir extern String* pOldFrmCat;
57cdf0e10cSrcweir extern String* pOldDrwCat;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /* -----------------06.11.98 13:45-------------------
60cdf0e10cSrcweir  *
61cdf0e10cSrcweir  * --------------------------------------------------*/
62cdf0e10cSrcweir 
ExecDlgExt(SfxRequest & rReq)63cdf0e10cSrcweir void SwView::ExecDlgExt(SfxRequest &rReq)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	Window *pMDI = &GetViewFrame()->GetWindow();
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
68cdf0e10cSrcweir 	{
69cdf0e10cSrcweir 		case FN_INSERT_CAPTION:
70cdf0e10cSrcweir 		{
71cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
72cdf0e10cSrcweir             DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
73cdf0e10cSrcweir 
74cdf0e10cSrcweir             VclAbstractDialog* pDialog = pFact->CreateSwCaptionDialog( pMDI, *this, DLG_CAPTION );
75cdf0e10cSrcweir             DBG_ASSERT(pDialog, "Dialogdiet fail!");
76cdf0e10cSrcweir 			if ( pDialog )
77cdf0e10cSrcweir 			{
78cdf0e10cSrcweir 				pDialog->Execute();
79cdf0e10cSrcweir 				delete pDialog;
80cdf0e10cSrcweir 			}
81cdf0e10cSrcweir 			break;
82cdf0e10cSrcweir 		}
83cdf0e10cSrcweir 		case  FN_EDIT_FOOTNOTE:
84cdf0e10cSrcweir 		{
85cdf0e10cSrcweir 			SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
86cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet fail!");
87cdf0e10cSrcweir             AbstractInsFootNoteDlg* pDlg = pFact->CreateInsFootNoteDlg( DLG_INS_FOOTNOTE,
88cdf0e10cSrcweir 														pMDI, *pWrtShell, sal_True );
89cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
90cdf0e10cSrcweir 
91cdf0e10cSrcweir             pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand());
92cdf0e10cSrcweir             pDlg->SetText( SW_RESSTR(STR_EDIT_FOOTNOTE) );
93cdf0e10cSrcweir 			pDlg->Execute();
94cdf0e10cSrcweir 			delete pDlg;
95cdf0e10cSrcweir 			break;
96cdf0e10cSrcweir 		}
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir /* -----------------06.11.98 14:53-------------------
101cdf0e10cSrcweir  *
102cdf0e10cSrcweir  * --------------------------------------------------*/
103cdf0e10cSrcweir 
AutoCaption(const sal_uInt16 nType,const SvGlobalName * pOleId)104cdf0e10cSrcweir void SwView::AutoCaption(const sal_uInt16 nType, const SvGlobalName *pOleId)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	sal_Bool bWeb = 0 != PTR_CAST(SwWebView, this);
109cdf0e10cSrcweir 	if (pModOpt->IsInsWithCaption(bWeb))
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		const InsCaptionOpt *pOpt = pModOpt->GetCapOption(bWeb, (SwCapObjType)nType, pOleId);
112cdf0e10cSrcweir 		if (pOpt && pOpt->UseCaption() == sal_True)
113cdf0e10cSrcweir 			InsertCaption(pOpt);
114cdf0e10cSrcweir 	}
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /* -----------------06.11.98 12:58-------------------
118cdf0e10cSrcweir  *
119cdf0e10cSrcweir  * --------------------------------------------------*/
120cdf0e10cSrcweir 
InsertCaption(const InsCaptionOpt * pOpt)121cdf0e10cSrcweir void SwView::InsertCaption(const InsCaptionOpt *pOpt)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	if (!pOpt)
124cdf0e10cSrcweir 		return;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	const String &rName = pOpt->GetCategory();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	// Existiert Pool-Vorlage gleichen Namens?
129cdf0e10cSrcweir 	SwWrtShell &rSh = GetWrtShell();
130cdf0e10cSrcweir     if(rName.Len())
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName(rName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
133cdf0e10cSrcweir         if( USHRT_MAX != nPoolId )
134cdf0e10cSrcweir             rSh.GetTxtCollFromPool(nPoolId);
135cdf0e10cSrcweir             // Pool-Vorlage existiert nicht: Existiert sie am Dokument?
136cdf0e10cSrcweir         else if( !rSh.GetParaStyle(rName) )
137cdf0e10cSrcweir         {
138cdf0e10cSrcweir             // Sie existiert auch nicht am Dokument: erzeugen
139cdf0e10cSrcweir             SwTxtFmtColl* pDerivedFrom = rSh.GetTxtCollFromPool(RES_POOLCOLL_LABEL);
140cdf0e10cSrcweir             rSh.MakeTxtFmtColl(rName, pDerivedFrom);
141cdf0e10cSrcweir         }
142cdf0e10cSrcweir     }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	SelectionType eType = rSh.GetSelectionType();
145cdf0e10cSrcweir 	if (eType & nsSelectionType::SEL_OLE)
146cdf0e10cSrcweir 		eType = nsSelectionType::SEL_GRF;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	// SwLabelType
149cdf0e10cSrcweir     const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE :
150cdf0e10cSrcweir 					  eType & nsSelectionType::SEL_FRM ? LTYPE_FLY :
151cdf0e10cSrcweir 					  eType == nsSelectionType::SEL_TXT ? LTYPE_FLY :
152cdf0e10cSrcweir 					  eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW :
153cdf0e10cSrcweir 													LTYPE_OBJECT;
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	SwFldMgr aMgr(&rSh);
156cdf0e10cSrcweir 	SwSetExpFieldType* pFldType =
157cdf0e10cSrcweir 			(SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
158cdf0e10cSrcweir     if (!pFldType && rName.Len() )
159cdf0e10cSrcweir 	{
160cdf0e10cSrcweir 		// Neuen Feldtypen erzeugen
161cdf0e10cSrcweir 		SwSetExpFieldType aSwSetExpFieldType(rSh.GetDoc(), rName, nsSwGetSetExpType::GSE_SEQ);
162cdf0e10cSrcweir 		aMgr.InsertFldType(aSwSetExpFieldType);
163cdf0e10cSrcweir 		pFldType = (SwSetExpFieldType*)aMgr.GetFldType(RES_SETEXPFLD, rName);
164cdf0e10cSrcweir 	}
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	if (!pOpt->IgnoreSeqOpts())
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		if (pFldType)
169cdf0e10cSrcweir 		{
170cdf0e10cSrcweir 			pFldType->SetDelimiter(pOpt->GetSeparator());
171cdf0e10cSrcweir             pFldType->SetOutlineLvl( static_cast< sal_uInt8 >(pOpt->GetLevel()) );
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     sal_uInt16       nID    = USHRT_MAX;
176cdf0e10cSrcweir 	SwFieldType* pType 	= 0;
177cdf0e10cSrcweir 	const sal_uInt16 nCount = aMgr.GetFldTypeCount();
178cdf0e10cSrcweir     if( rName.Len() )
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < nCount; ++i)
181cdf0e10cSrcweir         {
182cdf0e10cSrcweir             pType = aMgr.GetFldType(USHRT_MAX, i);
183cdf0e10cSrcweir             String aTmpName( pType->GetName() );
184cdf0e10cSrcweir             if (aTmpName == rName && pType->Which() == RES_SETEXPFLD)
185cdf0e10cSrcweir             {
186cdf0e10cSrcweir                 nID = i;
187cdf0e10cSrcweir                 break;
188cdf0e10cSrcweir             }
189cdf0e10cSrcweir         }
190cdf0e10cSrcweir     }
191cdf0e10cSrcweir 	rSh.StartAllAction();
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     GetWrtShell().InsertLabel( eT,
194cdf0e10cSrcweir                                 pOpt->GetCaption(),
195cdf0e10cSrcweir                                 !pOpt->IgnoreSeqOpts() ? aEmptyStr : pOpt->GetSeparator(),
196cdf0e10cSrcweir                                 pOpt->GetNumSeparator(),
197cdf0e10cSrcweir 								!pOpt->GetPos(),
198cdf0e10cSrcweir 								nID,
199cdf0e10cSrcweir                                 pOpt->GetCharacterStyle(),
200cdf0e10cSrcweir                                 pOpt->CopyAttributes() );
201cdf0e10cSrcweir 	// Nummernformat setzen
202cdf0e10cSrcweir     if(pType)
203cdf0e10cSrcweir 	    ((SwSetExpFieldType*)pType)->SetSeqFormat(pOpt->GetNumType());
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	rSh.UpdateExpFlds( sal_True );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	rSh.EndAllAction();
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	if ( rSh.IsFrmSelected() )
210cdf0e10cSrcweir 	{
211cdf0e10cSrcweir 		GetEditWin().StopInsFrm();
212cdf0e10cSrcweir 		rSh.EnterSelFrmMode();
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	// Kategorie merken
216cdf0e10cSrcweir 	String** ppStr = 0;
217cdf0e10cSrcweir 	if (eType & nsSelectionType::SEL_GRF)
218cdf0e10cSrcweir 		ppStr = &pOldGrfCat;
219cdf0e10cSrcweir 	else if( eType & nsSelectionType::SEL_TBL)
220cdf0e10cSrcweir 		ppStr = &pOldTabCat;
221cdf0e10cSrcweir 	else if( eType & nsSelectionType::SEL_FRM)
222cdf0e10cSrcweir 		ppStr = &pOldFrmCat;
223cdf0e10cSrcweir 	else if( eType == nsSelectionType::SEL_TXT)
224cdf0e10cSrcweir 		ppStr = &pOldFrmCat;
225cdf0e10cSrcweir 	else if( eType & nsSelectionType::SEL_DRW)
226cdf0e10cSrcweir 		ppStr = &pOldDrwCat;
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	if( ppStr )
229cdf0e10cSrcweir 	{
230cdf0e10cSrcweir 		if( !*ppStr )
231cdf0e10cSrcweir 			*ppStr = new String( rName );
232cdf0e10cSrcweir 		else
233cdf0e10cSrcweir 			**ppStr = rName;
234cdf0e10cSrcweir 	}
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 
238