[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Thu Oct 28 18:45:49 PDT 2010
sc/source/ui/app/inputhdl.cxx | 273 +++++++++++++++++++++---------------------
sc/source/ui/inc/inputhdl.hxx | 14 +-
2 files changed, 148 insertions(+), 139 deletions(-)
New commits:
commit 5d5738ac9cc7e73f40dcb6a6888e32a496dc283b
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Thu Oct 28 21:25:40 2010 -0400
Allow activation of cell even when the document is read-only.
This behavior is very handy when checking for referenced cells
visually by pressing F2. No cell content modification is allowed
of course. (n#647982)
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 8b202e0..d50a581 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -652,7 +652,7 @@ void ScInputHandler::GetFormulaData()
// MRU-Funktionen aus dem Funktions-Autopiloten
// wie in ScPosWnd::FillFunctions (inputwin.cxx)
-
+
const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
USHORT nMRUCount = rOpt.GetLRUFuncListCount();
const USHORT* pMRUList = rOpt.GetLRUFuncList();
@@ -899,7 +899,7 @@ void ScInputHandler::ShowTipCursor()
ShowTipBelow( aNew );
bFound = TRUE;
}
- else
+ else
break;
}
else
@@ -1051,7 +1051,7 @@ void ScInputHandler::UseFormulaData()
{
nCountSemicolon = aNew.GetTokenCount(cSep)-1;
nCountDot = aNew.GetTokenCount(cSheetSep)-1;
-
+
if( !nCountSemicolon )
{
for( USHORT i = 0; i < aNew.Len(); i++ )
@@ -1831,167 +1831,177 @@ void ScInputHandler::RemoveRangeFinder()
DeleteRangeFinder(); // loescht die Liste und die Markierungen auf der Tabelle
}
-BOOL ScInputHandler::StartTable( sal_Unicode cTyped, BOOL bFromCommand )
+bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated )
{
- // returns TRUE if a new edit mode was started
+ bool bNewTable = false;
- BOOL bNewTable = FALSE;
+ if (bModified || !ValidCol(aCursorPos.Col()))
+ return false;
- if (!bModified && ValidCol(aCursorPos.Col()))
+ if (pActiveViewSh)
{
- if (pActiveViewSh)
- {
- ImplCreateEditEngine();
- UpdateActiveView();
- SyncViews();
+ ImplCreateEditEngine();
+ UpdateActiveView();
+ SyncViews();
- ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
- const ScMarkData& rMark = pActiveViewSh->GetViewData()->GetMarkData();
- ScEditableTester aTester;
- if ( rMark.IsMarked() || rMark.IsMultiMarked() )
- aTester.TestSelection( pDoc, rMark );
- else
- aTester.TestSelectedBlock( pDoc, aCursorPos.Col(),aCursorPos.Row(),
- aCursorPos.Col(),aCursorPos.Row(), rMark );
- if ( aTester.IsEditable() )
- {
- // UpdateMode is enabled again in ScViewData::SetEditEngine (and not needed otherwise)
- pEngine->SetUpdateMode( FALSE );
+ const ScMarkData& rMark = pActiveViewSh->GetViewData()->GetMarkData();
+ ScEditableTester aTester;
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ aTester.TestSelection( pDoc, rMark );
+ else
+ aTester.TestSelectedBlock(
+ pDoc, aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Col(), aCursorPos.Row(), rMark );
- // Attribute in EditEngine uebernehmen
+ bool bStartInputMode = true;
- const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(),
- aCursorPos.Row(),
- aCursorPos.Tab() );
- if (pPattern != pLastPattern)
+ if (!aTester.IsEditable())
+ {
+ bProtected = TRUE;
+ // We allow read-only input mode activation when explicit cell
+ // activation is requested (double-click or F2) and if it's not
+ // part of an array.
+ bool bShowError = !bInputActivated || aTester.GetMessageId() != STR_PROTECTIONERR;
+ if (bShowError)
+ {
+ eMode = SC_INPUT_NONE;
+ StopInputWinEngine( TRUE );
+ UpdateFormulaMode();
+ if ( pActiveViewSh && ( !bFromCommand || !bCommandErrorShown ) )
{
- // Prozent-Format?
-
- const SfxItemSet& rAttrSet = pPattern->GetItemSet();
- const SfxPoolItem* pItem;
+ // #97673# Prevent repeated error messages for the same cell from command events
+ // (for keyboard events, multiple messages are wanted).
+ // Set the flag before showing the error message because the command handler
+ // for the next IME command may be called when showing the dialog.
+ if ( bFromCommand )
+ bCommandErrorShown = TRUE;
- if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, TRUE, &pItem ) )
- {
- ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
- bCellHasPercentFormat = ( NUMBERFORMAT_PERCENT ==
- pDoc->GetFormatTable()->GetType( nFormat ) );
- }
- else
- bCellHasPercentFormat = FALSE; // Default: kein Prozent
+ pActiveViewSh->GetActiveWin()->GrabFocus();
+ pActiveViewSh->ErrorMessage(aTester.GetMessageId());
+ }
+ bStartInputMode = false;
+ }
+ }
- // Gueltigkeit angegeben?
+ if (bStartInputMode)
+ {
+ // UpdateMode is enabled again in ScViewData::SetEditEngine (and not needed otherwise)
+ pEngine->SetUpdateMode( FALSE );
- if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALIDDATA, TRUE, &pItem ) )
- nValidation = ((const SfxUInt32Item*)pItem)->GetValue();
- else
- nValidation = 0;
+ // Attribute in EditEngine uebernehmen
- // EditEngine Defaults
+ const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(),
+ aCursorPos.Row(),
+ aCursorPos.Tab() );
+ if (pPattern != pLastPattern)
+ {
+ // Prozent-Format?
- // Hier auf keinen Fall SetParaAttribs, weil die EditEngine evtl.
- // schon gefuellt ist (bei Edit-Zellen).
- // SetParaAttribs wuerde dann den Inhalt aendern
+ const SfxItemSet& rAttrSet = pPattern->GetItemSet();
+ const SfxPoolItem* pItem;
- //! ER 30.08.00 The SetDefaults is now (since MUST/src602
- //! EditEngine changes) implemented as a SetParaAttribs.
- //! Any problems?
+ if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, TRUE, &pItem ) )
+ {
+ ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ bCellHasPercentFormat = ( NUMBERFORMAT_PERCENT ==
+ pDoc->GetFormatTable()->GetType( nFormat ) );
+ }
+ else
+ bCellHasPercentFormat = FALSE; // Default: kein Prozent
- pPattern->FillEditItemSet( pEditDefaults );
- pEngine->SetDefaults( *pEditDefaults );
- pLastPattern = pPattern;
- bLastIsSymbol = pPattern->IsSymbolFont();
+ // Gueltigkeit angegeben?
- // Background color must be known for automatic font color.
- // For transparent cell background, the document background color must be used.
+ if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALIDDATA, TRUE, &pItem ) )
+ nValidation = ((const SfxUInt32Item*)pItem)->GetValue();
+ else
+ nValidation = 0;
- Color aBackCol = ((const SvxBrushItem&)
- pPattern->GetItem( ATTR_BACKGROUND )).GetColor();
- ScModule* pScMod = SC_MOD();
- // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
- if ( aBackCol.GetTransparency() > 0 ||
- Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
- aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
- pEngine->SetBackgroundColor( aBackCol );
+ // EditEngine Defaults
- // Ausrichtung
+ // Hier auf keinen Fall SetParaAttribs, weil die EditEngine evtl.
+ // schon gefuellt ist (bei Edit-Zellen).
+ // SetParaAttribs wuerde dann den Inhalt aendern
- eAttrAdjust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
- GetItem(ATTR_HOR_JUSTIFY)).GetValue();
- if ( eAttrAdjust == SVX_HOR_JUSTIFY_REPEAT &&
- static_cast<const SfxBoolItem&>(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() )
- {
- // #i31843# "repeat" with "line breaks" is treated as default alignment
- eAttrAdjust = SVX_HOR_JUSTIFY_STANDARD;
- }
- }
+ //! ER 30.08.00 The SetDefaults is now (since MUST/src602
+ //! EditEngine changes) implemented as a SetParaAttribs.
+ //! Any problems?
- // UpdateSpellSettings enables online spelling if needed
- // -> also call if attributes are unchanged
+ pPattern->FillEditItemSet( pEditDefaults );
+ pEngine->SetDefaults( *pEditDefaults );
+ pLastPattern = pPattern;
+ bLastIsSymbol = pPattern->IsSymbolFont();
- UpdateSpellSettings( TRUE ); // uses pLastPattern
+ // Background color must be known for automatic font color.
+ // For transparent cell background, the document background color must be used.
- // Edit-Engine fuellen
+ Color aBackCol = ((const SvxBrushItem&)
+ pPattern->GetItem( ATTR_BACKGROUND )).GetColor();
+ ScModule* pScMod = SC_MOD();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ if ( aBackCol.GetTransparency() > 0 ||
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+ pEngine->SetBackgroundColor( aBackCol );
- String aStr;
- if (bTextValid)
- {
- pEngine->SetText(aCurrentText);
- aStr = aCurrentText;
- bTextValid = FALSE;
- aCurrentText.Erase();
- }
- else
- aStr = GetEditText(pEngine);
+ // Ausrichtung
- if (aStr.Len() > 3 && // Matrix-Formel ?
- aStr.GetChar(0) == '{' &&
- aStr.GetChar(1) == '=' &&
- aStr.GetChar(aStr.Len()-1) == '}')
+ eAttrAdjust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
+ GetItem(ATTR_HOR_JUSTIFY)).GetValue();
+ if ( eAttrAdjust == SVX_HOR_JUSTIFY_REPEAT &&
+ static_cast<const SfxBoolItem&>(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() )
{
- aStr.Erase(0,1);
- aStr.Erase(aStr.Len()-1,1);
- pEngine->SetText(aStr);
- if ( pInputWin )
- pInputWin->SetTextString(aStr);
+ // #i31843# "repeat" with "line breaks" is treated as default alignment
+ eAttrAdjust = SVX_HOR_JUSTIFY_STANDARD;
}
+ }
- UpdateAdjust( cTyped );
+ // UpdateSpellSettings enables online spelling if needed
+ // -> also call if attributes are unchanged
- if ( bAutoComplete )
- GetColData();
+ UpdateSpellSettings( TRUE ); // uses pLastPattern
- if ( ( aStr.GetChar(0) == '=' || aStr.GetChar(0) == '+' || aStr.GetChar(0) == '-' ) &&
- !cTyped && !bCreatingFuncView )
- InitRangeFinder(aStr); // Formel wird editiert -> RangeFinder
+ // Edit-Engine fuellen
- bNewTable = TRUE; // -> PostEditView-Aufruf
+ String aStr;
+ if (bTextValid)
+ {
+ pEngine->SetText(aCurrentText);
+ aStr = aCurrentText;
+ bTextValid = FALSE;
+ aCurrentText.Erase();
}
else
- {
- bProtected = TRUE;
- eMode = SC_INPUT_NONE;
- StopInputWinEngine( TRUE );
- UpdateFormulaMode();
- if ( pActiveViewSh && ( !bFromCommand || !bCommandErrorShown ) )
- {
- // #97673# Prevent repeated error messages for the same cell from command events
- // (for keyboard events, multiple messages are wanted).
- // Set the flag before showing the error message because the command handler
- // for the next IME command may be called when showing the dialog.
- if ( bFromCommand )
- bCommandErrorShown = TRUE;
+ aStr = GetEditText(pEngine);
- pActiveViewSh->GetActiveWin()->GrabFocus();
- pActiveViewSh->ErrorMessage(aTester.GetMessageId());
- }
+ if (aStr.Len() > 3 && // Matrix-Formel ?
+ aStr.GetChar(0) == '{' &&
+ aStr.GetChar(1) == '=' &&
+ aStr.GetChar(aStr.Len()-1) == '}')
+ {
+ aStr.Erase(0,1);
+ aStr.Erase(aStr.Len()-1,1);
+ pEngine->SetText(aStr);
+ if ( pInputWin )
+ pInputWin->SetTextString(aStr);
}
- }
- if (!bProtected && pInputWin)
- pInputWin->SetOkCancelMode();
+ UpdateAdjust( cTyped );
+
+ if ( bAutoComplete )
+ GetColData();
+
+ if ( ( aStr.GetChar(0) == '=' || aStr.GetChar(0) == '+' || aStr.GetChar(0) == '-' ) &&
+ !cTyped && !bCreatingFuncView )
+ InitRangeFinder(aStr); // Formel wird editiert -> RangeFinder
+
+ bNewTable = true; // -> PostEditView-Aufruf
+ }
}
+ if (!bProtected && pInputWin)
+ pInputWin->SetOkCancelMode();
+
return bNewTable;
}
@@ -2065,7 +2075,7 @@ BOOL ScInputHandler::DataChanging( sal_Unicode cTyped, BOOL bFromCommand ) // r
bInOwnChange = TRUE; // disable ModifyHdl (reset in DataChanged)
if ( eMode == SC_INPUT_NONE )
- return StartTable( cTyped, bFromCommand );
+ return StartTable( cTyped, bFromCommand, false );
else
return FALSE;
}
@@ -2261,7 +2271,6 @@ void ScInputHandler::InvalidateAttribs()
}
}
-
//
// --------------- public Methoden --------------------------------------------
//
@@ -2297,7 +2306,7 @@ void ScInputHandler::SetMode( ScInputMode eNewMode )
{
if (eOldMode == SC_INPUT_NONE) // not when switching between modes
{
- if (StartTable(0, FALSE)) // 0 = look at existing document content for text or number
+ if (StartTable(0, false, eMode == SC_INPUT_TABLE))
{
if (pActiveViewSh)
pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
@@ -3661,7 +3670,6 @@ BOOL ScInputHandler::GetTextAndFields( ScEditEngineDefaulter& rDestEngine )
return bRet;
}
-
//------------------------------------------------------------------------
// Methoden fuer FunktionsAutopiloten:
// InputGetSelection, InputSetSelection, InputReplaceSelection, InputGetFormulaStr
@@ -3817,7 +3825,4 @@ ScInputHdlState& ScInputHdlState::operator=( const ScInputHdlState& r )
return *this;
}
-
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 33a2982..d3a30b0 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -2,7 +2,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -126,7 +126,14 @@ private:
private:
void UpdateActiveView();
void SyncViews( EditView* pSourceView = NULL );
- BOOL StartTable( sal_Unicode cTyped, BOOL bFromCommand );
+ /**
+ * @param cTyped typed character. If 0, look at existing document content
+ * for text or number.
+ * @param bInputActivated true if the cell input mode is activated (via
+ * F2), false otherwise.
+ * @return true if the new edit mode has been started.
+ */
+ bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated );
void RemoveSelection();
void UpdateFormulaMode();
void InvalidateAttribs();
@@ -188,7 +195,6 @@ public:
void ViewShellGone(ScTabViewShell* pViewSh);
void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
-
void NotifyChange( const ScInputHdlState* pState, BOOL bForce = FALSE,
ScTabViewShell* pSourceSh = NULL,
BOOL bStopEditing = TRUE);
@@ -290,8 +296,6 @@ private:
EditTextObject* pEditData;
};
-
-
#endif
More information about the Libreoffice-commits
mailing list