summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-27 22:38:22 +0100
committerEike Rathke <erack@redhat.com>2011-11-28 15:25:27 +0100
commitcdbcb1a0d9281a7a96bcdb6b271e387f5e06813f (patch)
tree24c99afbd4a03be01ed65acd7f66a4dcdc4d0b80 /sc
parentf65345b11259c431e715d7f4f17d2ec035cd23d8 (diff)
dr78: #i51508# use the correct MapMode for EditEngine when formatting for screen
# HG changeset patch # User Niklas Nebel <nn@openoffice.org> # Date 1291314860 -3600 # Node ID c2bc2890eae42a85c3f16085f9d7867799554839 # Parent 96608d83032e60946c80e0a5185a55843b74eb6f
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/source/core/data/column2.cxx27
-rw-r--r--sc/source/core/data/documen2.cxx12
-rw-r--r--sc/source/core/data/documen9.cxx7
-rw-r--r--sc/source/ui/app/inputhdl.cxx11
-rw-r--r--sc/source/ui/inc/output.hxx3
-rw-r--r--sc/source/ui/view/output2.cxx62
-rw-r--r--sc/source/ui/view/printfun.cxx6
8 files changed, 77 insertions, 53 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 684b16622071..ad4ea74cadfd 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -121,6 +121,7 @@ class ScViewOptions;
class ScStrCollection;
class TypedScStrCollection;
class ScChangeTrack;
+class ScEditEngineDefaulter;
class ScFieldEditEngine;
class ScNoteEditEngine;
struct ScConsolidateParam;
@@ -1583,6 +1584,7 @@ public:
bool GetAsianKerning() const;
bool IsValidAsianKerning() const;
void SetAsianKerning(bool bNew);
+ void ApplyAsianEditSettings(ScEditEngineDefaulter& rEngine);
sal_uInt8 GetEditTextDirection(SCTAB nTab) const; // EEHorizontalTextDirection values
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f30688a7695c..22d3da4ba709 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -338,12 +338,17 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev,
ScFieldEditEngine* pEngine = pDocument->CreateFieldEditEngine();
pEngine->SetUpdateMode( false );
+ bool bTextWysiwyg = ( pDev->GetOutDevType() == OUTDEV_PRINTER );
+ sal_uLong nCtrl = pEngine->GetControlWord();
+ if ( bTextWysiwyg )
+ nCtrl |= EE_CNTRL_FORMAT100;
+ else
+ nCtrl &= ~EE_CNTRL_FORMAT100;
+ pEngine->SetControlWord( nCtrl );
MapMode aOld = pDev->GetMapMode();
pDev->SetMapMode( aHMMMode );
pEngine->SetRefDevice( pDev );
- pEngine->SetForbiddenCharsTable( pDocument->GetForbiddenCharacters() );
- pEngine->SetAsianCompressionMode( pDocument->GetAsianCompression() );
- pEngine->SetKernAsianPunctuation( pDocument->GetAsianKerning() );
+ pDocument->ApplyAsianEditSettings( *pEngine );
SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
pPattern->FillEditItemSet( pSet, pCondSet );
@@ -362,7 +367,6 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev,
else if (bBreak)
{
double fWidthFactor = nPPTX;
- bool bTextWysiwyg = ( pDev->GetOutDevType() == OUTDEV_PRINTER );
if ( bTextWysiwyg )
{
// if text is formatted for printer, don't use PixelToLogic,
@@ -475,6 +479,17 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev,
{
nValue = pDev->LogicToPixel(Size( 0, pEngine->GetTextHeight() ),
aHMMMode).Height();
+
+ // With non-100% zoom and several lines or paragraphs, don't shrink below the result with FORMAT100 set
+ if ( !bTextWysiwyg && ( rZoomY.GetNumerator() != 1 || rZoomY.GetDenominator() != 1 ) &&
+ ( pEngine->GetParagraphCount() > 1 || ( bBreak && pEngine->GetLineCount(0) > 1 ) ) )
+ {
+ pEngine->SetControlWord( nCtrl | EE_CNTRL_FORMAT100 );
+ pEngine->QuickFormatDoc( sal_True );
+ long nSecondValue = pDev->LogicToPixel(Size( 0, pEngine->GetTextHeight() ), aHMMMode).Height();
+ if ( nSecondValue > nValue )
+ nValue = nSecondValue;
+ }
}
if ( nValue && bAddMargin )
@@ -953,9 +968,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow )
pEngine = new ScFieldEditEngine( pDocument->GetEditPool() );
// EE_CNTRL_ONLINESPELLING falls schon Fehler drin sind
pEngine->SetControlWord( pEngine->GetControlWord() | EE_CNTRL_ONLINESPELLING );
- pEngine->SetForbiddenCharsTable( pDocument->GetForbiddenCharacters() );
- pEngine->SetAsianCompressionMode( pDocument->GetAsianCompression() );
- pEngine->SetKernAsianPunctuation( pDocument->GetAsianKerning() );
+ pDocument->ApplyAsianEditSettings( *pEngine );
}
pEngine->SetText( *pData );
sal_uInt16 nParCount = pEngine->GetParagraphCount();
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 641afcf89bb8..94893dc2f410 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -522,7 +522,7 @@ ScFieldEditEngine& ScDocument::GetEditEngine()
pEditEngine->SetUpdateMode( false );
pEditEngine->EnableUndo( false );
pEditEngine->SetRefMapMode( MAP_100TH_MM );
- pEditEngine->SetForbiddenCharsTable( xForbiddenCharacters );
+ ApplyAsianEditSettings( *pEditEngine );
}
return *pEditEngine;
}
@@ -535,11 +535,11 @@ ScNoteEditEngine& ScDocument::GetNoteEngine()
pNoteEngine->SetUpdateMode( false );
pNoteEngine->EnableUndo( false );
pNoteEngine->SetRefMapMode( MAP_100TH_MM );
- pNoteEngine->SetForbiddenCharsTable( xForbiddenCharacters );
- const SfxItemSet& rItemSet = GetDefPattern()->GetItemSet();
- SfxItemSet* pEEItemSet = new SfxItemSet( pNoteEngine->GetEmptyItemSet() );
- ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
- pNoteEngine->SetDefaults( pEEItemSet ); // edit engine takes ownership
+ ApplyAsianEditSettings( *pNoteEngine );
+ const SfxItemSet& rItemSet = GetDefPattern()->GetItemSet();
+ SfxItemSet* pEEItemSet = new SfxItemSet( pNoteEngine->GetEmptyItemSet() );
+ ScPatternAttr::FillToEditItemSet( *pEEItemSet, rItemSet );
+ pNoteEngine->SetDefaults( pEEItemSet ); // edit engine takes ownership
}
return *pNoteEngine;
}
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 97f1f2b225f8..bb374343d7ff 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -698,4 +698,11 @@ void ScDocument::SetAsianKerning(bool bNew)
pDrawLayer->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
}
+void ScDocument::ApplyAsianEditSettings( ScEditEngineDefaulter& rEngine )
+{
+ rEngine.SetForbiddenCharsTable( xForbiddenCharacters );
+ rEngine.SetAsianCompressionMode( GetAsianCompression() );
+ rEngine.SetKernAsianPunctuation( GetAsianKerning() );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 61aa7d97c232..e8575514daae 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -514,6 +514,13 @@ void ScInputHandler::UpdateRefDevice()
return;
sal_Bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
+ bool bInPlace = pActiveViewSh && pActiveViewSh->GetViewFrame()->GetFrame().IsInPlace();
+ sal_uLong nCtrl = pEngine->GetControlWord();
+ if ( bTextWysiwyg || bInPlace )
+ nCtrl |= EE_CNTRL_FORMAT100; // EditEngine default: always format for 100%
+ else
+ nCtrl &= ~EE_CNTRL_FORMAT100; // when formatting for screen, use the actual MapMode
+ pEngine->SetControlWord( nCtrl );
if ( bTextWysiwyg && pActiveViewSh )
pEngine->SetRefDevice( pActiveViewSh->GetViewData()->GetDocument()->GetPrinter() );
else
@@ -601,9 +608,7 @@ void ScInputHandler::UpdateSpellSettings( sal_Bool bFromStartTab )
pEngine->SetControlWord(nCntrl);
ScDocument* pDoc = pViewData->GetDocument();
- pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
- pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
- pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
+ pDoc->ApplyAsianEditSettings( *pEngine );
pEngine->SetDefaultHorizontalTextDirection(
(EEHorizontalTextDirection)pDoc->GetEditTextDirection( pViewData->GetTabNo() ) );
pEngine->SetFirstWordCapitalization( false );
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index d8c9f24731e7..72934cfb41ed 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -51,6 +51,7 @@ struct ScTableInfo;
class ScTabViewShell;
class ScPageBreakData;
class FmFormView;
+class ScFieldEditEngine;
// #i74769# SdrPaintWindow predefine
class SdrPaintWindow;
@@ -256,6 +257,8 @@ private:
void DrawEditStacked(DrawEditParam& rParam);
void DrawEditAsianVertical(DrawEditParam& rParam);
+ ScFieldEditEngine* CreateOutputEditEngine();
+
public:
ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
ScTableInfo& rTabInfo, ScDocument* pNewDoc,
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 0e8a5f108238..5f1e109bf516 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1923,6 +1923,26 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
// -------------------------------------------------------------------------------
+ScFieldEditEngine* ScOutputData::CreateOutputEditEngine()
+{
+ ScFieldEditEngine* pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() );
+ pEngine->SetUpdateMode( false );
+ // a RefDevice always has to be set, otherwise EditEngine would create a VirtualDevice
+ pEngine->SetRefDevice( pFmtDevice );
+ sal_uLong nCtrl = pEngine->GetControlWord();
+ if ( bShowSpellErrors )
+ nCtrl |= EE_CNTRL_ONLINESPELLING;
+ if ( eType == OUTTYPE_PRINTER )
+ nCtrl &= ~EE_CNTRL_MARKFIELDS;
+ if ( eType == OUTTYPE_WINDOW && pRefDevice == pFmtDevice )
+ nCtrl &= ~EE_CNTRL_FORMAT100; // use the actual MapMode
+ pEngine->SetControlWord( nCtrl );
+ pDoc->ApplyAsianEditSettings( *pEngine );
+ pEngine->EnableAutoColor( bUseStyleColor );
+ pEngine->SetDefaultHorizontalTextDirection( (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
+ return pEngine;
+}
+
void lcl_ClearEdit( EditEngine& rEngine ) // Text und Attribute
{
rEngine.SetUpdateMode( false );
@@ -4440,38 +4460,6 @@ void ScOutputData::DrawEditAsianVertical(DrawEditParam& rParam)
rParam.adjustForHyperlinkInPDF(aURLStart, pDev);
}
-namespace {
-
-void initEditEngine(
- ScFieldEditEngine*& pEngine, ScDocument* pDoc, SCTAB nTab, OutputDevice* pFmtDevice,
- ScOutputType eType, bool bShowSpellErrors, bool bUseStyleColor)
-{
- if (!pEngine)
- {
- // Ein RefDevice muss auf jeden Fall gesetzt werden,
- // sonst legt sich die EditEngine ein VirtualDevice an!
- pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() );
- pEngine->SetUpdateMode( false );
- pEngine->SetRefDevice( pFmtDevice ); // always set
- sal_uLong nCtrl = pEngine->GetControlWord();
- if ( bShowSpellErrors )
- nCtrl |= EE_CNTRL_ONLINESPELLING;
- if ( eType == OUTTYPE_PRINTER )
- nCtrl &= ~EE_CNTRL_MARKFIELDS;
- pEngine->SetControlWord( nCtrl );
- pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
- pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
- pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
- pEngine->EnableAutoColor( bUseStyleColor );
- pEngine->SetDefaultHorizontalTextDirection(
- (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
- }
- else
- lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(sal_False)
-}
-
-}
-
void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
{
ScFieldEditEngine* pEngine = NULL;
@@ -4577,7 +4565,10 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
}
if (bDoCell)
{
- initEditEngine(pEngine, pDoc, nTab, pFmtDevice, eType, bShowSpellErrors, bUseStyleColor);
+ if (!pEngine)
+ pEngine = CreateOutputEditEngine();
+ else
+ lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(sal_False)
DrawEditParam aParam(pPattern, pCondSet, lcl_SafeIsValue(pCell));
aParam.mbPixelToLogic = bPixelToLogic;
@@ -4692,7 +4683,10 @@ void ScOutputData::DrawRotated(sal_Bool bPixelToLogic)
if (!bHidden)
{
- initEditEngine(pEngine, pDoc, nTab, pFmtDevice, eType, bShowSpellErrors, bUseStyleColor);
+ if (!pEngine)
+ pEngine = CreateOutputEditEngine();
+ else
+ lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(sal_False)
long nPosY = nRowPosY;
sal_Bool bVisChanged = false;
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 48d95153cfe1..c844fd951951 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1671,6 +1671,7 @@ void ScPrintFunc::MakeEditEngine()
pEditEngine->SetWordDelimiters(
ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS );
+ pDoc->ApplyAsianEditSettings( *pEditEngine );
pEditEngine->EnableAutoColor( bUseStyleColor );
// Default-Set fuer Ausrichtung
@@ -2357,9 +2358,8 @@ void ScPrintFunc::SetExclusivelyDrawOleAndDrawObjects()
aTableParam.bNotes = false;
aTableParam.bGrid = false;
aTableParam.bHeaders = false;
- aTableParam.bFormulas = false;;
- aTableParam.bNullVals = false;;
- aTableParam.bNullVals = false;;
+ aTableParam.bFormulas = false;
+ aTableParam.bNullVals = false;
}
//