1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: editutil.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // System - Includes -----------------------------------------------------
38 // INCLUDE ---------------------------------------------------------------
40 #include "scitems.hxx"
41 #include <svx/eeitem.hxx>
43 #include <svx/algitem.hxx>
44 #include <svtools/colorcfg.hxx>
45 #include <svx/editview.hxx>
46 #include <svx/editstat.hxx>
47 #include <svx/escpitem.hxx>
48 #include <svx/flditem.hxx>
49 #include <svx/numitem.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vcl/outdev.hxx>
52 #include <svtools/inethist.hxx>
53 #include <svtools/syslocale.hxx>
54 #ifndef _SVSTDARR_USHORTS
55 #define _SVSTDARR_USHORTS
56 #include <svtools/svstdarr.hxx>
59 #include "editutil.hxx"
62 #include "document.hxx"
63 #include "docpool.hxx"
64 #include "patattr.hxx"
66 #include "inputopt.hxx"
67 #include "compiler.hxx"
69 // STATIC DATA -----------------------------------------------------------
71 // Delimiters zusaetzlich zu EditEngine-Default:
73 const sal_Char __FAR_DATA
ScEditUtil::pCalcDelimiters
[] = "=()+-*/^&<>";
76 //------------------------------------------------------------------------
78 String
ScEditUtil::ModifyDelimiters( const String
& rOld
)
81 aRet
.EraseAllChars( '_' ); // underscore is used in function argument names
82 aRet
.AppendAscii( RTL_CONSTASCII_STRINGPARAM( pCalcDelimiters
) );
83 aRet
.Append(ScCompiler::GetNativeSymbol(ocSep
)); // argument separator is localized.
87 static String
lcl_GetDelimitedString( const EditEngine
& rEngine
, const sal_Char c
)
90 USHORT nParCount
= rEngine
.GetParagraphCount();
91 for (USHORT nPar
=0; nPar
<nParCount
; nPar
++)
95 aRet
+= rEngine
.GetText( nPar
);
100 String
ScEditUtil::GetSpaceDelimitedString( const EditEngine
& rEngine
)
102 return lcl_GetDelimitedString(rEngine
, ' ');
105 String
ScEditUtil::GetMultilineString( const EditEngine
& rEngine
)
107 return lcl_GetDelimitedString(rEngine
, '\n');
110 //------------------------------------------------------------------------
112 Rectangle
ScEditUtil::GetEditArea( const ScPatternAttr
* pPattern
, BOOL bForceToTop
)
114 // bForceToTop = always align to top, for editing
115 // (FALSE for querying URLs etc.)
118 pPattern
= pDoc
->GetPattern( nCol
, nRow
, nTab
);
120 Point aStartPos
= aScrPos
;
122 BOOL bLayoutRTL
= pDoc
->IsLayoutRTL( nTab
);
123 long nLayoutSign
= bLayoutRTL
? -1 : 1;
125 const ScMergeAttr
* pMerge
= (const ScMergeAttr
*)&pPattern
->GetItem(ATTR_MERGE
);
126 long nCellX
= (long) ( pDoc
->GetColWidth(nCol
,nTab
) * nPPTX
);
127 if ( pMerge
->GetColMerge() > 1 )
129 SCCOL nCountX
= pMerge
->GetColMerge();
130 for (SCCOL i
=1; i
<nCountX
; i
++)
131 nCellX
+= (long) ( pDoc
->GetColWidth(nCol
+i
,nTab
) * nPPTX
);
133 long nCellY
= (long) ( pDoc
->GetRowHeight(nRow
,nTab
) * nPPTY
);
134 if ( pMerge
->GetRowMerge() > 1 )
136 SCROW nCountY
= pMerge
->GetRowMerge();
137 nCellY
+= (long) pDoc
->GetScaledRowHeight( nRow
+1, nRow
+nCountY
-1, nTab
, nPPTY
);
140 const SvxMarginItem
* pMargin
= (const SvxMarginItem
*)&pPattern
->GetItem(ATTR_MARGIN
);
142 if ( ((const SvxHorJustifyItem
&)pPattern
->GetItem(ATTR_HOR_JUSTIFY
)).GetValue() ==
143 SVX_HOR_JUSTIFY_LEFT
)
144 nIndent
= ((const SfxUInt16Item
&)pPattern
->GetItem(ATTR_INDENT
)).GetValue();
145 long nPixDifX
= (long) ( ( pMargin
->GetLeftMargin() + nIndent
) * nPPTX
);
146 aStartPos
.X() += nPixDifX
* nLayoutSign
;
147 nCellX
-= nPixDifX
+ (long) ( pMargin
->GetRightMargin() * nPPTX
); // wegen Umbruch etc.
149 // vertikale Position auf die in der Tabelle anpassen
152 long nTopMargin
= (long) ( pMargin
->GetTopMargin() * nPPTY
);
153 SvxCellVerJustify eJust
= (SvxCellVerJustify
) ((const SvxVerJustifyItem
&)pPattern
->
154 GetItem(ATTR_VER_JUSTIFY
)).GetValue();
156 // asian vertical is always edited top-aligned
157 BOOL bAsianVertical
= ((const SfxBoolItem
&)pPattern
->GetItem( ATTR_STACKED
)).GetValue() &&
158 ((const SfxBoolItem
&)pPattern
->GetItem( ATTR_VERTICAL_ASIAN
)).GetValue();
160 if ( eJust
== SVX_VER_JUSTIFY_TOP
||
161 ( bForceToTop
&& ( SC_MOD()->GetInputOptions().GetTextWysiwyg() || bAsianVertical
) ) )
162 nPixDifY
= nTopMargin
;
165 MapMode aMode
= pDev
->GetMapMode();
166 pDev
->SetMapMode( MAP_PIXEL
);
168 long nTextHeight
= pDoc
->GetNeededSize( nCol
, nRow
, nTab
,
169 pDev
, nPPTX
, nPPTY
, aZoomX
, aZoomY
, FALSE
);
173 // font color doesn't matter here
174 pPattern
->GetFont( aFont
, SC_AUTOCOL_BLACK
, pDev
, &aZoomY
);
175 pDev
->SetFont(aFont
);
176 nTextHeight
= pDev
->GetTextHeight() + nTopMargin
+
177 (long) ( pMargin
->GetBottomMargin() * nPPTY
);
180 pDev
->SetMapMode(aMode
);
182 if ( nTextHeight
> nCellY
+ nTopMargin
|| bForceToTop
)
183 nPixDifY
= 0; // zu gross -> oben anfangen
186 if ( eJust
== SVX_VER_JUSTIFY_CENTER
)
187 nPixDifY
= nTopMargin
+ ( nCellY
- nTextHeight
) / 2;
189 nPixDifY
= nCellY
- nTextHeight
+ nTopMargin
; // JUSTIFY_BOTTOM
193 aStartPos
.Y() += nPixDifY
;
197 aStartPos
.X() -= nCellX
- 2; // excluding grid on both sides
199 // -1 -> Gitter nicht ueberschreiben
200 return Rectangle( aStartPos
, Size(nCellX
-1,nCellY
-1) );
203 //------------------------------------------------------------------------
205 ScEditAttrTester::ScEditAttrTester( ScEditEngineDefaulter
* pEng
) :
208 bNeedsObject( FALSE
),
209 bNeedsCellAttr( FALSE
)
211 if ( pEngine
->GetParagraphCount() > 1 )
213 bNeedsObject
= TRUE
; //! Zellatribute finden ?
217 const SfxPoolItem
* pItem
= NULL
;
218 pEditAttrs
= new SfxItemSet( pEngine
->GetAttribs(
219 ESelection(0,0,0,pEngine
->GetTextLen(0)), EditEngineAttribs_OnlyHard
) );
220 const SfxItemSet
& rEditDefaults
= pEngine
->GetDefaults();
222 for (USHORT nId
= EE_CHAR_START
; nId
<= EE_CHAR_END
&& !bNeedsObject
; nId
++)
224 SfxItemState eState
= pEditAttrs
->GetItemState( nId
, FALSE
, &pItem
);
225 if (eState
== SFX_ITEM_DONTCARE
)
227 else if (eState
== SFX_ITEM_SET
)
229 if ( nId
== EE_CHAR_ESCAPEMENT
|| nId
== EE_CHAR_PAIRKERNING
||
230 nId
== EE_CHAR_KERNING
|| nId
== EE_CHAR_XMLATTRIBS
)
232 // Escapement and kerning are kept in EditEngine because there are no
233 // corresponding cell format items. User defined attributes are kept in
234 // EditEngine because "user attributes applied to all the text" is different
235 // from "user attributes applied to the cell".
237 if ( *pItem
!= rEditDefaults
.Get(nId
) )
242 if ( *pItem
!= rEditDefaults
.Get(nId
) )
243 bNeedsCellAttr
= TRUE
;
244 // rEditDefaults contains the defaults from the cell format
248 // Feldbefehle enthalten?
250 SfxItemState eFieldState
= pEditAttrs
->GetItemState( EE_FEATURE_FIELD
, FALSE
);
251 if ( eFieldState
== SFX_ITEM_DONTCARE
|| eFieldState
== SFX_ITEM_SET
)
254 // not converted characters?
256 SfxItemState eConvState
= pEditAttrs
->GetItemState( EE_FEATURE_NOTCONV
, FALSE
);
257 if ( eConvState
== SFX_ITEM_DONTCARE
|| eConvState
== SFX_ITEM_SET
)
262 ScEditAttrTester::~ScEditAttrTester()
268 //------------------------------------------------------------------------
270 ScEnginePoolHelper::ScEnginePoolHelper( SfxItemPool
* pEnginePoolP
,
271 BOOL bDeleteEnginePoolP
)
273 pEnginePool( pEnginePoolP
),
275 bDeleteEnginePool( bDeleteEnginePoolP
),
276 bDeleteDefaults( FALSE
)
281 ScEnginePoolHelper::ScEnginePoolHelper( const ScEnginePoolHelper
& rOrg
)
283 pEnginePool( rOrg
.bDeleteEnginePool
? rOrg
.pEnginePool
->Clone() : rOrg
.pEnginePool
),
285 bDeleteEnginePool( rOrg
.bDeleteEnginePool
),
286 bDeleteDefaults( FALSE
)
291 ScEnginePoolHelper::~ScEnginePoolHelper()
293 if ( bDeleteDefaults
)
295 if ( bDeleteEnginePool
)
296 SfxItemPool::Free(pEnginePool
);
300 //------------------------------------------------------------------------
302 ScEditEngineDefaulter::ScEditEngineDefaulter( SfxItemPool
* pEnginePoolP
,
303 BOOL bDeleteEnginePoolP
)
305 ScEnginePoolHelper( pEnginePoolP
, bDeleteEnginePoolP
),
306 EditEngine( pEnginePoolP
)
308 // All EditEngines use ScGlobal::GetEditDefaultLanguage as DefaultLanguage.
309 // DefaultLanguage for InputHandler's EditEngine is updated later.
311 SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() );
315 ScEditEngineDefaulter::ScEditEngineDefaulter( const ScEditEngineDefaulter
& rOrg
)
317 ScEnginePoolHelper( rOrg
),
318 EditEngine( pEnginePool
)
320 SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() );
324 ScEditEngineDefaulter::~ScEditEngineDefaulter()
329 void ScEditEngineDefaulter::SetDefaults( const SfxItemSet
& rSet
, BOOL bRememberCopy
)
333 if ( bDeleteDefaults
)
335 pDefaults
= new SfxItemSet( rSet
);
336 bDeleteDefaults
= TRUE
;
338 const SfxItemSet
& rNewSet
= bRememberCopy
? *pDefaults
: rSet
;
339 BOOL bUndo
= IsUndoEnabled();
341 BOOL bUpdateMode
= GetUpdateMode();
343 SetUpdateMode( FALSE
);
344 USHORT nPara
= GetParagraphCount();
345 for ( USHORT j
=0; j
<nPara
; j
++ )
347 SetParaAttribs( j
, rNewSet
);
350 SetUpdateMode( TRUE
);
356 void ScEditEngineDefaulter::SetDefaults( SfxItemSet
* pSet
, BOOL bTakeOwnership
)
358 if ( bDeleteDefaults
)
361 bDeleteDefaults
= bTakeOwnership
;
363 SetDefaults( *pDefaults
, FALSE
);
367 void ScEditEngineDefaulter::SetDefaultItem( const SfxPoolItem
& rItem
)
371 pDefaults
= new SfxItemSet( GetEmptyItemSet() );
372 bDeleteDefaults
= TRUE
;
374 pDefaults
->Put( rItem
);
375 SetDefaults( *pDefaults
, FALSE
);
378 const SfxItemSet
& ScEditEngineDefaulter::GetDefaults()
382 pDefaults
= new SfxItemSet( GetEmptyItemSet() );
383 bDeleteDefaults
= TRUE
;
388 void ScEditEngineDefaulter::SetText( const EditTextObject
& rTextObject
)
390 BOOL bUpdateMode
= GetUpdateMode();
392 SetUpdateMode( FALSE
);
393 EditEngine::SetText( rTextObject
);
395 SetDefaults( *pDefaults
, FALSE
);
397 SetUpdateMode( TRUE
);
400 void ScEditEngineDefaulter::SetTextNewDefaults( const EditTextObject
& rTextObject
,
401 const SfxItemSet
& rSet
, BOOL bRememberCopy
)
403 BOOL bUpdateMode
= GetUpdateMode();
405 SetUpdateMode( FALSE
);
406 EditEngine::SetText( rTextObject
);
407 SetDefaults( rSet
, bRememberCopy
);
409 SetUpdateMode( TRUE
);
412 void ScEditEngineDefaulter::SetTextNewDefaults( const EditTextObject
& rTextObject
,
413 SfxItemSet
* pSet
, BOOL bTakeOwnership
)
415 BOOL bUpdateMode
= GetUpdateMode();
417 SetUpdateMode( FALSE
);
418 EditEngine::SetText( rTextObject
);
419 SetDefaults( pSet
, bTakeOwnership
);
421 SetUpdateMode( TRUE
);
425 void ScEditEngineDefaulter::SetText( const String
& rText
)
427 BOOL bUpdateMode
= GetUpdateMode();
429 SetUpdateMode( FALSE
);
430 EditEngine::SetText( rText
);
432 SetDefaults( *pDefaults
, FALSE
);
434 SetUpdateMode( TRUE
);
437 void ScEditEngineDefaulter::SetTextNewDefaults( const String
& rText
,
438 const SfxItemSet
& rSet
, BOOL bRememberCopy
)
440 BOOL bUpdateMode
= GetUpdateMode();
442 SetUpdateMode( FALSE
);
443 EditEngine::SetText( rText
);
444 SetDefaults( rSet
, bRememberCopy
);
446 SetUpdateMode( TRUE
);
449 void ScEditEngineDefaulter::SetTextNewDefaults( const String
& rText
,
450 SfxItemSet
* pSet
, BOOL bTakeOwnership
)
452 BOOL bUpdateMode
= GetUpdateMode();
454 SetUpdateMode( FALSE
);
455 EditEngine::SetText( rText
);
456 SetDefaults( pSet
, bTakeOwnership
);
458 SetUpdateMode( TRUE
);
461 void ScEditEngineDefaulter::RepeatDefaults()
465 USHORT nPara
= GetParagraphCount();
466 for ( USHORT j
=0; j
<nPara
; j
++ )
467 SetParaAttribs( j
, *pDefaults
);
471 void ScEditEngineDefaulter::RemoveParaAttribs()
473 SfxItemSet
* pCharItems
= NULL
;
474 BOOL bUpdateMode
= GetUpdateMode();
476 SetUpdateMode( FALSE
);
477 USHORT nParCount
= GetParagraphCount();
478 for (USHORT nPar
=0; nPar
<nParCount
; nPar
++)
480 const SfxItemSet
& rParaAttribs
= GetParaAttribs( nPar
);
482 for (nWhich
= EE_CHAR_START
; nWhich
<= EE_CHAR_END
; nWhich
++)
484 const SfxPoolItem
* pParaItem
;
485 if ( rParaAttribs
.GetItemState( nWhich
, FALSE
, &pParaItem
) == SFX_ITEM_SET
)
487 // if defaults are set, use only items that are different from default
488 if ( !pDefaults
|| *pParaItem
!= pDefaults
->Get(nWhich
) )
491 pCharItems
= new SfxItemSet( GetEmptyItemSet() );
492 pCharItems
->Put( *pParaItem
);
500 GetPortions( nPar
, aPortions
);
502 // loop through the portions of the paragraph, and set only those items
503 // that are not overridden by existing character attributes
505 USHORT nPCount
= aPortions
.Count();
507 for ( USHORT nPos
=0; nPos
<nPCount
; nPos
++ )
509 USHORT nEnd
= aPortions
.GetObject( nPos
);
510 ESelection
aSel( nPar
, nStart
, nPar
, nEnd
);
511 SfxItemSet aOldCharAttrs
= GetAttribs( aSel
);
512 SfxItemSet aNewCharAttrs
= *pCharItems
;
513 for (nWhich
= EE_CHAR_START
; nWhich
<= EE_CHAR_END
; nWhich
++)
515 // Clear those items that are different from existing character attributes.
516 // Where no character attributes are set, GetAttribs returns the paragraph attributes.
517 const SfxPoolItem
* pItem
;
518 if ( aNewCharAttrs
.GetItemState( nWhich
, FALSE
, &pItem
) == SFX_ITEM_SET
&&
519 *pItem
!= aOldCharAttrs
.Get(nWhich
) )
521 aNewCharAttrs
.ClearItem(nWhich
);
524 if ( aNewCharAttrs
.Count() )
525 QuickSetAttribs( aNewCharAttrs
, aSel
);
530 DELETEZ( pCharItems
);
533 if ( rParaAttribs
.Count() )
535 // clear all paragraph attributes (including defaults),
536 // so they are not contained in resulting EditTextObjects
538 SetParaAttribs( nPar
, SfxItemSet( *rParaAttribs
.GetPool(), rParaAttribs
.GetRanges() ) );
542 SetUpdateMode( TRUE
);
545 //------------------------------------------------------------------------
547 ScTabEditEngine::ScTabEditEngine( ScDocument
* pDoc
)
548 : ScEditEngineDefaulter( pDoc
->GetEnginePool() )
550 SetEditTextObjectPool( pDoc
->GetEditPool() );
551 Init((const ScPatternAttr
&)pDoc
->GetPool()->GetDefaultItem(ATTR_PATTERN
));
554 ScTabEditEngine::ScTabEditEngine( const ScPatternAttr
& rPattern
,
555 SfxItemPool
* pEnginePoolP
, SfxItemPool
* pTextObjectPool
)
556 : ScEditEngineDefaulter( pEnginePoolP
)
558 if ( pTextObjectPool
)
559 SetEditTextObjectPool( pTextObjectPool
);
563 void ScTabEditEngine::Init( const ScPatternAttr
& rPattern
)
565 SetRefMapMode(MAP_100TH_MM
);
566 SfxItemSet
* pEditDefaults
= new SfxItemSet( GetEmptyItemSet() );
567 rPattern
.FillEditItemSet( pEditDefaults
);
568 SetDefaults( pEditDefaults
);
569 // wir haben keine StyleSheets fuer Text
570 SetControlWord( GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS
);
573 //------------------------------------------------------------------------
574 // Feldbefehle fuer Kopf- und Fusszeilen
575 //------------------------------------------------------------------------
578 // Zahlen aus \sw\source\core\doc\numbers.cxx
581 String
lcl_GetCharStr( sal_Int32 nNo
)
583 DBG_ASSERT( nNo
, "0 ist eine ungueltige Nummer !!" );
586 const sal_Int32 coDiff
= 'Z' - 'A' +1;
590 nCalc
= nNo
% coDiff
;
593 aStr
.Insert( (sal_Unicode
)('a' - 1 + nCalc
), 0 );
594 nNo
= sal::static_int_cast
<sal_Int32
>( nNo
- nCalc
);
601 String
lcl_GetNumStr( sal_Int32 nNo
, SvxNumType eType
)
603 String
aTmpStr( '0' );
608 case SVX_CHARS_UPPER_LETTER
:
609 case SVX_CHARS_LOWER_LETTER
:
610 aTmpStr
= lcl_GetCharStr( nNo
);
613 case SVX_ROMAN_UPPER
:
614 case SVX_ROMAN_LOWER
:
616 aTmpStr
= SvxNumberFormat::CreateRomanString( nNo
, ( eType
== SVX_ROMAN_UPPER
) );
621 case SVX_NUMBER_NONE
:
628 // case ARABIC: ist jetzt default
630 aTmpStr
= String::CreateFromInt32( nNo
);
634 if( SVX_CHARS_UPPER_LETTER
== eType
)
635 aTmpStr
.ToUpperAscii();
640 ScHeaderFieldData::ScHeaderFieldData()
642 nPageNo
= nTotalPages
= 0;
643 eNumType
= SVX_ARABIC
;
646 ScHeaderEditEngine::ScHeaderEditEngine( SfxItemPool
* pEnginePoolP
, BOOL bDeleteEnginePoolP
)
647 : ScEditEngineDefaulter( pEnginePoolP
, bDeleteEnginePoolP
)
651 String __EXPORT
ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem
& rField
,
652 USHORT
/* nPara */, USHORT
/* nPos */,
653 Color
*& /* rTxtColor */, Color
*& /* rFldColor */ )
656 const SvxFieldData
* pFieldData
= rField
.GetField();
659 TypeId aType
= pFieldData
->Type();
660 if (aType
== TYPE(SvxPageField
))
661 aRet
= lcl_GetNumStr( aData
.nPageNo
,aData
.eNumType
);
662 else if (aType
== TYPE(SvxPagesField
))
663 aRet
= lcl_GetNumStr( aData
.nTotalPages
,aData
.eNumType
);
664 else if (aType
== TYPE(SvxTimeField
))
665 aRet
= ScGlobal::pLocaleData
->getTime(aData
.aTime
);
666 else if (aType
== TYPE(SvxFileField
))
668 else if (aType
== TYPE(SvxExtFileField
))
670 switch ( ((const SvxExtFileField
*)pFieldData
)->GetFormat() )
672 case SVXFILEFORMAT_FULLPATH
:
673 aRet
= aData
.aLongDocName
;
676 aRet
= aData
.aShortDocName
;
679 else if (aType
== TYPE(SvxTableField
))
680 aRet
= aData
.aTabName
;
681 else if (aType
== TYPE(SvxDateField
))
682 aRet
= ScGlobal::pLocaleData
->getDate(aData
.aDate
);
685 //DBG_ERROR("unbekannter Feldbefehl");
691 DBG_ERROR("FieldData ist 0");
698 //------------------------------------------------------------------------
702 //------------------------------------------------------------------------
704 ScFieldEditEngine::ScFieldEditEngine( SfxItemPool
* pEnginePoolP
,
705 SfxItemPool
* pTextObjectPool
, BOOL bDeleteEnginePoolP
)
707 ScEditEngineDefaulter( pEnginePoolP
, bDeleteEnginePoolP
),
710 if ( pTextObjectPool
)
711 SetEditTextObjectPool( pTextObjectPool
);
712 // EE_CNTRL_URLSFXEXECUTE nicht, weil die Edit-Engine den ViewFrame nicht kennt
713 // wir haben keine StyleSheets fuer Text
714 SetControlWord( (GetControlWord() | EE_CNTRL_MARKFIELDS
) & ~EE_CNTRL_RTFSTYLESHEETS
);
717 String __EXPORT
ScFieldEditEngine::CalcFieldValue( const SvxFieldItem
& rField
,
718 USHORT
/* nPara */, USHORT
/* nPos */,
719 Color
*& rTxtColor
, Color
*& /* rFldColor */ )
722 const SvxFieldData
* pFieldData
= rField
.GetField();
726 TypeId aType
= pFieldData
->Type();
728 if (aType
== TYPE(SvxURLField
))
730 String aURL
= ((const SvxURLField
*)pFieldData
)->GetURL();
732 switch ( ((const SvxURLField
*)pFieldData
)->GetFormat() )
734 case SVXURLFORMAT_APPDEFAULT
: //!!! einstellbar an App???
735 case SVXURLFORMAT_REPR
:
736 aRet
= ((const SvxURLField
*)pFieldData
)->GetRepresentation();
739 case SVXURLFORMAT_URL
:
744 svtools::ColorConfigEntry eEntry
=
745 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
746 rTxtColor
= new Color( SC_MOD()->GetColorConfig().GetColorValue(eEntry
).nColor
);
750 //DBG_ERROR("unbekannter Feldbefehl");
755 if (!aRet
.Len()) // leer ist baeh
756 aRet
= ' '; // Space ist Default der Editengine
761 void __EXPORT
ScFieldEditEngine::FieldClicked( const SvxFieldItem
& rField
, USHORT
, USHORT
)
763 const SvxFieldData
* pFld
= rField
.GetField();
765 if ( pFld
&& pFld
->ISA( SvxURLField
) && bExecuteURL
)
767 const SvxURLField
* pURLField
= (const SvxURLField
*) pFld
;
768 ScGlobal::OpenURL( pURLField
->GetURL(), pURLField
->GetTargetFrame() );
772 //------------------------------------------------------------------------
774 ScNoteEditEngine::ScNoteEditEngine( SfxItemPool
* pEnginePoolP
,
775 SfxItemPool
* pTextObjectPool
, BOOL bDeleteEnginePoolP
) :
776 ScEditEngineDefaulter( pEnginePoolP
, bDeleteEnginePoolP
)
778 if ( pTextObjectPool
)
779 SetEditTextObjectPool( pTextObjectPool
);
780 SetControlWord( (GetControlWord() | EE_CNTRL_MARKFIELDS
) & ~EE_CNTRL_RTFSTYLESHEETS
);