summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-08-29 17:15:33 +0100
committerNoel Power <noel.power@suse.com>2013-08-29 21:42:05 +0100
commitbcc51fb2ebdf77a1cc089857775fd742085b45b6 (patch)
treea828e81a8c283a99d991f695178c0db686b10f86 /sc
parent9d7c5dcf448fed668cc772d3cffa31712b1834a3 (diff)
add support for in-place style preview
selecting a style in the styles dialog ( without double clicking ) will apply the style to the currently selected cell(s) You can with the keys navigate to other styles and they in turn will also be applied. Preview will end when you click back onto the document. *FIXME* - the styles dialog isn't really suitable for previewing, a new dialog ( possibly in the toolbar ) might be nicer ( see Excel ) *FIXME* - when there is a multiple selection the highlight colour (applied as a transparent overlay) is most annoying ( and is mixed with any background colour applied if part of a style ) see ( ScGridWindow::UpdateSelectionOverlay() ) However my puny attempts to make the selection use a transparent colour made all the borders of the selected cells dissappear. I guess maybe a box/border around each selected cell ( or group of cells ) would also work but I didn't try that Change-Id: I0950e79085ffb75f60ee961835665df0c230172f
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx9
-rw-r--r--sc/sdi/formatsh.sdi2
-rw-r--r--sc/source/core/data/column2.cxx24
-rw-r--r--sc/source/core/data/documen2.cxx27
-rw-r--r--sc/source/core/data/documen8.cxx29
-rw-r--r--sc/source/core/data/fillinfo.cxx26
-rw-r--r--sc/source/ui/inc/output.hxx2
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx8
-rw-r--r--sc/source/ui/view/formatsh.cxx63
-rw-r--r--sc/source/ui/view/gridwin4.cxx3
-rw-r--r--sc/source/ui/view/output2.cxx29
11 files changed, 189 insertions, 33 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ab84d4c10b06..9c307f59e81e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -46,6 +46,7 @@
#include <vector>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
+#include "markdata.hxx"
namespace editeng { class SvxBorderLine; }
namespace sc {
@@ -306,7 +307,8 @@ private:
ScLookupCacheMapImpl* pLookupCacheMapImpl; // cache for lookups like VLOOKUP and MATCH
SfxItemSet* pPreviewFont; // convert to std::auto_ptr or whatever
- ScMarkData* pPreviewSelection;
+ ScStyleSheet* pPreviewCellStyle;
+ ScMarkData maPreviewSelection;
sal_Int64 nUnoObjectId; // counted up for UNO objects
sal_uInt32 nRangeOverflowType; // used in (xml) loading for overflow warnings
@@ -967,8 +969,11 @@ public:
void SetPreviewFont( SfxItemSet* pFontSet );
SfxItemSet* GetPreviewFont() { return pPreviewFont; }
SfxItemSet* GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab );
- const ScMarkData& GetPreviewSelection();
+ const ScMarkData GetPreviewSelection();
void SetPreviewSelection( ScMarkData& rSel );
+ ScStyleSheet* GetPreviewCellStyle() { return pPreviewCellStyle; }
+ ScStyleSheet* GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ void SetPreviewCellStyle( ScStyleSheet* pStyle ) { pPreviewCellStyle = pStyle; }
SC_DLLPUBLIC void SetAutoNameCache( ScAutoNameCache* pCache );
/** Creates a ScLookupCache cache for the range if it
diff --git a/sc/sdi/formatsh.sdi b/sc/sdi/formatsh.sdi
index bbdf09942170..693813302c17 100644
--- a/sc/sdi/formatsh.sdi
+++ b/sc/sdi/formatsh.sdi
@@ -62,6 +62,8 @@ interface FormatForSelection
SID_STYLE_DELETE [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ]
SID_STYLE_HIDE [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ]
SID_STYLE_SHOW [ ExecMethod = ExecuteStyle; StateMethod = GetStyleState; ]
+ SID_STYLE_PREVIEW [ ExecMethod = ExecuteStyle; ]
+ SID_STYLE_END_PREVIEW [ ExecMethod = ExecuteStyle; ]
// } Slot's die in der DrawShell disabled werden.
SID_ATTR_ALIGN_HOR_JUSTIFY [ ExecMethod = ExecuteAlignment; StateMethod = GetAttrState; ]
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index b22b477c8e29..9edca5f0dafb 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -349,8 +349,18 @@ long ScColumn::GetNeededSize(
pEngine->SetRefDevice( pDev );
pDocument->ApplyAsianEditSettings( *pEngine );
SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
- pPattern->FillEditItemSet( pSet, pCondSet );
-
+ if ( ScStyleSheet* pPreviewStyle = pDocument->GetPreviewCellStyle( nCol, nRow, nTab ) )
+ {
+ ScPatternAttr* pPreviewPattern = new ScPatternAttr( *pPattern );
+ pPreviewPattern->SetStyleSheet(pPreviewStyle);
+ pPreviewPattern->FillEditItemSet( pSet, pCondSet );
+ delete pPreviewPattern;
+ }
+ else
+ {
+ SfxItemSet* pFontSet = pDocument->GetPreviewFont( nCol, nRow, nTab );
+ pPattern->FillEditItemSet( pSet, pFontSet ? pFontSet : pCondSet );
+ }
// no longer needed, are setted with the text (is faster)
// pEngine->SetDefaults( pSet );
@@ -757,8 +767,18 @@ void ScColumn::GetOptimalHeight(
// with conditional formatting, always consider the individual cells
const ScPatternAttr* pPattern = aIter.Next(nStart,nEnd);
+ ::boost::ptr_vector<ScPatternAttr> aAltPatterns;
while ( pPattern )
{
+ // GetOptimalHeight called for preview style needs to
+ // use really use the style
+ if ( ScStyleSheet* pStyle = pDocument->GetPreviewCellStyle( nCol, nStartRow, nTab ) )
+ {
+ aAltPatterns.push_back( new ScPatternAttr( *pPattern ) );
+ ScPatternAttr* pModifiedPatt = &aAltPatterns.back();
+ pModifiedPatt->SetStyleSheet( pStyle );
+ pPattern = pModifiedPatt;
+ }
const ScMergeAttr* pMerge = (const ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
const ScMergeFlagAttr* pFlag = (const ScMergeFlagAttr*)&pPattern->GetItem(ATTR_MERGE_FLAG);
if ( pMerge->GetRowMerge() > 1 || pFlag->IsOverlapped() )
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 720b504b6e61..cd09ffbd82b2 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -156,7 +156,7 @@ ScDocument::ScDocument( ScDocumentMode eMode,
pAutoNameCache( NULL ),
pLookupCacheMapImpl( NULL ),
pPreviewFont( NULL ),
- pPreviewSelection( NULL ),
+ pPreviewCellStyle( NULL ),
nUnoObjectId( 0 ),
nRangeOverflowType( 0 ),
aCurTextWidthCalcPos(MAXCOL,0,0),
@@ -437,6 +437,7 @@ ScDocument::~ScDocument()
delete pScriptTypeData;
delete pRecursionHelper;
+ delete pPreviewFont;
OSL_POSTCOND( !pAutoNameCache, "AutoNameCache still set in dtor" );
}
@@ -1205,21 +1206,14 @@ void ScDocument::SetPreviewFont( SfxItemSet* pFont )
pPreviewFont = pFont;
}
-const ScMarkData& ScDocument::GetPreviewSelection()
+const ScMarkData ScDocument::GetPreviewSelection()
{
- if ( !pPreviewSelection )
- pPreviewSelection = new ScMarkData();
-
- return *pPreviewSelection;
+ return maPreviewSelection;
}
void ScDocument::SetPreviewSelection( ScMarkData& rSel )
{
- // yeuch, why do I have a pointer here ???? ( other problems
- // to fix right now though )
- if ( !pPreviewSelection )
- pPreviewSelection = new ScMarkData();
- *pPreviewSelection = rSel;
+ maPreviewSelection = rSel;
}
SfxItemSet* ScDocument::GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab )
@@ -1227,10 +1221,19 @@ SfxItemSet* ScDocument::GetPreviewFont( SCCOL nCol, SCROW nRow, SCTAB nTab )
SfxItemSet* pRet = NULL;
if ( pPreviewFont )
{
- if ( GetPreviewSelection().IsCellMarked( nCol, nRow ) && GetPreviewSelection().GetFirstSelected() == nTab )
+ ScMarkData aSel = GetPreviewSelection();
+ if ( aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
pRet = pPreviewFont;
}
return pRet;
}
+ScStyleSheet* ScDocument::GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ ScStyleSheet* pRet = NULL;
+ ScMarkData aSel = GetPreviewSelection();
+ if ( pPreviewCellStyle && aSel.IsCellMarked( nCol, nRow ) && aSel.GetFirstSelected() == nTab )
+ pRet = pPreviewCellStyle;
+ return pRet;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 71e18785332b..4dfd029e53dc 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -822,7 +822,18 @@ bool ScDocument::OnlineSpellInRange( const ScRange& rSpellRange, ScAddress& rSpe
}
const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
- pPattern->FillEditItemSet( pDefaults );
+ if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) )
+ {
+ ScPatternAttr* pPreviewPattern = new ScPatternAttr( *pPattern );
+ pPreviewPattern->SetStyleSheet(pPreviewStyle);
+ pPreviewPattern->FillEditItemSet( pDefaults );
+ delete pPreviewPattern;
+ }
+ else
+ {
+ SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab );
+ pPattern->FillEditItemSet( pDefaults, pFontSet );
+ }
pEngine->SetDefaults( pDefaults, false ); //! noetig ?
sal_uInt16 nCellLang = ((const SvxLanguageItem&)
@@ -1669,9 +1680,19 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
// defaults from cell attributes must be set so right language is used
const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
SfxItemSet* pDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
- pPattern->FillEditItemSet( pDefaults );
- pEngine->SetDefaults( pDefaults, true );
-
+ if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) )
+ {
+ ScPatternAttr* pPreviewPattern = new ScPatternAttr( *pPattern );
+ pPreviewPattern->SetStyleSheet(pPreviewStyle);
+ pPreviewPattern->FillEditItemSet( pDefaults );
+ delete pPreviewPattern;
+ }
+ else
+ {
+ SfxItemSet* pFontSet = GetPreviewFont( nCol, nRow, nTab );
+ pPattern->FillEditItemSet( pDefaults, pFontSet );
+ }
+ pEngine->SetDefaults( pDefaults, true );
if (aCell.meType == CELLTYPE_STRING)
pEngine->SetText(*aCell.mpString);
else if (aCell.mpEditText)
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 5f9b6cecdbb3..5646527d8cc6 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -226,6 +226,7 @@ void ScDocument::FillInfo(
bool bAnyMerged = false;
bool bAnyShadow = false;
bool bAnyCondition = false;
+ bool bAnyPreview = false;
bool bTabProtect = IsTabProtected(nTab);
@@ -505,6 +506,8 @@ void ScDocument::FillInfo(
bool bRowHidden = RowHidden(nCurRow, nTab, NULL, &nLastHiddenRow);
if ( nArrRow==0 || !bRowHidden )
{
+ if ( GetPreviewCellStyle( nX, nCurRow, nTab ) != NULL )
+ bAnyPreview = true;
RowInfo* pThisRowInfo = &pRowInfo[nArrRow];
if (pBackground != pDefBackground) // Spalten-HG == Standard ?
pThisRowInfo->bEmptyBack = false;
@@ -677,15 +680,30 @@ void ScDocument::FillInfo(
pCondFormList->endRendering();
//-------------------------------------------------------------------------
// bedingte Formatierung auswerten
-
- if (bAnyCondition)
+ ::boost::ptr_vector<ScPatternAttr> aAltPatterns;
+ // favour preview over condition
+ if (bAnyCondition || bAnyPreview)
{
for (nArrRow=0; nArrRow<nArrCount; nArrRow++)
{
for (nArrCol=nCol1; nArrCol<=nCol2+2; nArrCol++) // links und rechts einer mehr
{
CellInfo* pInfo = &pRowInfo[nArrRow].pCellInfo[nArrCol];
- const SfxItemSet* pCondSet = pInfo->pConditionSet;
+ SCCOL nCol = (nArrCol>0) ? nArrCol-1 : MAXCOL+1;
+ ScPatternAttr* pModifiedPatt = NULL;
+
+ if ( ValidCol(nCol) && pRowInfo[nArrRow].nRowNo <= MAXROW )
+ {
+ if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, pRowInfo[nArrRow].nRowNo, nTab ) )
+ {
+ aAltPatterns.push_back( new ScPatternAttr( *pInfo->pPatternAttr ) );
+ pModifiedPatt = &aAltPatterns.back();
+ pModifiedPatt->SetStyleSheet( pPreviewStyle );
+ }
+ }
+ // favour preview over condition
+ const SfxItemSet* pCondSet = pModifiedPatt ? &pModifiedPatt->GetItemSet() : pInfo->pConditionSet;
+
if (pCondSet)
{
const SfxPoolItem* pItem;
@@ -713,7 +731,7 @@ void ScDocument::FillInfo(
bAnyShadow = true;
}
}
- if(pInfo->pColorScale)
+ if( bAnyCondition && pInfo->pColorScale)
{
pRowInfo[nArrRow].bEmptyBack = false;
pInfo->pBackground = new SvxBrushItem(*pInfo->pColorScale, ATTR_BACKGROUND);
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
index cefeca8ec542..4565354ac1c7 100644
--- a/sc/source/ui/inc/output.hxx
+++ b/sc/source/ui/inc/output.hxx
@@ -81,6 +81,7 @@ private:
SCROW mnY;
SCCOL mnCellX;
SCROW mnCellY;
+ SCTAB mnTab;
long mnPosX;
long mnPosY;
long mnInitPosX;
@@ -97,6 +98,7 @@ private:
const SfxItemSet* mpPreviewFontSet;
const ScPatternAttr* mpOldPattern;
const SfxItemSet* mpOldCondSet;
+ const SfxItemSet* mpOldPreviewFontSet;
const RowInfo* mpThisRowInfo;
explicit DrawEditParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
index ebfc48d801fd..8df28ad0d78e 100644
--- a/sc/source/ui/unoobj/viewuno.cxx
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -1748,6 +1748,14 @@ void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
void ScTabViewObj::SelectionChanged()
{
+ // Selection changed so end any style preview
+ // Note: executing this slot through the dispatcher
+ // will cause the style dialog to be raised so we go
+ // direct here
+ ScFormatShell aShell( GetViewShell()->GetViewData() );
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ SfxRequest aReq( SID_STYLE_END_PREVIEW, 0, reqList );
+ aShell.ExecuteStyle( aReq );
lang::EventObject aEvent;
aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
BOOST_FOREACH(const XSelectionChangeListenerUnoRef rListener, aSelectionChgListeners)
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index b15ff3e6ccc1..a3da82d94857 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -267,8 +267,68 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
ScModule* pScMod = SC_MOD();
String aRefName;
bool bUndo = pDoc->IsUndoEnabled();
+ SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
+
+ if ( (nSlotId == SID_STYLE_PREVIEW)
+ || (nSlotId == SID_STYLE_END_PREVIEW) )
+ {
+ if (nSlotId == SID_STYLE_PREVIEW)
+ {
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA;
+ const SfxPoolItem* pFamItem;
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, sal_True, &pFamItem ) )
+ eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue();
+ const SfxPoolItem* pNameItem;
+ OUString aStyleName;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, sal_True, &pNameItem ))
+ aStyleName = ((const SfxStringItem*)pNameItem)->GetValue();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA ) // CellStyles
+ {
+ ScMarkData aFuncMark( pViewData->GetMarkData() );
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+ aFuncMark.MarkToMulti();
+
+ if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
+ {
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScRange aRange( nCol, nRow, nTab );
+ aFuncMark.SetMarkArea( aRange );
+ }
+ pDoc->SetPreviewSelection( aFuncMark );
+ ScStyleSheet* pPreviewStyle = static_cast<ScStyleSheet*>( pStylePool->Find( aStyleName, eFamily ) );
+ pDoc->SetPreviewCellStyle( pPreviewStyle );
+ ScPatternAttr aAttr( *pDoc->GetSelectionPattern( aFuncMark ) );
+ aAttr.SetStyleSheet( pPreviewStyle );
+
+ SfxItemSet aItemSet( GetPool() );
+
+ ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
+ SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
+ rNewSet.Put( aItemSet, false );
- if ( (nSlotId == SID_STYLE_NEW)
+ pDoc->ApplySelectionPattern( aNewAttrs, pDoc->GetPreviewSelection() );
+ pTabViewShell->UpdateSelectionArea( aFuncMark, &aAttr );
+ }
+ }
+ else
+ {
+ ScPatternAttr aAttr( *pDoc->GetSelectionPattern( pDoc->GetPreviewSelection() ) );
+ if ( ScStyleSheet* pPreviewStyle = pDoc->GetPreviewCellStyle() )
+ aAttr.SetStyleSheet( pPreviewStyle );
+ pDoc->SetPreviewCellStyle(NULL);
+
+ SfxItemSet aItemSet( GetPool() );
+
+ ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
+ SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
+ rNewSet.Put( aItemSet, false );
+ pDoc->ApplySelectionPattern( aNewAttrs, pDoc->GetPreviewSelection() );
+ pTabViewShell->UpdateSelectionArea( pDoc->GetPreviewSelection(), &aAttr );
+ }
+ }
+ else if ( (nSlotId == SID_STYLE_NEW)
|| (nSlotId == SID_STYLE_EDIT)
|| (nSlotId == SID_STYLE_DELETE)
|| (nSlotId == SID_STYLE_HIDE)
@@ -279,7 +339,6 @@ void ScFormatShell::ExecuteStyle( SfxRequest& rReq )
|| (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
|| (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) )
{
- SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
SfxStyleSheetBase* pStyleSheet = NULL;
bool bStyleToMarked = false;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 621b0f5bea68..1d2f133bcae4 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1354,16 +1354,13 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
ScMarkData aMultiMark( pViewData->GetMarkData() );
aMultiMark.SetMarking( false );
aMultiMark.MarkToMulti();
-
ScDocument* pDoc = pViewData->GetDocument();
SCTAB nTab = pViewData->GetTabNo();
sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
long nLayoutSign = bLayoutRTL ? -1 : 1;
-
if ( !aMultiMark.IsMultiMarked() )
return;
-
ScRange aMultiRange;
aMultiMark.GetMultiMarkArea( aMultiRange );
SCCOL nX1 = aMultiRange.aStart.Col();
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index af55bcd34e8e..77b700ca4240 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1574,11 +1574,15 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
pPattern = mpDoc->GetPattern( nCellX, nCellY, nTab );
pCondSet = mpDoc->GetCondResult( nCellX, nCellY, nTab );
}
- if ( mpDoc->GetPreviewFont() )
+ if ( mpDoc->GetPreviewFont() || mpDoc->GetPreviewCellStyle() )
{
aAltPatterns.push_back(new ScPatternAttr(*pPattern));
ScPatternAttr* pAltPattern = &aAltPatterns.back();
- if ( SfxItemSet* pFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab ) )
+ if ( ScStyleSheet* pPreviewStyle = mpDoc->GetPreviewCellStyle( nCellX, nCellY, nTab ) )
+ {
+ pAltPattern->SetStyleSheet(pPreviewStyle);
+ }
+ else if ( SfxItemSet* pFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab ) )
{
const SfxPoolItem* pItem;
if ( pFontSet->GetItemState( ATTR_FONT, true, &pItem ) == SFX_ITEM_SET )
@@ -2238,7 +2242,7 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
meVerJustMethod( lcl_GetValue<SvxJustifyMethodItem, SvxCellJustifyMethod>(*pPattern, ATTR_VER_JUSTIFY_METHOD, pCondSet) ),
meOrient( pPattern->GetCellOrientation(pCondSet) ),
mnArrY(0),
- mnX(0), mnY(0), mnCellX(0), mnCellY(0),
+ mnX(0), mnY(0), mnCellX(0), mnCellY(0), mnTab(0),
mnPosX(0), mnPosY(0), mnInitPosX(0),
mbBreak( (meHorJust == SVX_HOR_JUSTIFY_BLOCK) || lcl_GetBoolValue(*pPattern, ATTR_LINEBREAK, pCondSet) ),
mbCellIsValue(bCellIsValue),
@@ -2252,6 +2256,7 @@ ScOutputData::DrawEditParam::DrawEditParam(const ScPatternAttr* pPattern, const
mpPreviewFontSet(NULL),
mpOldPattern(NULL),
mpOldCondSet(NULL),
+ mpOldPreviewFontSet(NULL),
mpThisRowInfo(NULL)
{}
@@ -2305,7 +2310,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
// syntax highlighting mode is ignored here
// StringDiffer doesn't look at hyphenate, language items
- if (mpPattern == mpOldPattern && mpCondSet == mpOldCondSet && !mpPreviewFontSet)
+ if (mpPattern == mpOldPattern && mpCondSet == mpOldCondSet && mpPreviewFontSet == mpOldPreviewFontSet )
return;
sal_Int32 nConfBackColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
@@ -2339,6 +2344,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
mpEngine->SetDefaults( pSet );
mpOldPattern = mpPattern;
mpOldCondSet = mpCondSet;
+ mpOldPreviewFontSet = mpPreviewFontSet;
sal_uLong nControl = mpEngine->GetControlWord();
if (meOrient == SVX_ORIENTATION_STACKED)
@@ -4498,6 +4504,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
bool bHyphenatorSet = false;
const ScPatternAttr* pOldPattern = NULL;
const SfxItemSet* pOldCondSet = NULL;
+ const SfxItemSet* pOldPreviewFontSet = NULL;
ScRefCellValue aCell;
long nInitPosX = nScrX;
@@ -4525,6 +4532,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
long nPosX = 0;
for (SCCOL nX=0; nX<=nX2; nX++) // wegen Ueberhaengen
{
+ std::auto_ptr< ScPatternAttr > pPreviewPattr;
if (nX==nX1) nPosX = nInitPosX; // positions before nX1 are calculated individually
CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
@@ -4597,6 +4605,15 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
}
if (bDoCell)
{
+ if ( mpDoc->GetPreviewCellStyle() )
+ {
+ if ( ScStyleSheet* pPreviewStyle = mpDoc->GetPreviewCellStyle( nCellX, nCellY, nTab ) )
+ {
+ pPreviewPattr.reset( new ScPatternAttr(*pPattern) );
+ pPreviewPattr->SetStyleSheet(pPreviewStyle);
+ pPattern = const_cast<ScPatternAttr*>(pPreviewPattr.get());
+ }
+ }
SfxItemSet* pPreviewFontSet = mpDoc->GetPreviewFont( nCellX, nCellY, nTab );
if (!pEngine)
pEngine = CreateOutputEditEngine();
@@ -4617,12 +4634,15 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
aParam.mnY = nY;
aParam.mnCellX = nCellX;
aParam.mnCellY = nCellY;
+ aParam.mnTab = nTab;
aParam.mnPosX = nPosX;
aParam.mnPosY = nPosY;
aParam.mnInitPosX = nInitPosX;
aParam.mpPreviewFontSet = pPreviewFontSet;
+ aParam.mpPreviewFontSet = pPreviewFontSet;
aParam.mpOldPattern = pOldPattern;
aParam.mpOldCondSet = pOldCondSet;
+ aParam.mpOldPreviewFontSet = pOldPreviewFontSet;
aParam.mpThisRowInfo = pThisRowInfo;
if (aParam.meHorJust == SVX_HOR_JUSTIFY_REPEAT)
{
@@ -4648,6 +4668,7 @@ void ScOutputData::DrawEdit(sal_Bool bPixelToLogic)
// Retrieve parameters for next iteration.
pOldPattern = aParam.mpOldPattern;
pOldCondSet = aParam.mpOldCondSet;
+ pOldPreviewFontSet = aParam.mpOldPreviewFontSet;
bHyphenatorSet = aParam.mbHyphenatorSet;
}
}