xref: /aoo41x/main/sc/source/ui/view/viewutil.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 
32 
33 // INCLUDE ---------------------------------------------------------------
34 #include <tools/list.hxx>
35 #include "scitems.hxx"
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/viewsh.hxx>
38 #include <sfx2/dispatch.hxx>
39 #include <editeng/fontitem.hxx>
40 #include <editeng/langitem.hxx>
41 #include <editeng/scripttypeitem.hxx>
42 #include <svl/itempool.hxx>
43 #include <svl/itemset.hxx>
44 #include <svl/cjkoptions.hxx>
45 #include <svl/ctloptions.hxx>
46 #include <vcl/svapp.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <vcl/wrkwin.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <svl/stritem.hxx>
52 #include <svl/eitem.hxx>
53 
54 #include <com/sun/star/i18n/TransliterationModules.hpp>
55 #include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
56 
57 
58 #include "viewutil.hxx"
59 #include "global.hxx"
60 #include "chgtrack.hxx"
61 #include "chgviset.hxx"
62 #include "markdata.hxx"
63 
64 #include <svx/svxdlg.hxx> //CHINA001
65 #include <svx/dialogs.hrc> //CHINA001
66 // STATIC DATA -----------------------------------------------------------
67 
68 //==================================================================
69 
70 //	static
71 void ScViewUtil::PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
72 								sal_uInt16 nWhichId, sal_uInt16 nScript )
73 {
74 	//	take the effective item from rCoreSet according to nScript
75 	//	and put in rShellSet under the (base) nWhichId
76 
77 	SfxItemPool& rPool = *rShellSet.GetPool();
78 	SvxScriptSetItem aSetItem( rPool.GetSlotId(nWhichId), rPool );
79 	//	use PutExtended with eDefaultAs = SFX_ITEM_SET, so defaults from rCoreSet
80 	//	(document pool) are read and put into rShellSet (MessagePool)
81 	aSetItem.GetItemSet().PutExtended( rCoreSet, SFX_ITEM_DONTCARE, SFX_ITEM_SET );
82 	const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
83 	if (pI)
84 		rShellSet.Put( *pI, nWhichId );
85 	else
86 		rShellSet.InvalidateItem( nWhichId );
87 }
88 
89 //	static
90 sal_uInt16 ScViewUtil::GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos )
91 {
92 	//	used for thesaurus
93 
94 	sal_uInt8 nScript = pDoc->GetScriptType( rPos.Col(), rPos.Row(), rPos.Tab() );
95 	sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
96 					( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE : ATTR_FONT_LANGUAGE );
97 	const SfxPoolItem* pItem = pDoc->GetAttr( rPos.Col(), rPos.Row(), rPos.Tab(), nWhich);
98 	SvxLanguageItem* pLangIt = PTR_CAST( SvxLanguageItem, pItem );
99 	LanguageType eLnge;
100 	if (pLangIt)
101 	{
102 		eLnge = (LanguageType) pLangIt->GetValue();
103 		if (eLnge == LANGUAGE_DONTKNOW)					//! can this happen?
104 		{
105 			LanguageType eLatin, eCjk, eCtl;
106 			pDoc->GetLanguage( eLatin, eCjk, eCtl );
107 			eLnge = ( nScript == SCRIPTTYPE_ASIAN ) ? eCjk :
108 					( ( nScript == SCRIPTTYPE_COMPLEX ) ? eCtl : eLatin );
109 		}
110 	}
111 	else
112 		eLnge = LANGUAGE_ENGLISH_US;
113 	if ( eLnge == LANGUAGE_SYSTEM )
114         eLnge = Application::GetSettings().GetLanguage();   // never use SYSTEM for spelling
115 
116 	return eLnge;
117 }
118 
119 //	static
120 sal_Int32 ScViewUtil::GetTransliterationType( sal_uInt16 nSlotID )
121 {
122 	sal_Int32 nType = 0;
123 	switch ( nSlotID )
124 	{
125         case SID_TRANSLITERATE_SENTENCE_CASE:
126             nType = com::sun::star::i18n::TransliterationModulesExtra::SENTENCE_CASE;
127             break;
128         case SID_TRANSLITERATE_TITLE_CASE:
129             nType = com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE;
130             break;
131         case SID_TRANSLITERATE_TOGGLE_CASE:
132             nType = com::sun::star::i18n::TransliterationModulesExtra::TOGGLE_CASE;
133             break;
134         case SID_TRANSLITERATE_UPPER:
135 			nType = com::sun::star::i18n::TransliterationModules_LOWERCASE_UPPERCASE;
136 			break;
137 		case SID_TRANSLITERATE_LOWER:
138 			nType = com::sun::star::i18n::TransliterationModules_UPPERCASE_LOWERCASE;
139 			break;
140 		case SID_TRANSLITERATE_HALFWIDTH:
141 			nType = com::sun::star::i18n::TransliterationModules_FULLWIDTH_HALFWIDTH;
142 			break;
143 		case SID_TRANSLITERATE_FULLWIDTH:
144 			nType = com::sun::star::i18n::TransliterationModules_HALFWIDTH_FULLWIDTH;
145 			break;
146 		case SID_TRANSLITERATE_HIRAGANA:
147 			nType = com::sun::star::i18n::TransliterationModules_KATAKANA_HIRAGANA;
148 			break;
149 		case SID_TRANSLITERATE_KATAGANA:
150 			nType = com::sun::star::i18n::TransliterationModules_HIRAGANA_KATAKANA;
151 			break;
152 	}
153 	return nType;
154 }
155 
156 //	static
157 sal_Bool ScViewUtil::IsActionShown( const ScChangeAction& rAction,
158 								const ScChangeViewSettings& rSettings,
159 								ScDocument& rDocument )
160 {
161 	// abgelehnte werden durch eine invertierende akzeptierte Action dargestellt,
162 	// die Reihenfolge von ShowRejected/ShowAccepted ist deswegen wichtig
163 
164 	if ( !rSettings.IsShowRejected() && rAction.IsRejecting() )
165 		return sal_False;
166 
167 	if ( !rSettings.IsShowAccepted() && rAction.IsAccepted() && !rAction.IsRejecting() )
168 		return sal_False;
169 
170 	if ( rSettings.HasAuthor() )
171 	{
172 		if ( rSettings.IsEveryoneButMe() )
173 		{
174 			//	GetUser() am ChangeTrack ist der aktuelle Benutzer
175 			ScChangeTrack* pTrack = rDocument.GetChangeTrack();
176 			if ( !pTrack || rAction.GetUser() == pTrack->GetUser() )
177 				return sal_False;
178 		}
179 		else if ( rAction.GetUser() != rSettings.GetTheAuthorToShow() )
180 			return sal_False;
181 	}
182 
183 	if ( rSettings.HasComment() )
184 	{
185 		String aComStr=rAction.GetComment();
186 		aComStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
187 		rAction.GetDescription( aComStr, &rDocument );
188 		aComStr+=')';
189 
190 		if(!rSettings.IsValidComment(&aComStr))
191 			return sal_False;
192 	}
193 
194 	if ( rSettings.HasRange() )
195 		if ( !rSettings.GetTheRangeList().Intersects( rAction.GetBigRange().MakeRange() ) )
196 			return sal_False;
197 
198 	if ( rSettings.HasDate() && rSettings.GetTheDateMode() != SCDM_NO_DATEMODE )
199 	{
200 		DateTime aDateTime = rAction.GetDateTime();
201 		const DateTime& rFirst = rSettings.GetTheFirstDateTime();
202 		const DateTime& rLast  = rSettings.GetTheLastDateTime();
203 		switch ( rSettings.GetTheDateMode() )
204 		{	// korrespondiert mit ScHighlightChgDlg::OKBtnHdl
205 			case SCDM_DATE_BEFORE:
206 				if ( aDateTime > rFirst )
207 					return sal_False;
208 				break;
209 
210 			case SCDM_DATE_SINCE:
211 				if ( aDateTime < rFirst )
212 					return sal_False;
213 				break;
214 
215 			case SCDM_DATE_EQUAL:
216 			case SCDM_DATE_BETWEEN:
217 				if ( aDateTime < rFirst || aDateTime > rLast )
218 					return sal_False;
219 				break;
220 
221 			case SCDM_DATE_NOTEQUAL:
222 				if ( aDateTime >= rFirst && aDateTime <= rLast )
223 					return sal_False;
224 				break;
225 
226 			case SCDM_DATE_SAVE:
227 				{
228 				ScChangeTrack* pTrack = rDocument.GetChangeTrack();
229 				if ( !pTrack || pTrack->GetLastSavedActionNumber() >=
230 						rAction.GetActionNumber() )
231 					return sal_False;
232 				}
233 				break;
234 
235             default:
236             {
237                 // added to avoid warnings
238             }
239 		}
240 	}
241 
242     if ( rSettings.HasActionRange() )
243     {
244         sal_uLong nAction = rAction.GetActionNumber();
245         sal_uLong nFirstAction;
246         sal_uLong nLastAction;
247         rSettings.GetTheActionRange( nFirstAction, nLastAction );
248         if ( nAction < nFirstAction || nAction > nLastAction )
249         {
250             return sal_False;
251         }
252     }
253 
254 	return sal_True;
255 }
256 
257 // static
258 void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc )
259 {
260     rMark.MarkToMulti();
261 
262     ScRange aMultiArea;
263     rMark.GetMultiMarkArea( aMultiArea );
264     SCCOL nStartCol = aMultiArea.aStart.Col();
265     SCROW nStartRow = aMultiArea.aStart.Row();
266     SCCOL nEndCol = aMultiArea.aEnd.Col();
267     SCROW nEndRow = aMultiArea.aEnd.Row();
268 
269     bool bChanged = false;
270     SCTAB nTabCount = pDoc->GetTableCount();
271     for (SCTAB nTab=0; nTab<nTabCount; nTab++)
272         if ( rMark.GetTableSelect(nTab ) )
273         {
274             for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
275             {
276                 SCROW nLastRow = nRow;
277                 if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow))
278     			{
279                     // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns
280                     // (visible in repaint for indentation)
281                     rMark.SetMultiMarkArea(
282                         ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false);
283                     bChanged = true;
284                     nRow = nLastRow;
285     			}
286             }
287         }
288 
289     if ( bChanged && !rMark.HasAnyMultiMarks() )
290         rMark.ResetMark();
291 
292     rMark.MarkToSimple();
293 }
294 
295 
296 // static
297 bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows )
298 {
299     SCTAB nTab = rRange.aStart.Tab();
300     bool bOneTabOnly = (nTab == rRange.aEnd.Tab());
301     // Always fit the range on its first sheet.
302     DBG_ASSERT( bOneTabOnly, "ScViewUtil::ExtendToUnfilteredRows: works only on one sheet");
303     SCROW nStartRow = rRange.aStart.Row();
304     SCROW nLastRow = pDoc->LastNonFilteredRow(nStartRow, MAXROW, nTab);
305     if (ValidRow(nLastRow))
306         rRange.aEnd.SetRow(nLastRow);
307     SCROW nCount = pDoc->CountNonFilteredRows(nStartRow, MAXROW, nTab);
308     return static_cast<size_t>(nCount) == nRows && bOneTabOnly;
309 }
310 
311 
312 // static
313 bool ScViewUtil::HasFiltered( const ScRange& rRange, ScDocument* pDoc )
314 {
315     SCROW nStartRow = rRange.aStart.Row();
316     SCROW nEndRow = rRange.aEnd.Row();
317     for (SCTAB nTab=rRange.aStart.Tab(); nTab<=rRange.aEnd.Tab(); nTab++)
318     {
319         if (pDoc->HasFilteredRows(nStartRow, nEndRow, nTab))
320             return true;
321     }
322 
323     return false;
324 }
325 
326 // static
327 void ScViewUtil::HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, sal_uInt16 nSlotId )
328 {
329     SvtCJKOptions aCJKOptions;
330     SvtCTLOptions aCTLOptions;
331     bool bEnabled = true;
332 
333     switch( nSlotId )
334     {
335         case SID_CHINESE_CONVERSION:
336         case SID_HANGUL_HANJA_CONVERSION:
337             bEnabled = aCJKOptions.IsAnyEnabled();
338         break;
339 
340         case SID_TRANSLITERATE_HALFWIDTH:
341         case SID_TRANSLITERATE_FULLWIDTH:
342         case SID_TRANSLITERATE_HIRAGANA:
343         case SID_TRANSLITERATE_KATAGANA:
344             bEnabled = aCJKOptions.IsChangeCaseMapEnabled();
345         break;
346 
347         case SID_INSERT_RLM:
348         case SID_INSERT_LRM:
349         case SID_INSERT_ZWNBSP:
350         case SID_INSERT_ZWSP:
351             bEnabled = aCTLOptions.IsCTLFontEnabled();
352         break;
353 
354         default:
355             DBG_ERRORFILE( "ScViewUtil::HideDisabledSlot - unknown slot ID" );
356             return;
357     }
358 
359     rBindings.SetVisibleState( nSlotId, bEnabled );
360     if( !bEnabled )
361         rSet.DisableItem( nSlotId );
362 }
363 
364 //==================================================================
365 
366 sal_Bool ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
367 								 SfxViewFrame& rFrame,
368 								 SvxFontItem& 		rNewFont,
369 								 String&			rString )
370 {
371 	sal_Bool bRet = sal_False;
372 	SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
373 	if(pFact)
374 	{
375 		SfxAllItemSet aSet( rFrame.GetObjectShell()->GetPool() );
376 		aSet.Put( SfxBoolItem( FN_PARAM_1, sal_False ) );
377 		aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
378 		SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
379 		if ( pDlg->Execute() == RET_OK )
380 		{
381 			SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, sal_False );
382 			SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, sal_False );
383 			if ( pItem )
384 				rString  = pItem->GetValue();
385 			if ( pFontItem )
386 				rNewFont = SvxFontItem( pFontItem->GetFamily(), pFontItem->GetFamilyName(), pFontItem->GetStyleName(), pFontItem->GetPitch(), pFontItem->GetCharSet(), rNewFont.Which() );
387 			bRet = sal_True;
388 		}
389 		delete pDlg;
390 	}
391 	return bRet;
392 }
393 
394 bool ScViewUtil::IsFullScreen( SfxViewShell& rViewShell )
395 {
396     SfxBindings&    rBindings       = rViewShell.GetViewFrame()->GetBindings();
397     SfxPoolItem*    pItem           = 0;
398     bool            bIsFullScreen   = false;
399 
400     if (rBindings.QueryState( SID_WIN_FULLSCREEN, pItem ) >= SFX_ITEM_DEFAULT)
401         bIsFullScreen = static_cast< SfxBoolItem* >( pItem )->GetValue();
402     return bIsFullScreen;
403 }
404 
405 void ScViewUtil::SetFullScreen( SfxViewShell& rViewShell, bool bSet )
406 {
407     if( IsFullScreen( rViewShell ) != bSet )
408     {
409         SfxBoolItem aItem( SID_WIN_FULLSCREEN, bSet );
410         rViewShell.GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
411     }
412 }
413 
414 //------------------------------------------------------------------
415 
416 ScUpdateRect::ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
417 {
418 	PutInOrder( nX1, nX2 );
419 	PutInOrder( nY1, nY2 );
420 
421 	nOldStartX = nX1;
422 	nOldStartY = nY1;
423 	nOldEndX = nX2;
424 	nOldEndY = nY2;
425 }
426 
427 void ScUpdateRect::SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
428 {
429 	PutInOrder( nX1, nX2 );
430 	PutInOrder( nY1, nY2 );
431 
432 	nNewStartX = nX1;
433 	nNewStartY = nY1;
434 	nNewEndX = nX2;
435 	nNewEndY = nY2;
436 }
437 
438 sal_Bool ScUpdateRect::GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
439 {
440 	if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX &&
441 		 nNewStartY == nOldStartY && nNewEndY == nOldEndY )
442 	{
443 		rX1 = nNewStartX;
444 		rY1 = nNewStartY;
445 		rX2 = nNewStartX;
446 		rY2 = nNewStartY;
447 		return sal_False;
448 	}
449 
450 	rX1 = Min(nNewStartX,nOldStartX);
451 	rY1 = Min(nNewStartY,nOldStartY);
452 	rX2 = Max(nNewEndX,nOldEndX);
453 	rY2 = Max(nNewEndY,nOldEndY);
454 
455 	if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX )
456 	{
457 		if ( nNewStartY == nOldStartY )
458 		{
459 			rY1 = Min( nNewEndY, nOldEndY );
460 			rY2 = Max( nNewEndY, nOldEndY );
461 		}
462 		else if ( nNewEndY == nOldEndY )
463 		{
464 			rY1 = Min( nNewStartY, nOldStartY );
465 			rY2 = Max( nNewStartY, nOldStartY );
466 		}
467 	}
468 	else if ( nNewStartY == nOldStartY && nNewEndY == nOldEndY )
469 	{
470 		if ( nNewStartX == nOldStartX )
471 		{
472 			rX1 = Min( nNewEndX, nOldEndX );
473 			rX2 = Max( nNewEndX, nOldEndX );
474 		}
475 		else if ( nNewEndX == nOldEndX )
476 		{
477 			rX1 = Min( nNewStartX, nOldStartX );
478 			rX2 = Max( nNewStartX, nOldStartX );
479 		}
480 	}
481 
482 	return sal_True;
483 }
484 
485 #ifdef OLD_SELECTION_PAINT
486 sal_Bool ScUpdateRect::GetXorDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, sal_Bool& rCont )
487 {
488     rCont = sal_False;
489 
490     if (nNewStartX == nOldStartX && nNewEndX == nOldEndX &&
491         nNewStartY == nOldStartY && nNewEndY == nOldEndY)
492     {
493         rX1 = nNewStartX;
494         rY1 = nNewStartY;
495         rX2 = nNewStartX;
496         rY2 = nNewStartY;
497         return sal_False;
498     }
499 
500     rX1 = Min(nNewStartX,nOldStartX);
501     rY1 = Min(nNewStartY,nOldStartY);
502     rX2 = Max(nNewEndX,nOldEndX);
503     rY2 = Max(nNewEndY,nOldEndY);
504 
505     if (nNewStartX == nOldStartX && nNewEndX == nOldEndX)             // nur vertikal
506     {
507         if (nNewStartY == nOldStartY)
508         {
509             rY1 = Min( nNewEndY, nOldEndY ) + 1;
510             rY2 = Max( nNewEndY, nOldEndY );
511         }
512         else if (nNewEndY == nOldEndY)
513         {
514             rY1 = Min( nNewStartY, nOldStartY );
515             rY2 = Max( nNewStartY, nOldStartY ) - 1;
516         }
517         else
518         {
519             rY1 = Min( nNewStartY, nOldStartY );
520             rY2 = Max( nNewStartY, nOldStartY ) - 1;
521             rCont = sal_True;
522             nContY1 = Min( nNewEndY, nOldEndY ) + 1;
523             nContY2 = Max( nNewEndY, nOldEndY );
524             nContX1 = rX1;
525             nContX2 = rX2;
526         }
527     }
528     else if (nNewStartY == nOldStartY && nNewEndY == nOldEndY)        // nur horizontal
529     {
530         if (nNewStartX == nOldStartX)
531         {
532             rX1 = Min( nNewEndX, nOldEndX ) + 1;
533             rX2 = Max( nNewEndX, nOldEndX );
534         }
535         else if (nNewEndX == nOldEndX)
536         {
537             rX1 = Min( nNewStartX, nOldStartX );
538             rX2 = Max( nNewStartX, nOldStartX ) - 1;
539         }
540         else
541         {
542             rX1 = Min( nNewStartX, nOldStartX );
543             rX2 = Max( nNewStartX, nOldStartX ) - 1;
544             rCont = sal_True;
545             nContX1 = Min( nNewEndX, nOldEndX ) + 1;
546             nContX2 = Max( nNewEndX, nOldEndX );
547             nContY1 = rY1;
548             nContY2 = rY2;
549         }
550     }
551     else if (nNewEndX == nOldEndX && nNewEndY == nOldEndY)            // links oben
552     {
553         if ((nNewStartX<nOldStartX) == (nNewStartY<nOldStartY))
554             rX1 = Min( nNewStartX, nOldStartX );
555         else
556             rX1 = Max( nNewStartX, nOldStartX );            // Ecke weglassen
557         rX2 = nOldEndX;
558         rY1 = Min( nNewStartY, nOldStartY );                // oben
559         rY2 = Max( nNewStartY, nOldStartY ) - 1;
560         rCont = sal_True;
561         nContY1 = rY2+1;
562         nContY2 = nOldEndY;
563         nContX1 = Min( nNewStartX, nOldStartX );            // links
564         nContX2 = Max( nNewStartX, nOldStartX ) - 1;
565     }
566     else if (nNewStartX == nOldStartX && nNewEndY == nOldEndY)        // rechts oben
567     {
568         if ((nNewEndX<nOldEndX) != (nNewStartY<nOldStartY))
569             rX2 = Max( nNewEndX, nOldEndX );
570         else
571             rX2 = Min( nNewEndX, nOldEndX );                // Ecke weglassen
572         rX1 = nOldStartX;
573         rY1 = Min( nNewStartY, nOldStartY );                // oben
574         rY2 = Max( nNewStartY, nOldStartY ) - 1;
575         rCont = sal_True;
576         nContY1 = rY2+1;
577         nContY2 = nOldEndY;
578         nContX1 = Min( nNewEndX, nOldEndX ) + 1;            // rechts
579         nContX2 = Max( nNewEndX, nOldEndX );
580     }
581     else if (nNewEndX == nOldEndX && nNewStartY == nOldStartY)        // links unten
582     {
583         if ((nNewStartX<nOldStartX) != (nNewEndY<nOldEndY))
584             rX1 = Min( nNewStartX, nOldStartX );
585         else
586             rX1 = Max( nNewStartX, nOldStartX );            // Ecke weglassen
587         rX2 = nOldEndX;
588         rY1 = Min( nNewEndY, nOldEndY ) + 1;                // unten
589         rY2 = Max( nNewEndY, nOldEndY );
590         rCont = sal_True;
591         nContY1 = nOldStartY;
592         nContY2 = rY1-1;
593         nContX1 = Min( nNewStartX, nOldStartX );            // links
594         nContX2 = Max( nNewStartX, nOldStartX ) - 1;
595     }
596     else if (nNewStartX == nOldStartX && nNewStartY == nOldStartY)    // rechts unten
597     {
598         if ((nNewEndX<nOldEndX) == (nNewEndY<nOldEndY))
599             rX2 = Max( nNewEndX, nOldEndX );
600         else
601             rX2 = Min( nNewEndX, nOldEndX );                // Ecke weglassen
602         rX1 = nOldStartX;
603         rY1 = Min( nNewEndY, nOldEndY ) + 1;                // unten
604         rY2 = Max( nNewEndY, nOldEndY );
605         rCont = sal_True;
606         nContY1 = nOldStartY;
607         nContY2 = rY1-1;
608         nContX1 = Min( nNewEndX, nOldEndX ) + 1;            // rechts
609         nContX2 = Max( nNewEndX, nOldEndX );
610     }
611     else                                                                // Ueberschlag
612     {
613         rX1 = nOldStartX;
614         rY1 = nOldStartY;
615         rX2 = nOldEndX;
616         rY2 = nOldEndY;
617         rCont = sal_True;
618         nContX1 = nNewStartX;
619         nContY1 = nNewStartY;
620         nContX2 = nNewEndX;
621         nContY2 = nNewEndY;
622     }
623 
624     return sal_True;
625 }
626 
627 void ScUpdateRect::GetContDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
628 {
629     rX1 = nContX1;
630     rY1 = nContY1;
631     rX2 = nContX2;
632     rY2 = nContY2;
633 }
634 #endif
635 
636 
637 
638 
639 
640 
641