xref: /AOO41X/main/sw/source/core/unocore/unocrsrhelper.cxx (revision 69a743679e823ad8f875be547552acb607b8ada5)
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
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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 <svx/svxids.hrc>
28cdf0e10cSrcweir #include <map>
29cdf0e10cSrcweir #include <com/sun/star/text/XTextSection.hpp>
30cdf0e10cSrcweir #include <cmdid.h>
31cdf0e10cSrcweir #include <unocrsrhelper.hxx>
32cdf0e10cSrcweir #include <unofootnote.hxx>
33cdf0e10cSrcweir #include <unorefmark.hxx>
34cdf0e10cSrcweir #include <unostyle.hxx>
35cdf0e10cSrcweir #include <unoidx.hxx>
36cdf0e10cSrcweir #include <unofield.hxx>
37cdf0e10cSrcweir #include <unotbl.hxx>
38cdf0e10cSrcweir #include <unosett.hxx>
39cdf0e10cSrcweir #include <unoframe.hxx>
40cdf0e10cSrcweir #include <unocrsr.hxx>
41cdf0e10cSrcweir #include <doc.hxx>
42cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
43cdf0e10cSrcweir #include <IDocumentRedlineAccess.hxx>
44cdf0e10cSrcweir #include <fmtftn.hxx>
45cdf0e10cSrcweir #include <fmtpdsc.hxx>
46cdf0e10cSrcweir #include <charfmt.hxx>
47cdf0e10cSrcweir #include <pagedesc.hxx>
48cdf0e10cSrcweir #include <docstyle.hxx>
49cdf0e10cSrcweir #include <ndtxt.hxx>
50cdf0e10cSrcweir #include <txtrfmrk.hxx>
51cdf0e10cSrcweir #include <fmtfld.hxx>
52*69a74367SOliver-Rainer Wittmann #include <txtfld.hxx>
53cdf0e10cSrcweir #include <docsh.hxx>
54cdf0e10cSrcweir #include <section.hxx>
55cdf0e10cSrcweir #include <shellio.hxx>
56cdf0e10cSrcweir #include <edimp.hxx>
57cdf0e10cSrcweir #include <swundo.hxx>
58cdf0e10cSrcweir #include <cntfrm.hxx>
59cdf0e10cSrcweir #include <pagefrm.hxx>
60cdf0e10cSrcweir #include <svl/eitem.hxx>
61cdf0e10cSrcweir #include <tools/urlobj.hxx>
62cdf0e10cSrcweir #include <docary.hxx>
63cdf0e10cSrcweir #include <swtable.hxx>
64cdf0e10cSrcweir #include <tox.hxx>
65cdf0e10cSrcweir #include <doctxm.hxx>
66cdf0e10cSrcweir #include <fchrfmt.hxx>
67cdf0e10cSrcweir #include <editeng/flstitem.hxx>
68cdf0e10cSrcweir #include <vcl/metric.hxx>
69cdf0e10cSrcweir #include <svtools/ctrltool.hxx>
70cdf0e10cSrcweir #define _SVSTDARR_USHORTS
71cdf0e10cSrcweir #define _SVSTDARR_USHORTSSORT
72cdf0e10cSrcweir #include <svl/svstdarr.hxx>
73cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
74cdf0e10cSrcweir #include <sfx2/docfile.hxx>
75cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
76cdf0e10cSrcweir #include <svl/stritem.hxx>
77cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
78cdf0e10cSrcweir #include <SwStyleNameMapper.hxx>
79cdf0e10cSrcweir #include <redline.hxx>
80cdf0e10cSrcweir #include <numrule.hxx>
81cdf0e10cSrcweir #include <comphelper/storagehelper.hxx>
82cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
83cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
84cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
85cdf0e10cSrcweir #include <com/sun/star/embed/XStorage.hpp>
86cdf0e10cSrcweir // --> OD 2008-11-26 #158694#
87cdf0e10cSrcweir #include <SwNodeNum.hxx>
88cdf0e10cSrcweir // <--
89cdf0e10cSrcweir #include <fmtmeta.hxx>
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir using namespace ::com::sun::star;
93cdf0e10cSrcweir using namespace ::com::sun::star::uno;
94cdf0e10cSrcweir using namespace ::com::sun::star::beans;
95cdf0e10cSrcweir using namespace ::com::sun::star::text;
96cdf0e10cSrcweir using namespace ::com::sun::star::table;
97cdf0e10cSrcweir using namespace ::com::sun::star::container;
98cdf0e10cSrcweir using namespace ::com::sun::star::lang;
99cdf0e10cSrcweir using ::rtl::OUString;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir namespace SwUnoCursorHelper
103cdf0e10cSrcweir {
104cdf0e10cSrcweir 
105cdf0e10cSrcweir uno::Reference<text::XTextContent>
GetNestedTextContent(SwTxtNode & rTextNode,xub_StrLen const nIndex,bool const bParent)106cdf0e10cSrcweir GetNestedTextContent(SwTxtNode & rTextNode, xub_StrLen const nIndex,
107cdf0e10cSrcweir         bool const bParent)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     // these should be unambiguous because of the dummy character
110cdf0e10cSrcweir     SwTxtNode::GetTxtAttrMode const eMode( (bParent)
111cdf0e10cSrcweir         ? SwTxtNode::PARENT : SwTxtNode::EXPAND );
112cdf0e10cSrcweir     SwTxtAttr *const pMetaTxtAttr =
113cdf0e10cSrcweir         rTextNode.GetTxtAttrAt(nIndex, RES_TXTATR_META, eMode);
114cdf0e10cSrcweir     SwTxtAttr *const pMetaFieldTxtAttr =
115cdf0e10cSrcweir         rTextNode.GetTxtAttrAt(nIndex, RES_TXTATR_METAFIELD, eMode);
116cdf0e10cSrcweir     // which is innermost?
117cdf0e10cSrcweir     SwTxtAttr *const pTxtAttr = (pMetaTxtAttr)
118cdf0e10cSrcweir         ? ((pMetaFieldTxtAttr)
119cdf0e10cSrcweir             ? ((*pMetaFieldTxtAttr->GetStart() >
120cdf0e10cSrcweir                     *pMetaTxtAttr->GetStart())
121cdf0e10cSrcweir                 ? pMetaFieldTxtAttr : pMetaTxtAttr)
122cdf0e10cSrcweir             : pMetaTxtAttr)
123cdf0e10cSrcweir         : pMetaFieldTxtAttr;
124cdf0e10cSrcweir     uno::Reference<XTextContent> xRet;
125cdf0e10cSrcweir     if (pTxtAttr)
126cdf0e10cSrcweir     {
127cdf0e10cSrcweir         ::sw::Meta *const pMeta(
128cdf0e10cSrcweir             static_cast<SwFmtMeta &>(pTxtAttr->GetAttr()).GetMeta());
129cdf0e10cSrcweir         OSL_ASSERT(pMeta);
130cdf0e10cSrcweir         xRet.set(pMeta->MakeUnoObject(), uno::UNO_QUERY);
131cdf0e10cSrcweir     }
132cdf0e10cSrcweir     return xRet;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 
136cdf0e10cSrcweir /* -----------------16.09.98 12:27-------------------
137cdf0e10cSrcweir * 	Lesen spezieller Properties am Cursor
138cdf0e10cSrcweir  * --------------------------------------------------*/
getCrsrPropertyValue(const SfxItemPropertySimpleEntry & rEntry,SwPaM & rPam,Any * pAny,PropertyState & eState,const SwTxtNode * pNode)139*69a74367SOliver-Rainer Wittmann sal_Bool getCrsrPropertyValue(
140*69a74367SOliver-Rainer Wittmann     const SfxItemPropertySimpleEntry& rEntry,
141*69a74367SOliver-Rainer Wittmann     SwPaM& rPam,
142*69a74367SOliver-Rainer Wittmann     Any *pAny,
143*69a74367SOliver-Rainer Wittmann     PropertyState& eState,
144*69a74367SOliver-Rainer Wittmann     const SwTxtNode* pNode )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     PropertyState eNewState = PropertyState_DIRECT_VALUE;
147cdf0e10cSrcweir     //    PropertyState_DEFAULT_VALUE
148cdf0e10cSrcweir     //    PropertyState_AMBIGUOUS_VALUE
149cdf0e10cSrcweir     sal_Bool bDone = sal_True;
150cdf0e10cSrcweir     switch(rEntry.nWID)
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         case FN_UNO_PARA_CONT_PREV_SUBTREE:
153cdf0e10cSrcweir             if (pAny)
154cdf0e10cSrcweir             {
155cdf0e10cSrcweir                 const SwTxtNode * pTmpNode = pNode;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir                 if (!pTmpNode)
158cdf0e10cSrcweir                     pTmpNode = rPam.GetNode()->GetTxtNode();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir                 bool bRet = false;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir                 if ( pTmpNode &&
163cdf0e10cSrcweir                      pTmpNode->GetNum() &&
164cdf0e10cSrcweir                      pTmpNode->GetNum()->IsContinueingPreviousSubTree() )
165cdf0e10cSrcweir                 {
166cdf0e10cSrcweir                     bRet = true;
167cdf0e10cSrcweir                 }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir                 *pAny <<= bRet;
170cdf0e10cSrcweir             }
171cdf0e10cSrcweir         break;
172*69a74367SOliver-Rainer Wittmann 
173cdf0e10cSrcweir         case FN_UNO_PARA_NUM_STRING:
174cdf0e10cSrcweir             if (pAny)
175cdf0e10cSrcweir             {
176cdf0e10cSrcweir                 const SwTxtNode * pTmpNode = pNode;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir                 if (!pTmpNode)
179cdf0e10cSrcweir                     pTmpNode = rPam.GetNode()->GetTxtNode();
180cdf0e10cSrcweir 
181cdf0e10cSrcweir                 String sRet;
182cdf0e10cSrcweir                 if ( pTmpNode && pTmpNode->GetNum() )
183cdf0e10cSrcweir                 {
184cdf0e10cSrcweir                     sRet = pTmpNode->GetNumString();
185cdf0e10cSrcweir                 }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir                 *pAny <<= OUString(sRet);
188cdf0e10cSrcweir             }
189cdf0e10cSrcweir         break;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         case RES_PARATR_OUTLINELEVEL: //#outlinelevel added by zhaojianwei
192cdf0e10cSrcweir             if (pAny)
193cdf0e10cSrcweir             {
194cdf0e10cSrcweir                 const SwTxtNode * pTmpNode = pNode;
195cdf0e10cSrcweir 
196cdf0e10cSrcweir                 if (!pTmpNode)
197cdf0e10cSrcweir                     pTmpNode = rPam.GetNode()->GetTxtNode();
198cdf0e10cSrcweir 
199cdf0e10cSrcweir                 sal_Int16 nRet = -1;
200cdf0e10cSrcweir                 if ( pTmpNode )
201cdf0e10cSrcweir                     nRet = sal::static_int_cast< sal_Int16 >( pTmpNode->GetAttrOutlineLevel() );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir                 *pAny <<= nRet;
204cdf0e10cSrcweir             }
205cdf0e10cSrcweir         break; //<-end,zhaojianwei
206*69a74367SOliver-Rainer Wittmann 
207cdf0e10cSrcweir         case FN_UNO_PARA_CONDITIONAL_STYLE_NAME:
208cdf0e10cSrcweir         case FN_UNO_PARA_STYLE :
209cdf0e10cSrcweir             {
210cdf0e10cSrcweir             SwFmtColl* pFmt = 0;
211cdf0e10cSrcweir             if(pNode)
212cdf0e10cSrcweir                 pFmt = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID
213cdf0e10cSrcweir                             ? pNode->GetFmtColl() : &pNode->GetAnyFmtColl();
214cdf0e10cSrcweir             else
215cdf0e10cSrcweir             {
216cdf0e10cSrcweir                 pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(rPam,
217cdf0e10cSrcweir                         FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID);
218cdf0e10cSrcweir             }
219cdf0e10cSrcweir 			if(pFmt)
220cdf0e10cSrcweir 			{
221cdf0e10cSrcweir 				if( pAny )
222cdf0e10cSrcweir 				{
223cdf0e10cSrcweir 					String sVal;
224cdf0e10cSrcweir 					SwStyleNameMapper::FillProgName(pFmt->GetName(), sVal, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
225cdf0e10cSrcweir 					*pAny <<= OUString(sVal);
226cdf0e10cSrcweir 				}
227cdf0e10cSrcweir 			}
228cdf0e10cSrcweir 			else
229cdf0e10cSrcweir 				eNewState = PropertyState_AMBIGUOUS_VALUE;
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir 		break;
232cdf0e10cSrcweir 		case FN_UNO_PAGE_STYLE :
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			String sVal;
235cdf0e10cSrcweir 			GetCurPageStyle(rPam, sVal);
236cdf0e10cSrcweir 			if( pAny )
237cdf0e10cSrcweir 				*pAny <<= OUString(sVal);
238cdf0e10cSrcweir 			if(!sVal.Len())
239cdf0e10cSrcweir 				eNewState = PropertyState_AMBIGUOUS_VALUE;
240cdf0e10cSrcweir 		}
241cdf0e10cSrcweir 		break;
242cdf0e10cSrcweir 		case FN_UNO_NUM_START_VALUE  :
243cdf0e10cSrcweir 			if( pAny )
244cdf0e10cSrcweir 			{
245cdf0e10cSrcweir 				sal_Int16 nValue = IsNodeNumStart(rPam, eNewState);
246cdf0e10cSrcweir 				*pAny <<= nValue;
247cdf0e10cSrcweir 			}
248cdf0e10cSrcweir 		break;
249*69a74367SOliver-Rainer Wittmann 
250cdf0e10cSrcweir         case FN_UNO_NUM_LEVEL  :
251cdf0e10cSrcweir         case FN_UNO_IS_NUMBER  :
252cdf0e10cSrcweir         case FN_UNO_LIST_ID:
253cdf0e10cSrcweir         case FN_NUMBER_NEWSTART:
254cdf0e10cSrcweir             {
255cdf0e10cSrcweir                 // a multi selection is not considered
256cdf0e10cSrcweir                 const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode();
257cdf0e10cSrcweir                 if ( pTxtNd && pTxtNd->IsInList() )
258cdf0e10cSrcweir                 {
259cdf0e10cSrcweir                     if( pAny )
260cdf0e10cSrcweir                     {
261cdf0e10cSrcweir                         if(rEntry.nWID == FN_UNO_NUM_LEVEL)
262cdf0e10cSrcweir                             *pAny <<= (sal_Int16)(pTxtNd->GetActualListLevel());
263cdf0e10cSrcweir                         else if(rEntry.nWID == FN_UNO_IS_NUMBER)
264cdf0e10cSrcweir                         {
265cdf0e10cSrcweir                             sal_Bool bIsNumber = pTxtNd->IsCountedInList();
266cdf0e10cSrcweir                             pAny->setValue(&bIsNumber, ::getBooleanCppuType());
267cdf0e10cSrcweir                         }
268cdf0e10cSrcweir                         else if ( rEntry.nWID == FN_UNO_LIST_ID )
269cdf0e10cSrcweir                         {
270cdf0e10cSrcweir                             const String sListId = pTxtNd->GetListId();
271cdf0e10cSrcweir                             *pAny <<= OUString(sListId);
272cdf0e10cSrcweir                         }
273cdf0e10cSrcweir                         else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/
274cdf0e10cSrcweir                         {
275cdf0e10cSrcweir                             sal_Bool bIsRestart = pTxtNd->IsListRestart();
276cdf0e10cSrcweir                             pAny->setValue(&bIsRestart, ::getBooleanCppuType());
277cdf0e10cSrcweir                         }
278cdf0e10cSrcweir                     }
279cdf0e10cSrcweir                 }
280cdf0e10cSrcweir                 else
281cdf0e10cSrcweir                 {
282cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
283cdf0e10cSrcweir 
284cdf0e10cSrcweir                     if( pAny )
285cdf0e10cSrcweir                     {
286cdf0e10cSrcweir                         // #i30838# set default values for default properties
287cdf0e10cSrcweir                         if(rEntry.nWID == FN_UNO_NUM_LEVEL)
288cdf0e10cSrcweir                             *pAny <<= static_cast<sal_Int16>( 0 );
289cdf0e10cSrcweir                         else if(rEntry.nWID == FN_UNO_IS_NUMBER)
290cdf0e10cSrcweir                             *pAny <<= false;
291cdf0e10cSrcweir                         // --> OD 2008-07-14 #i91601#
292cdf0e10cSrcweir                         else if ( rEntry.nWID == FN_UNO_LIST_ID )
293cdf0e10cSrcweir                         {
294cdf0e10cSrcweir                             *pAny <<= OUString();
295cdf0e10cSrcweir                         }
296cdf0e10cSrcweir                         // <--
297cdf0e10cSrcweir                         else /*if(rEntry.nWID == UNO_NAME_PARA_IS_NUMBERING_RESTART)*/
298cdf0e10cSrcweir                             *pAny <<= false;
299cdf0e10cSrcweir                     }
300cdf0e10cSrcweir                 }
301cdf0e10cSrcweir                 //PROPERTY_MAYBEVOID!
302cdf0e10cSrcweir             }
303cdf0e10cSrcweir             break;
304*69a74367SOliver-Rainer Wittmann 
305cdf0e10cSrcweir         case FN_UNO_NUM_RULES  :
306cdf0e10cSrcweir             if( pAny )
307cdf0e10cSrcweir                 getNumberingProperty(rPam, eNewState, pAny);
308cdf0e10cSrcweir             else
309cdf0e10cSrcweir             {
310cdf0e10cSrcweir                 if( !rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() ) )
311cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
312cdf0e10cSrcweir             }
313cdf0e10cSrcweir             break;
314*69a74367SOliver-Rainer Wittmann 
315cdf0e10cSrcweir         case FN_UNO_DOCUMENT_INDEX_MARK:
316cdf0e10cSrcweir             {
317cdf0e10cSrcweir                 ::std::vector<SwTxtAttr *> const marks(
318cdf0e10cSrcweir                     rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
319cdf0e10cSrcweir                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK));
320cdf0e10cSrcweir                 if (marks.size())
321cdf0e10cSrcweir                 {
322cdf0e10cSrcweir                     if( pAny )
323cdf0e10cSrcweir                     {   // hmm... can only return 1 here
324cdf0e10cSrcweir                         SwTOXMark & rMark =
325cdf0e10cSrcweir                             static_cast<SwTOXMark &>((*marks.begin())->GetAttr());
326cdf0e10cSrcweir                         const uno::Reference< text::XDocumentIndexMark > xRef =
327cdf0e10cSrcweir                             SwXDocumentIndexMark::CreateXDocumentIndexMark(
328cdf0e10cSrcweir                             *rPam.GetDoc(),
329cdf0e10cSrcweir                             *const_cast<SwTOXType*>(rMark.GetTOXType()), rMark);
330cdf0e10cSrcweir                         (*pAny) <<= xRef;
331cdf0e10cSrcweir                     }
332cdf0e10cSrcweir                 }
333cdf0e10cSrcweir                 else
334cdf0e10cSrcweir                     //auch hier - nicht zu unterscheiden
335cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
336cdf0e10cSrcweir             }
337cdf0e10cSrcweir             break;
338*69a74367SOliver-Rainer Wittmann 
339cdf0e10cSrcweir         case FN_UNO_DOCUMENT_INDEX:
340cdf0e10cSrcweir             {
341cdf0e10cSrcweir                 const SwTOXBase* pBase = rPam.GetDoc()->GetCurTOX(
342cdf0e10cSrcweir                     *rPam.Start() );
343cdf0e10cSrcweir                 if( pBase )
344cdf0e10cSrcweir                 {
345cdf0e10cSrcweir                     if( pAny )
346cdf0e10cSrcweir                     {
347cdf0e10cSrcweir                         const uno::Reference< text::XDocumentIndex > xRef =
348cdf0e10cSrcweir                             SwXDocumentIndex::CreateXDocumentIndex(*rPam.GetDoc(),
349cdf0e10cSrcweir                             *static_cast<SwTOXBaseSection const*>(pBase));
350cdf0e10cSrcweir                         (*pAny) <<= xRef;
351cdf0e10cSrcweir                     }
352cdf0e10cSrcweir                 }
353cdf0e10cSrcweir                 else
354cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
355cdf0e10cSrcweir             }
356cdf0e10cSrcweir             break;
357*69a74367SOliver-Rainer Wittmann 
358cdf0e10cSrcweir         case FN_UNO_TEXT_FIELD:
359cdf0e10cSrcweir             {
360cdf0e10cSrcweir                 const SwPosition *pPos = rPam.Start();
361cdf0e10cSrcweir                 const SwTxtNode *pTxtNd =
362cdf0e10cSrcweir                     rPam.GetDoc()->GetNodes()[pPos->nNode.GetIndex()]->GetTxtNode();
363*69a74367SOliver-Rainer Wittmann                 const SwTxtAttr* pTxtAttr = (pTxtNd)
364*69a74367SOliver-Rainer Wittmann                     ? pTxtNd->GetFldTxtAttrAt( pPos->nContent.GetIndex(), true )
365cdf0e10cSrcweir                     : 0;
366*69a74367SOliver-Rainer Wittmann                 if ( pTxtAttr != NULL )
367cdf0e10cSrcweir                 {
368cdf0e10cSrcweir                     if( pAny )
369cdf0e10cSrcweir                     {
370c0286415SOliver-Rainer Wittmann                         SwXTextField* pField =
371c0286415SOliver-Rainer Wittmann                             SwXTextField::CreateSwXTextField( *rPam.GetDoc(),pTxtAttr->GetFmtFld() );
372cdf0e10cSrcweir                         *pAny <<= uno::Reference< XTextField >( pField );
373cdf0e10cSrcweir                     }
374cdf0e10cSrcweir                 }
375cdf0e10cSrcweir                 else
376cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
377cdf0e10cSrcweir             }
378cdf0e10cSrcweir             break;
379*69a74367SOliver-Rainer Wittmann 
380cdf0e10cSrcweir         case FN_UNO_TEXT_TABLE:
381cdf0e10cSrcweir         case FN_UNO_CELL:
382cdf0e10cSrcweir             {
383cdf0e10cSrcweir                 SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode();
384cdf0e10cSrcweir                 SwStartNodeType eType = pSttNode->GetStartNodeType();
385cdf0e10cSrcweir                 if(SwTableBoxStartNode == eType)
386cdf0e10cSrcweir                 {
387cdf0e10cSrcweir                     if( pAny )
388cdf0e10cSrcweir                     {
389cdf0e10cSrcweir                         const SwTableNode* pTblNode = pSttNode->FindTableNode();
390cdf0e10cSrcweir                         SwFrmFmt* pTableFmt = (SwFrmFmt*)pTblNode->GetTable().GetFrmFmt();
391cdf0e10cSrcweir                         //SwTable& rTable = ((SwTableNode*)pSttNode)->GetTable();
392cdf0e10cSrcweir                         if(FN_UNO_TEXT_TABLE == rEntry.nWID)
393cdf0e10cSrcweir                         {
394cdf0e10cSrcweir                             uno::Reference< XTextTable >  xTable = SwXTextTables::GetObject(*pTableFmt);
395cdf0e10cSrcweir                             pAny->setValue(&xTable, ::getCppuType((uno::Reference<XTextTable>*)0));
396cdf0e10cSrcweir                         }
397cdf0e10cSrcweir                         else
398cdf0e10cSrcweir                         {
399cdf0e10cSrcweir                             SwTableBox* pBox = pSttNode->GetTblBox();
400cdf0e10cSrcweir                             uno::Reference< XCell >  xCell = SwXCell::CreateXCell(pTableFmt, pBox);
401cdf0e10cSrcweir                             pAny->setValue(&xCell, ::getCppuType((uno::Reference<XCell>*)0));
402cdf0e10cSrcweir                         }
403cdf0e10cSrcweir                     }
404cdf0e10cSrcweir                 }
405cdf0e10cSrcweir                 else
406cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
407cdf0e10cSrcweir             }
408cdf0e10cSrcweir             break;
409*69a74367SOliver-Rainer Wittmann 
410cdf0e10cSrcweir         case FN_UNO_TEXT_FRAME:
411cdf0e10cSrcweir             {
412cdf0e10cSrcweir                 SwStartNode* pSttNode = rPam.GetNode()->StartOfSectionNode();
413cdf0e10cSrcweir                 SwStartNodeType eType = pSttNode->GetStartNodeType();
414cdf0e10cSrcweir 
415cdf0e10cSrcweir                 SwFrmFmt* pFmt;
416cdf0e10cSrcweir                 if(eType == SwFlyStartNode && 0 != (pFmt = pSttNode->GetFlyFmt()))
417cdf0e10cSrcweir                 {
418cdf0e10cSrcweir                     if( pAny )
419cdf0e10cSrcweir                     {
420cdf0e10cSrcweir                         uno::Reference< XTextFrame >  xFrm = (SwXTextFrame*) SwXFrames::GetObject(*pFmt, FLYCNTTYPE_FRM);
421cdf0e10cSrcweir                         pAny->setValue(&xFrm, ::getCppuType((uno::Reference<XTextFrame>*)0));
422cdf0e10cSrcweir                     }
423cdf0e10cSrcweir                 }
424cdf0e10cSrcweir                 else
425cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir             break;
428*69a74367SOliver-Rainer Wittmann 
429cdf0e10cSrcweir         case FN_UNO_TEXT_SECTION:
430cdf0e10cSrcweir             {
431cdf0e10cSrcweir                 SwSection* pSect = rPam.GetDoc()->GetCurrSection(*rPam.GetPoint());
432cdf0e10cSrcweir                 if(pSect)
433cdf0e10cSrcweir                 {
434cdf0e10cSrcweir                     if( pAny )
435cdf0e10cSrcweir                     {
436cdf0e10cSrcweir                         uno::Reference< XTextSection >  xSect = SwXTextSections::GetObject( *pSect->GetFmt() );
437cdf0e10cSrcweir                         pAny->setValue(&xSect, ::getCppuType((uno::Reference<XTextSection>*)0) );
438cdf0e10cSrcweir                     }
439cdf0e10cSrcweir                 }
440cdf0e10cSrcweir                 else
441cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
442cdf0e10cSrcweir             }
443cdf0e10cSrcweir             break;
444*69a74367SOliver-Rainer Wittmann 
445cdf0e10cSrcweir         case FN_UNO_ENDNOTE:
446cdf0e10cSrcweir         case FN_UNO_FOOTNOTE:
447cdf0e10cSrcweir             {
448cdf0e10cSrcweir                 SwTxtAttr *const pTxtAttr =
449cdf0e10cSrcweir                     rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
450cdf0e10cSrcweir                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
451cdf0e10cSrcweir                 if(pTxtAttr)
452cdf0e10cSrcweir                 {
453cdf0e10cSrcweir                     const SwFmtFtn& rFtn = pTxtAttr->GetFtn();
454cdf0e10cSrcweir                     if(rFtn.IsEndNote() == (FN_UNO_ENDNOTE == rEntry.nWID))
455cdf0e10cSrcweir                     {
456cdf0e10cSrcweir                         if( pAny )
457cdf0e10cSrcweir                         {
458cdf0e10cSrcweir                             const uno::Reference< text::XFootnote > xFootnote =
459cdf0e10cSrcweir                                 SwXFootnote::CreateXFootnote(*rPam.GetDoc(), rFtn);
460cdf0e10cSrcweir                             *pAny <<= xFootnote;
461cdf0e10cSrcweir                         }
462cdf0e10cSrcweir                     }
463cdf0e10cSrcweir                     else
464cdf0e10cSrcweir                         eNewState = PropertyState_DEFAULT_VALUE;
465cdf0e10cSrcweir                 }
466cdf0e10cSrcweir                 else
467cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
468cdf0e10cSrcweir             }
469cdf0e10cSrcweir             break;
470*69a74367SOliver-Rainer Wittmann 
471cdf0e10cSrcweir         case FN_UNO_REFERENCE_MARK:
472cdf0e10cSrcweir             {
473cdf0e10cSrcweir                 ::std::vector<SwTxtAttr *> const marks(
474cdf0e10cSrcweir                     rPam.GetNode()->GetTxtNode()->GetTxtAttrsAt(
475cdf0e10cSrcweir                     rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK));
476cdf0e10cSrcweir                 if (marks.size())
477cdf0e10cSrcweir                 {
478cdf0e10cSrcweir                     if( pAny )
479cdf0e10cSrcweir                     {   // hmm... can only return 1 here
480cdf0e10cSrcweir                         const SwFmtRefMark& rRef = (*marks.begin())->GetRefMark();
481cdf0e10cSrcweir                         uno::Reference< XTextContent >  xRef = SwXReferenceMarks::GetObject( rPam.GetDoc(), &rRef );
482cdf0e10cSrcweir                         pAny->setValue(&xRef, ::getCppuType((uno::Reference<XTextContent>*)0));
483cdf0e10cSrcweir                     }
484cdf0e10cSrcweir                 }
485cdf0e10cSrcweir                 else
486cdf0e10cSrcweir                     eNewState = PropertyState_DEFAULT_VALUE;
487cdf0e10cSrcweir             }
488cdf0e10cSrcweir             break;
489*69a74367SOliver-Rainer Wittmann 
490cdf0e10cSrcweir         case FN_UNO_NESTED_TEXT_CONTENT:
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir             uno::Reference<XTextContent> const xRet(
493cdf0e10cSrcweir                 GetNestedTextContent(*rPam.GetNode()->GetTxtNode(),
494cdf0e10cSrcweir                     rPam.GetPoint()->nContent.GetIndex(), false));
495cdf0e10cSrcweir             if (xRet.is())
496cdf0e10cSrcweir             {
497cdf0e10cSrcweir                 if (pAny)
498cdf0e10cSrcweir                 {
499cdf0e10cSrcweir                     (*pAny) <<= xRet;
500cdf0e10cSrcweir                 }
501cdf0e10cSrcweir             }
502cdf0e10cSrcweir             else
503cdf0e10cSrcweir             {
504cdf0e10cSrcweir                 eNewState = PropertyState_DEFAULT_VALUE;
505cdf0e10cSrcweir             }
506cdf0e10cSrcweir         }
507cdf0e10cSrcweir         break;
508*69a74367SOliver-Rainer Wittmann 
509cdf0e10cSrcweir         case FN_UNO_CHARFMT_SEQUENCE:
510cdf0e10cSrcweir         {
511cdf0e10cSrcweir 
512cdf0e10cSrcweir             SwTxtNode* pTxtNode;
513cdf0e10cSrcweir             if((pTxtNode = (SwTxtNode*)rPam.GetNode( sal_True )) == rPam.GetNode(sal_False) &&
514cdf0e10cSrcweir                     pTxtNode->GetpSwpHints())
515cdf0e10cSrcweir             {
516cdf0e10cSrcweir                 sal_uInt16 nPaMStart = rPam.GetPoint()->nContent.GetIndex();
517cdf0e10cSrcweir                 sal_uInt16 nPaMEnd = rPam.GetMark() ? rPam.GetMark()->nContent.GetIndex() : nPaMStart;
518cdf0e10cSrcweir                 if(nPaMStart > nPaMEnd)
519cdf0e10cSrcweir                 {
520cdf0e10cSrcweir                     sal_uInt16 nTmp = nPaMStart;
521cdf0e10cSrcweir                     nPaMStart = nPaMEnd;
522cdf0e10cSrcweir                     nPaMEnd = nTmp;
523cdf0e10cSrcweir                 }
524cdf0e10cSrcweir                 Sequence< ::rtl::OUString> aCharStyles;
525cdf0e10cSrcweir                 SwpHints* pHints = pTxtNode->GetpSwpHints();
526cdf0e10cSrcweir                 for(sal_uInt16 nAttr = 0; nAttr < pHints->GetStartCount(); nAttr++ )
527cdf0e10cSrcweir                 {
528cdf0e10cSrcweir                     SwTxtAttr* pAttr = pHints->GetStart( nAttr );
529cdf0e10cSrcweir                     if(pAttr->Which() != RES_TXTATR_CHARFMT)
530cdf0e10cSrcweir                         continue;
531cdf0e10cSrcweir                     sal_uInt16 nAttrStart = *pAttr->GetStart();
532cdf0e10cSrcweir                     sal_uInt16 nAttrEnd = *pAttr->GetEnd();
533cdf0e10cSrcweir                     //check if the attribute touches the selection
534cdf0e10cSrcweir                     if( ( nAttrEnd > nPaMStart && nAttrStart < nPaMEnd ) ||
535cdf0e10cSrcweir                         ( !nAttrStart && !nAttrEnd && !nPaMStart && !nPaMEnd ) )
536cdf0e10cSrcweir                     {
537cdf0e10cSrcweir                         //check for overlapping
538cdf0e10cSrcweir                         if(nAttrStart > nPaMStart ||
539cdf0e10cSrcweir                                     nAttrEnd < nPaMEnd)
540cdf0e10cSrcweir                         {
541cdf0e10cSrcweir                             aCharStyles.realloc(0);
542cdf0e10cSrcweir                             eNewState = PropertyState_AMBIGUOUS_VALUE;
543cdf0e10cSrcweir                             break;
544cdf0e10cSrcweir                         }
545cdf0e10cSrcweir                         else
546cdf0e10cSrcweir                         {
547cdf0e10cSrcweir                             //now the attribute should start before or at the selection
548cdf0e10cSrcweir                             //and it should end at the end of the selection or behind
549cdf0e10cSrcweir                             DBG_ASSERT(nAttrStart <= nPaMStart && nAttrEnd >=nPaMEnd,
550cdf0e10cSrcweir                                     "attribute overlaps or is outside");
551cdf0e10cSrcweir                             //now the name of the style has to be added to the sequence
552cdf0e10cSrcweir                             aCharStyles.realloc(aCharStyles.getLength() + 1);
553cdf0e10cSrcweir                             DBG_ASSERT(pAttr->GetCharFmt().GetCharFmt(), "no character format set");
554cdf0e10cSrcweir                             aCharStyles.getArray()[aCharStyles.getLength() - 1] =
555cdf0e10cSrcweir                                         SwStyleNameMapper::GetProgName(
556cdf0e10cSrcweir                                             pAttr->GetCharFmt().GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT);
557cdf0e10cSrcweir                         }
558cdf0e10cSrcweir                     }
559cdf0e10cSrcweir 
560cdf0e10cSrcweir                 }
561cdf0e10cSrcweir                 eNewState =
562cdf0e10cSrcweir                     aCharStyles.getLength() ?
563cdf0e10cSrcweir                         PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;;
564cdf0e10cSrcweir                 if(pAny)
565cdf0e10cSrcweir                     (*pAny) <<= aCharStyles;
566cdf0e10cSrcweir             }
567cdf0e10cSrcweir             else
568cdf0e10cSrcweir                 eNewState = PropertyState_DEFAULT_VALUE;
569cdf0e10cSrcweir         }
570cdf0e10cSrcweir         break;
571*69a74367SOliver-Rainer Wittmann 
572cdf0e10cSrcweir         case RES_TXTATR_CHARFMT:
573cdf0e10cSrcweir             // kein break hier!
574cdf0e10cSrcweir         default: bDone = sal_False;
575cdf0e10cSrcweir     }
576cdf0e10cSrcweir     if( bDone )
577cdf0e10cSrcweir         eState = eNewState;
578cdf0e10cSrcweir     return bDone;
579cdf0e10cSrcweir };
580cdf0e10cSrcweir /* -----------------30.06.98 10:30-------------------
581cdf0e10cSrcweir  *
582cdf0e10cSrcweir  * --------------------------------------------------*/
IsNodeNumStart(SwPaM & rPam,PropertyState & eState)583cdf0e10cSrcweir sal_Int16 IsNodeNumStart(SwPaM& rPam, PropertyState& eState)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	const SwTxtNode* pTxtNd = rPam.GetNode()->GetTxtNode();
586cdf0e10cSrcweir     // --> OD 2008-02-28 #refactorlists#
587cdf0e10cSrcweir     // correction: check, if restart value is set at the text node and use
588cdf0e10cSrcweir     // new method <SwTxtNode::GetAttrListRestartValue()> to retrieve the value
589cdf0e10cSrcweir     if ( pTxtNd && pTxtNd->GetNumRule() && pTxtNd->IsListRestart() &&
590cdf0e10cSrcweir          pTxtNd->HasAttrListRestartValue() )
591cdf0e10cSrcweir 	{
592cdf0e10cSrcweir 		eState = PropertyState_DIRECT_VALUE;
593cdf0e10cSrcweir         sal_Int16 nTmp = sal::static_int_cast< sal_Int16 >(pTxtNd->GetAttrListRestartValue());
594cdf0e10cSrcweir         return nTmp;
595cdf0e10cSrcweir 	}
596cdf0e10cSrcweir     // <--
597cdf0e10cSrcweir 	eState = PropertyState_DEFAULT_VALUE;
598cdf0e10cSrcweir 	return -1;
599cdf0e10cSrcweir }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir /* -----------------25.05.98 11:41-------------------
602cdf0e10cSrcweir  *
603cdf0e10cSrcweir  * --------------------------------------------------*/
setNumberingProperty(const Any & rValue,SwPaM & rPam)604cdf0e10cSrcweir void setNumberingProperty(const Any& rValue, SwPaM& rPam)
605cdf0e10cSrcweir {
606cdf0e10cSrcweir     uno::Reference<XIndexReplace> xIndexReplace;
607cdf0e10cSrcweir     if(rValue >>= xIndexReplace)
608cdf0e10cSrcweir 	{
609cdf0e10cSrcweir 		SwXNumberingRules* pSwNum = 0;
610cdf0e10cSrcweir 
611cdf0e10cSrcweir         uno::Reference<XUnoTunnel> xNumTunnel(xIndexReplace, UNO_QUERY);
612cdf0e10cSrcweir 		if(xNumTunnel.is())
613cdf0e10cSrcweir 		{
614cdf0e10cSrcweir 			pSwNum = reinterpret_cast< SwXNumberingRules * >(
615cdf0e10cSrcweir 				sal::static_int_cast< sal_IntPtr >( xNumTunnel->getSomething( SwXNumberingRules::getUnoTunnelId() )));
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 		if(pSwNum)
619cdf0e10cSrcweir 		{
620cdf0e10cSrcweir             SwDoc* pDoc = rPam.GetDoc();
621cdf0e10cSrcweir 			if(pSwNum->GetNumRule())
622cdf0e10cSrcweir 			{
623cdf0e10cSrcweir 				SwNumRule aRule(*pSwNum->GetNumRule());
624cdf0e10cSrcweir 				const String* pNewCharStyles =  pSwNum->GetNewCharStyleNames();
625cdf0e10cSrcweir 				const String* pBulletFontNames = pSwNum->GetBulletFontNames();
626cdf0e10cSrcweir 				for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
627cdf0e10cSrcweir 				{
628cdf0e10cSrcweir 					SwNumFmt aFmt(aRule.Get( i ));
629cdf0e10cSrcweir 					if( pNewCharStyles[i].Len() &&
630cdf0e10cSrcweir 						pNewCharStyles[i] != SwXNumberingRules::GetInvalidStyle() &&
631cdf0e10cSrcweir 						(!aFmt.GetCharFmt() || pNewCharStyles[i] != aFmt.GetCharFmt()->GetName()))
632cdf0e10cSrcweir 					{
633cdf0e10cSrcweir 						if(!pNewCharStyles[i].Len())
634cdf0e10cSrcweir 							aFmt.SetCharFmt(0);
635cdf0e10cSrcweir 						else
636cdf0e10cSrcweir 						{
637cdf0e10cSrcweir 
638cdf0e10cSrcweir                             // CharStyle besorgen und an der Rule setzen
639cdf0e10cSrcweir 							sal_uInt16 nChCount = pDoc->GetCharFmts()->Count();
640cdf0e10cSrcweir 							SwCharFmt* pCharFmt = 0;
641cdf0e10cSrcweir                             for(sal_uInt16 nCharFmt = 0; nCharFmt < nChCount; nCharFmt++)
642cdf0e10cSrcweir 							{
643cdf0e10cSrcweir                                 SwCharFmt& rChFmt = *((*(pDoc->GetCharFmts()))[nCharFmt]);;
644cdf0e10cSrcweir 								if(rChFmt.GetName() == pNewCharStyles[i])
645cdf0e10cSrcweir 								{
646cdf0e10cSrcweir 									pCharFmt = &rChFmt;
647cdf0e10cSrcweir 									break;
648cdf0e10cSrcweir 								}
649cdf0e10cSrcweir 							}
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 							if(!pCharFmt)
652cdf0e10cSrcweir 							{
653cdf0e10cSrcweir 								SfxStyleSheetBasePool* pPool = pDoc->GetDocShell()->GetStyleSheetPool();
654cdf0e10cSrcweir 								SfxStyleSheetBase* pBase;
655cdf0e10cSrcweir 								pBase = pPool->Find(pNewCharStyles[i], SFX_STYLE_FAMILY_CHAR);
656cdf0e10cSrcweir 							// soll das wirklich erzeugt werden?
657cdf0e10cSrcweir 								if(!pBase)
658cdf0e10cSrcweir 									pBase = &pPool->Make(pNewCharStyles[i], SFX_STYLE_FAMILY_PAGE);
659cdf0e10cSrcweir 								pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
660cdf0e10cSrcweir 							}
661cdf0e10cSrcweir 							if(pCharFmt)
662cdf0e10cSrcweir 								aFmt.SetCharFmt(pCharFmt);
663cdf0e10cSrcweir 						}
664cdf0e10cSrcweir 					}
665cdf0e10cSrcweir 					//jetzt nochmal fuer Fonts
666cdf0e10cSrcweir 					if(
667cdf0e10cSrcweir 					   pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() &&
668cdf0e10cSrcweir 					   (
669cdf0e10cSrcweir 					    (pBulletFontNames[i].Len() && !aFmt.GetBulletFont()) ||
670cdf0e10cSrcweir 					    (pBulletFontNames[i].Len() &&
671cdf0e10cSrcweir 							aFmt.GetBulletFont()->GetName() != pBulletFontNames[i])
672cdf0e10cSrcweir 					   )
673cdf0e10cSrcweir 					  )
674cdf0e10cSrcweir 					{
675cdf0e10cSrcweir 						const SvxFontListItem* pFontListItem =
676cdf0e10cSrcweir 								(const SvxFontListItem* )pDoc->GetDocShell()
677cdf0e10cSrcweir 													->GetItem( SID_ATTR_CHAR_FONTLIST );
678cdf0e10cSrcweir 						const FontList*	 pList = pFontListItem->GetFontList();
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 						FontInfo aInfo = pList->Get(
681cdf0e10cSrcweir 							pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
682cdf0e10cSrcweir 						Font aFont(aInfo);
683cdf0e10cSrcweir 						aFmt.SetBulletFont(&aFont);
684cdf0e10cSrcweir 					}
685cdf0e10cSrcweir 					aRule.Set( i, aFmt );
686cdf0e10cSrcweir 				}
687cdf0e10cSrcweir                 UnoActionContext aAction(pDoc);
688cdf0e10cSrcweir 
689cdf0e10cSrcweir                 if( rPam.GetNext() != &rPam )           // Mehrfachselektion ?
690cdf0e10cSrcweir 				{
691cdf0e10cSrcweir                     pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
692cdf0e10cSrcweir 					SwPamRanges aRangeArr( rPam );
693cdf0e10cSrcweir 					SwPaM aPam( *rPam.GetPoint() );
694cdf0e10cSrcweir 					for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
695cdf0e10cSrcweir                     {
696cdf0e10cSrcweir                         // --> OD 2008-03-17 #refactorlists#
697cdf0e10cSrcweir                         // no start of a new list
698cdf0e10cSrcweir                         pDoc->SetNumRule( aRangeArr.SetPam( n, aPam ), aRule, false );
699cdf0e10cSrcweir                         // <--
700cdf0e10cSrcweir                     }
701cdf0e10cSrcweir                     pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
702cdf0e10cSrcweir                 }
703cdf0e10cSrcweir                 else
704cdf0e10cSrcweir                 {
705cdf0e10cSrcweir                     // --> OD 2008-03-17 #refactorlists#
706cdf0e10cSrcweir                     // no start of a new list
707cdf0e10cSrcweir                     pDoc->SetNumRule( rPam, aRule, false );
708cdf0e10cSrcweir                     // <--
709cdf0e10cSrcweir                 }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 			}
713cdf0e10cSrcweir 			else if(pSwNum->GetCreatedNumRuleName().Len())
714cdf0e10cSrcweir 			{
715cdf0e10cSrcweir 				UnoActionContext aAction(pDoc);
716cdf0e10cSrcweir 				SwNumRule* pRule = pDoc->FindNumRulePtr( pSwNum->GetCreatedNumRuleName() );
717cdf0e10cSrcweir 				if(!pRule)
718cdf0e10cSrcweir 					throw RuntimeException();
719cdf0e10cSrcweir                 // --> OD 2008-03-17 #refactorlists#
720cdf0e10cSrcweir                 // no start of a new list
721cdf0e10cSrcweir                 pDoc->SetNumRule( rPam, *pRule, false );
722cdf0e10cSrcweir                 // <--
723cdf0e10cSrcweir 			}
724cdf0e10cSrcweir             // --> OD 2009-08-18 #i103817#
725cdf0e10cSrcweir             // outline numbering
726cdf0e10cSrcweir             else
727cdf0e10cSrcweir             {
728cdf0e10cSrcweir                 UnoActionContext aAction(pDoc);
729cdf0e10cSrcweir                 SwNumRule* pRule = pDoc->GetOutlineNumRule();
730cdf0e10cSrcweir                 if(!pRule)
731cdf0e10cSrcweir                     throw RuntimeException();
732cdf0e10cSrcweir                 pDoc->SetNumRule( rPam, *pRule, false );
733cdf0e10cSrcweir             }
734cdf0e10cSrcweir             // <--
735cdf0e10cSrcweir 		}
736cdf0e10cSrcweir 	}
737cdf0e10cSrcweir     else if(rValue.getValueType() == ::getVoidCppuType())
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         rPam.GetDoc()->DelNumRules(rPam);
740cdf0e10cSrcweir     }
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir 
744cdf0e10cSrcweir /* -----------------25.05.98 11:40-------------------
745cdf0e10cSrcweir  *
746cdf0e10cSrcweir  * --------------------------------------------------*/
getNumberingProperty(SwPaM & rPam,PropertyState & eState,Any * pAny)747cdf0e10cSrcweir void  getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir 	const SwNumRule* pNumRule = rPam.GetDoc()->GetCurrNumRule( *rPam.GetPoint() );
750cdf0e10cSrcweir 	if(pNumRule)
751cdf0e10cSrcweir 	{
752cdf0e10cSrcweir 		uno::Reference< XIndexReplace >  xNum = new SwXNumberingRules(*pNumRule);
753cdf0e10cSrcweir 		if ( pAny )
754cdf0e10cSrcweir 			pAny->setValue(&xNum, ::getCppuType((const uno::Reference<XIndexReplace>*)0));
755cdf0e10cSrcweir 		eState = PropertyState_DIRECT_VALUE;
756cdf0e10cSrcweir 	}
757cdf0e10cSrcweir 	else
758cdf0e10cSrcweir 		eState = PropertyState_DEFAULT_VALUE;
759cdf0e10cSrcweir }
760cdf0e10cSrcweir /* -----------------04.07.98 15:15-------------------
761cdf0e10cSrcweir  *
762cdf0e10cSrcweir  * --------------------------------------------------*/
GetCurPageStyle(SwPaM & rPaM,String & rString)763cdf0e10cSrcweir void GetCurPageStyle(SwPaM& rPaM, String &rString)
764cdf0e10cSrcweir {
765cdf0e10cSrcweir 	const SwPageFrm* pPage = rPaM.GetCntntNode()->getLayoutFrm(rPaM.GetDoc()->GetCurrentLayout())->FindPageFrm();
766cdf0e10cSrcweir 	if(pPage)
767cdf0e10cSrcweir 		SwStyleNameMapper::FillProgName( pPage->GetPageDesc()->GetName(), rString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
768cdf0e10cSrcweir }
769cdf0e10cSrcweir /* -----------------30.03.99 10:52-------------------
770cdf0e10cSrcweir  * spezielle Properties am Cursor zuruecksetzen
771cdf0e10cSrcweir  * --------------------------------------------------*/
resetCrsrPropertyValue(const SfxItemPropertySimpleEntry & rEntry,SwPaM & rPam)772cdf0e10cSrcweir void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPam)
773cdf0e10cSrcweir {
774cdf0e10cSrcweir 	SwDoc* pDoc = rPam.GetDoc();
775cdf0e10cSrcweir     switch(rEntry.nWID)
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		case FN_UNO_PARA_STYLE :
778cdf0e10cSrcweir //			lcl_SetTxtFmtColl(aValue, pUnoCrsr);
779cdf0e10cSrcweir 		break;
780cdf0e10cSrcweir 		case FN_UNO_PAGE_STYLE :
781cdf0e10cSrcweir 		break;
782cdf0e10cSrcweir 		case FN_UNO_NUM_START_VALUE  :
783cdf0e10cSrcweir 		{
784cdf0e10cSrcweir 			UnoActionContext aAction(pDoc);
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 			if( rPam.GetNext() != &rPam )			// Mehrfachselektion ?
787cdf0e10cSrcweir             {
788cdf0e10cSrcweir                 pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
789cdf0e10cSrcweir 				SwPamRanges aRangeArr( rPam );
790cdf0e10cSrcweir 				SwPaM aPam( *rPam.GetPoint() );
791cdf0e10cSrcweir 				for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
792cdf0e10cSrcweir 					pDoc->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), 1 );
793cdf0e10cSrcweir                 pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
794cdf0e10cSrcweir             }
795cdf0e10cSrcweir             else
796cdf0e10cSrcweir 				pDoc->SetNodeNumStart( *rPam.GetPoint(), 0 );
797cdf0e10cSrcweir 		}
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 		break;
800cdf0e10cSrcweir 		case FN_UNO_NUM_LEVEL  :
801cdf0e10cSrcweir 		break;
802cdf0e10cSrcweir 		case FN_UNO_NUM_RULES:
803cdf0e10cSrcweir //    		lcl_setNumberingProperty(aValue, pUnoCrsr);
804cdf0e10cSrcweir 		break;
805cdf0e10cSrcweir         case FN_UNO_CHARFMT_SEQUENCE:
806cdf0e10cSrcweir         {
807cdf0e10cSrcweir             SvUShortsSort aWhichIds;
808cdf0e10cSrcweir             aWhichIds.Insert(RES_TXTATR_CHARFMT);
809cdf0e10cSrcweir             pDoc->ResetAttrs(rPam, sal_True, &aWhichIds);
810cdf0e10cSrcweir         }
811cdf0e10cSrcweir         break;
812cdf0e10cSrcweir     }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir /* -----------------21.07.98 11:36-------------------
815cdf0e10cSrcweir  *
816cdf0e10cSrcweir  * --------------------------------------------------*/
InsertFile(SwUnoCrsr * pUnoCrsr,const String & rURL,const uno::Sequence<beans::PropertyValue> & rOptions)817cdf0e10cSrcweir void InsertFile(SwUnoCrsr* pUnoCrsr,
818cdf0e10cSrcweir     const String& rURL,
819cdf0e10cSrcweir     const uno::Sequence< beans::PropertyValue >& rOptions
820cdf0e10cSrcweir     ) throw( lang::IllegalArgumentException, io::IOException, uno::RuntimeException )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	SfxMedium* pMed = 0;
823cdf0e10cSrcweir 	SwDoc* pDoc = pUnoCrsr->GetDoc();
824cdf0e10cSrcweir 	SwDocShell* pDocSh = pDoc->GetDocShell();
825cdf0e10cSrcweir     comphelper::MediaDescriptor aMediaDescriptor( rOptions );
826cdf0e10cSrcweir     ::rtl::OUString sFileName = rURL;
827cdf0e10cSrcweir     ::rtl::OUString sFilterName, sFilterOptions, sPassword, sBaseURL;
828cdf0e10cSrcweir     uno::Reference < io::XStream > xStream;
829cdf0e10cSrcweir     uno::Reference < io::XInputStream > xInputStream;
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     if( !sFileName.getLength() )
832cdf0e10cSrcweir         aMediaDescriptor[comphelper::MediaDescriptor::PROP_URL()] >>= sFileName;
833cdf0e10cSrcweir     if( !sFileName.getLength() )
834cdf0e10cSrcweir         aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILENAME()] >>= sFileName;
835cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
836cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_STREAM()] >>= xStream;
837cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
838cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTERNAME()] >>= sFilterName;
839cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_FILTEROPTIONS()] >>= sFilterOptions;
840cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_PASSWORD()] >>= sPassword;
841cdf0e10cSrcweir     aMediaDescriptor[comphelper::MediaDescriptor::PROP_DOCUMENTBASEURL() ] >>= sBaseURL;
842cdf0e10cSrcweir     if ( !xInputStream.is() && xStream.is() )
843cdf0e10cSrcweir         xInputStream = xStream->getInputStream();
844cdf0e10cSrcweir 
845cdf0e10cSrcweir     if(!pDocSh || (!sFileName.getLength() && !xInputStream.is()))
846cdf0e10cSrcweir 		return;
847cdf0e10cSrcweir 
848cdf0e10cSrcweir     SfxObjectFactory& rFact = pDocSh->GetFactory();
849cdf0e10cSrcweir     const SfxFilter* pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( sFilterName );
850cdf0e10cSrcweir     uno::Reference < embed::XStorage > xReadStorage;
851cdf0e10cSrcweir     if( xInputStream.is() )
852cdf0e10cSrcweir     {
853cdf0e10cSrcweir         uno::Sequence< uno::Any > aArgs( 2 );
854cdf0e10cSrcweir         aArgs[0] <<= xInputStream;
855cdf0e10cSrcweir         aArgs[1] <<= embed::ElementModes::READ;
856cdf0e10cSrcweir         try
857cdf0e10cSrcweir         {
858cdf0e10cSrcweir             xReadStorage = uno::Reference< embed::XStorage >(
859cdf0e10cSrcweir                             ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ),
860cdf0e10cSrcweir                             uno::UNO_QUERY );
861cdf0e10cSrcweir         }
862cdf0e10cSrcweir         catch( const io::IOException& rEx)
863cdf0e10cSrcweir         {
864cdf0e10cSrcweir             (void)rEx;
865cdf0e10cSrcweir         }
866cdf0e10cSrcweir     }
867cdf0e10cSrcweir     if ( !pFilter )
868cdf0e10cSrcweir 	{
869cdf0e10cSrcweir         if( xInputStream.is() && !xReadStorage.is())
870cdf0e10cSrcweir         {
871cdf0e10cSrcweir             pMed = new SfxMedium;
872cdf0e10cSrcweir             pMed->setStreamToLoadFrom(xInputStream, sal_True );
873cdf0e10cSrcweir         }
874cdf0e10cSrcweir         else
875cdf0e10cSrcweir             pMed = xReadStorage.is() ?
876cdf0e10cSrcweir                 new SfxMedium(xReadStorage, sBaseURL, 0 ) :
877cdf0e10cSrcweir                 new SfxMedium(sFileName, STREAM_READ, sal_True, 0, 0 );
878cdf0e10cSrcweir         if( sBaseURL.getLength() )
879cdf0e10cSrcweir             pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 		SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
882cdf0e10cSrcweir 		ErrCode nErr = aMatcher.GuessFilter( *pMed, &pFilter, sal_False );
883cdf0e10cSrcweir 		if ( nErr || !pFilter)
884cdf0e10cSrcweir 			DELETEZ(pMed);
885cdf0e10cSrcweir 		else
886cdf0e10cSrcweir 			pMed->SetFilter( pFilter );
887cdf0e10cSrcweir 	}
888cdf0e10cSrcweir 	else
889cdf0e10cSrcweir 	{
890cdf0e10cSrcweir         if(!pMed)
891cdf0e10cSrcweir         {
892cdf0e10cSrcweir             if( xInputStream.is() && !xReadStorage.is())
893cdf0e10cSrcweir             {
894cdf0e10cSrcweir                 pMed = new SfxMedium;
895cdf0e10cSrcweir                 pMed->setStreamToLoadFrom(xInputStream, sal_True );
896cdf0e10cSrcweir                 pMed->SetFilter( pFilter );
897cdf0e10cSrcweir             }
898cdf0e10cSrcweir             else
899cdf0e10cSrcweir             {
900cdf0e10cSrcweir                 if( xReadStorage.is() )
901cdf0e10cSrcweir                 {
902cdf0e10cSrcweir                     pMed = new SfxMedium(xReadStorage, sBaseURL, 0 );
903cdf0e10cSrcweir                     pMed->SetFilter( pFilter );
904cdf0e10cSrcweir                 }
905cdf0e10cSrcweir                 else
906cdf0e10cSrcweir                     pMed = new SfxMedium(sFileName, STREAM_READ, sal_True, pFilter, 0);
907cdf0e10cSrcweir             }
908cdf0e10cSrcweir         }
909cdf0e10cSrcweir         if(sFilterOptions.getLength())
910cdf0e10cSrcweir             pMed->GetItemSet()->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sFilterOptions ) );
911cdf0e10cSrcweir         if( sBaseURL.getLength())
912cdf0e10cSrcweir             pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
913cdf0e10cSrcweir 	}
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 	if( !pMed )
916cdf0e10cSrcweir 		return;
917cdf0e10cSrcweir 
918cdf0e10cSrcweir     // this sourcecode is not responsible for the lifetime of the shell, SfxObjectShellLock should not be used
919cdf0e10cSrcweir 	SfxObjectShellRef aRef( pDocSh );
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 	pDocSh->RegisterTransfer( *pMed );
922cdf0e10cSrcweir 	pMed->DownLoad();	// ggfs. den DownLoad anstossen
923cdf0e10cSrcweir 	if( aRef.Is() && 1 < aRef->GetRefCount() )	// noch gueltige Ref?
924cdf0e10cSrcweir 	{
925cdf0e10cSrcweir 		SwReader* pRdr;
926cdf0e10cSrcweir 		SfxItemSet* pSet = 	pMed->GetItemSet();
927cdf0e10cSrcweir 		pSet->Put(SfxBoolItem(FN_API_CALL, sal_True));
928cdf0e10cSrcweir         if(sPassword.getLength())
929cdf0e10cSrcweir             pSet->Put(SfxStringItem(SID_PASSWORD, sPassword));
930cdf0e10cSrcweir 		Reader *pRead = pDocSh->StartConvertFrom( *pMed, &pRdr, 0, pUnoCrsr);
931cdf0e10cSrcweir 		if( pRead )
932cdf0e10cSrcweir 		{
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 			UnoActionContext aContext(pDoc);
935cdf0e10cSrcweir 
936cdf0e10cSrcweir 			if(pUnoCrsr->HasMark())
937cdf0e10cSrcweir 				pDoc->DeleteAndJoin(*pUnoCrsr);
938cdf0e10cSrcweir 
939cdf0e10cSrcweir 			SwNodeIndex aSave(  pUnoCrsr->GetPoint()->nNode, -1 );
940cdf0e10cSrcweir 			xub_StrLen nCntnt = pUnoCrsr->GetPoint()->nContent.GetIndex();
941cdf0e10cSrcweir 
942cdf0e10cSrcweir             sal_uInt32 nErrno = pRdr->Read( *pRead );   // und Dokument einfuegen
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 			if(!nErrno)
945cdf0e10cSrcweir 			{
946cdf0e10cSrcweir 				aSave++;
947cdf0e10cSrcweir 				pUnoCrsr->SetMark();
948cdf0e10cSrcweir 				pUnoCrsr->GetMark()->nNode = aSave;
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 				SwCntntNode* pCntNode = aSave.GetNode().GetCntntNode();
951cdf0e10cSrcweir 				if( !pCntNode )
952cdf0e10cSrcweir 					nCntnt = 0;
953cdf0e10cSrcweir 				pUnoCrsr->GetMark()->nContent.Assign( pCntNode, nCntnt );
954cdf0e10cSrcweir 			}
955cdf0e10cSrcweir 
956cdf0e10cSrcweir 			delete pRdr;
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 			// ggfs. alle Verzeichnisse updaten:
959cdf0e10cSrcweir /*			if( pWrtShell->IsUpdateTOX() )
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir 				SfxRequest aReq( *this, FN_UPDATE_TOX );
962cdf0e10cSrcweir 				Execute( aReq );
963cdf0e10cSrcweir 				pWrtShell->SetUpdateTOX( sal_False );		// wieder zurueck setzen
964cdf0e10cSrcweir 			}*/
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 		}
967cdf0e10cSrcweir 	}
968cdf0e10cSrcweir 	delete pMed;
969cdf0e10cSrcweir }
970cdf0e10cSrcweir 
971cdf0e10cSrcweir /* -----------------14.07.04 ------------------------
972cdf0e10cSrcweir  *
973cdf0e10cSrcweir  * --------------------------------------------------*/
974cdf0e10cSrcweir 
975cdf0e10cSrcweir // insert text and scan for CR characters in order to insert
976cdf0e10cSrcweir // paragraph breaks at those positions by calling SplitNode
DocInsertStringSplitCR(SwDoc & rDoc,const SwPaM & rNewCursor,const String & rText,const bool bForceExpandHints)977cdf0e10cSrcweir sal_Bool DocInsertStringSplitCR(
978cdf0e10cSrcweir         SwDoc &rDoc,
979cdf0e10cSrcweir         const SwPaM &rNewCursor, const String &rText,
980cdf0e10cSrcweir         const bool bForceExpandHints )
981cdf0e10cSrcweir {
982cdf0e10cSrcweir     sal_Bool bOK = sal_True;
983cdf0e10cSrcweir 
984cdf0e10cSrcweir         const enum IDocumentContentOperations::InsertFlags nInsertFlags =
985cdf0e10cSrcweir             (bForceExpandHints)
986cdf0e10cSrcweir             ? static_cast<IDocumentContentOperations::InsertFlags>(
987cdf0e10cSrcweir                     IDocumentContentOperations::INS_FORCEHINTEXPAND |
988cdf0e10cSrcweir                     IDocumentContentOperations::INS_EMPTYEXPAND)
989cdf0e10cSrcweir             : IDocumentContentOperations::INS_EMPTYEXPAND;
990cdf0e10cSrcweir 
991cdf0e10cSrcweir     // grouping done in InsertString is intended for typing, not API calls
992cdf0e10cSrcweir     ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
993cdf0e10cSrcweir     OUString aTxt;
994cdf0e10cSrcweir     xub_StrLen nStartIdx = 0;
995cdf0e10cSrcweir     SwTxtNode* const pTxtNd =
996cdf0e10cSrcweir         rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode();
997cdf0e10cSrcweir     const xub_StrLen nMaxLength = ( pTxtNd )
998cdf0e10cSrcweir         ? STRING_LEN - pTxtNd->GetTxt().Len()
999cdf0e10cSrcweir         : STRING_LEN;
1000cdf0e10cSrcweir     xub_StrLen nIdx = rText.Search( '\r', nStartIdx );
1001cdf0e10cSrcweir     if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) ||
1002cdf0e10cSrcweir         ( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) )
1003cdf0e10cSrcweir     {
1004cdf0e10cSrcweir         nIdx = nMaxLength;
1005cdf0e10cSrcweir     }
1006cdf0e10cSrcweir     while (nIdx != STRING_NOTFOUND )
1007cdf0e10cSrcweir     {
1008cdf0e10cSrcweir         DBG_ASSERT( nIdx - nStartIdx >= 0, "index negative!" );
1009cdf0e10cSrcweir         aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx );
1010cdf0e10cSrcweir         if (aTxt.getLength() &&
1011cdf0e10cSrcweir             !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
1012cdf0e10cSrcweir         {
1013cdf0e10cSrcweir             DBG_ERROR( "Doc->Insert(Str) failed." );
1014cdf0e10cSrcweir             bOK = sal_False;
1015cdf0e10cSrcweir         }
1016cdf0e10cSrcweir         if (!rDoc.SplitNode( *rNewCursor.GetPoint(), false ) )
1017cdf0e10cSrcweir         {
1018cdf0e10cSrcweir             DBG_ERROR( "SplitNode failed" );
1019cdf0e10cSrcweir             bOK = sal_False;
1020cdf0e10cSrcweir         }
1021cdf0e10cSrcweir         nStartIdx = nIdx + 1;
1022cdf0e10cSrcweir         nIdx = rText.Search( '\r', nStartIdx );
1023cdf0e10cSrcweir     }
1024cdf0e10cSrcweir     aTxt = rText.Copy( nStartIdx );
1025cdf0e10cSrcweir     if (aTxt.getLength() &&
1026cdf0e10cSrcweir         !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
1027cdf0e10cSrcweir     {
1028cdf0e10cSrcweir         DBG_ERROR( "Doc->Insert(Str) failed." );
1029cdf0e10cSrcweir         bOK = sal_False;
1030cdf0e10cSrcweir     }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir     return bOK;
1033cdf0e10cSrcweir }
1034cdf0e10cSrcweir /*-- 10.03.2008 09:58:47---------------------------------------------------
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir   -----------------------------------------------------------------------*/
makeRedline(SwPaM & rPaM,const::rtl::OUString & rRedlineType,const uno::Sequence<beans::PropertyValue> & rRedlineProperties)1037cdf0e10cSrcweir void makeRedline( SwPaM& rPaM,
1038cdf0e10cSrcweir     const ::rtl::OUString& rRedlineType,
1039cdf0e10cSrcweir     const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1040cdf0e10cSrcweir         throw (lang::IllegalArgumentException, uno::RuntimeException)
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir     IDocumentRedlineAccess* pRedlineAccess = rPaM.GetDoc();
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir     RedlineType_t eType = nsRedlineType_t::REDLINE_INSERT;
1045cdf0e10cSrcweir     if( rRedlineType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Delete" ) ))
1046cdf0e10cSrcweir         eType = nsRedlineType_t::REDLINE_DELETE;
1047cdf0e10cSrcweir     else if( rRedlineType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Format" ) ))
1048cdf0e10cSrcweir         eType = nsRedlineType_t::REDLINE_FORMAT;
1049cdf0e10cSrcweir     else if( rRedlineType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "TextTable" ) ))
1050cdf0e10cSrcweir         eType = nsRedlineType_t::REDLINE_TABLE;
1051cdf0e10cSrcweir     else if( !rRedlineType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Insert" ) ))
1052cdf0e10cSrcweir         throw lang::IllegalArgumentException();
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir     //todo: what about REDLINE_FMTCOLL?
1055cdf0e10cSrcweir     comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
1056cdf0e10cSrcweir     uno::Any aAuthorValue;
1057cdf0e10cSrcweir     aAuthorValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("RedlineAuthor"), aAuthorValue);
1058cdf0e10cSrcweir     sal_uInt16 nAuthor = 0;
1059cdf0e10cSrcweir     ::rtl::OUString sAuthor;
1060cdf0e10cSrcweir     if( aAuthorValue >>= sAuthor )
1061cdf0e10cSrcweir         nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor);
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir     ::rtl::OUString sComment;
1064cdf0e10cSrcweir     uno::Any aCommentValue;
1065cdf0e10cSrcweir     aCommentValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("RedlineComment"), aCommentValue);
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir     SwRedlineData aRedlineData( eType, nAuthor );
1068cdf0e10cSrcweir     if( aCommentValue >>= sComment )
1069cdf0e10cSrcweir         aRedlineData.SetComment( sComment );
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir     ::util::DateTime aStamp;
1072cdf0e10cSrcweir     uno::Any aDateTimeValue;
1073cdf0e10cSrcweir     aDateTimeValue = aPropMap.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("RedlineDateTime"), aDateTimeValue);
1074cdf0e10cSrcweir     if( aDateTimeValue >>= aStamp )
1075cdf0e10cSrcweir     {
1076cdf0e10cSrcweir        aRedlineData.SetTimeStamp(
1077cdf0e10cSrcweir         DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
1078cdf0e10cSrcweir     }
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir     SwRedline* pRedline = new SwRedline( aRedlineData, rPaM );
1081cdf0e10cSrcweir     RedlineMode_t nPrevMode = pRedlineAccess->GetRedlineMode( );
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir     pRedlineAccess->SetRedlineMode_intern(nsRedlineMode_t::REDLINE_ON);
1084cdf0e10cSrcweir     bool bRet = pRedlineAccess->AppendRedline( pRedline, false );
1085cdf0e10cSrcweir     pRedlineAccess->SetRedlineMode_intern( nPrevMode );
1086cdf0e10cSrcweir     if( !bRet )
1087cdf0e10cSrcweir         throw lang::IllegalArgumentException();
1088cdf0e10cSrcweir }
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir /*-- 19.02.2009 09:27:26---------------------------------------------------
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir   -----------------------------------------------------------------------*/
~SwAnyMapHelper()1093cdf0e10cSrcweir SwAnyMapHelper::~SwAnyMapHelper()
1094cdf0e10cSrcweir {
1095cdf0e10cSrcweir     AnyMapHelper_t::iterator aIt = begin();
1096cdf0e10cSrcweir     while( aIt != end() )
1097cdf0e10cSrcweir     {
1098cdf0e10cSrcweir         delete ( aIt->second );
1099cdf0e10cSrcweir         ++aIt;
1100cdf0e10cSrcweir     }
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir /*-- 19.02.2009 09:27:26---------------------------------------------------
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetValue(sal_uInt16 nWhichId,sal_uInt16 nMemberId,const uno::Any & rAny)1105cdf0e10cSrcweir void SwAnyMapHelper::SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rAny )
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir     sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
1108cdf0e10cSrcweir     AnyMapHelper_t::iterator aIt = find( nKey );
1109cdf0e10cSrcweir     if( aIt != end() )
1110cdf0e10cSrcweir     {
1111cdf0e10cSrcweir         *(aIt->second) = rAny;
1112cdf0e10cSrcweir     }
1113cdf0e10cSrcweir     else
1114cdf0e10cSrcweir         insert( value_type(nKey, new uno::Any( rAny )) );
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir /*-- 19.02.2009 09:27:26---------------------------------------------------
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir   -----------------------------------------------------------------------*/
FillValue(sal_uInt16 nWhichId,sal_uInt16 nMemberId,const uno::Any * & pAny)1119cdf0e10cSrcweir bool    SwAnyMapHelper::FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& pAny )
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir     bool bRet = false;
1122cdf0e10cSrcweir     sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
1123cdf0e10cSrcweir     AnyMapHelper_t::iterator aIt = find( nKey );
1124cdf0e10cSrcweir     if( aIt != end() )
1125cdf0e10cSrcweir     {
1126cdf0e10cSrcweir         pAny = aIt->second;
1127cdf0e10cSrcweir         bRet = true;
1128cdf0e10cSrcweir     }
1129cdf0e10cSrcweir     return bRet;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir }//namespace SwUnoCursorHelper
1133cdf0e10cSrcweir 
1134