diff options
author | Noel Power <noel.power@suse.com> | 2013-08-29 17:15:33 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-08-29 21:42:05 +0100 |
commit | bcc51fb2ebdf77a1cc089857775fd742085b45b6 (patch) | |
tree | a828e81a8c283a99d991f695178c0db686b10f86 | |
parent | 9d7c5dcf448fed668cc772d3cffa31712b1834a3 (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
-rw-r--r-- | include/sfx2/sfxsids.hrc | 2 | ||||
-rw-r--r-- | sc/inc/document.hxx | 9 | ||||
-rw-r--r-- | sc/sdi/formatsh.sdi | 2 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 24 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 29 | ||||
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/inc/output.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/viewuno.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 63 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 29 | ||||
-rw-r--r-- | sfx2/sdi/sfx.sdi | 47 | ||||
-rw-r--r-- | sfx2/source/dialog/templdlg.cxx | 28 | ||||
-rw-r--r-- | sfx2/source/inc/templdgi.hxx | 2 |
15 files changed, 266 insertions, 35 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index f17124ae195a..f3414d9be5a9 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -360,6 +360,8 @@ #define SID_STYLE_UPDATE_BY_EXAMPLE (SID_SFX_START + 556) #define SID_STYLE_DRAGHIERARCHIE (SID_SFX_START + 565) #define SID_STYLE_MASK (SID_SFX_START + 562) +#define SID_STYLE_PREVIEW (SID_SFX_START + 567) +#define SID_STYLE_END_PREVIEW (SID_SFX_START + 568) #define SID_STYLE_HIDE (SID_SFX_START + 1603) #define SID_STYLE_SHOW (SID_SFX_START + 1604) #define SID_STYLE_UPD_BY_EX_NAME (SID_SFX_START + 1585) 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; } } diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index e77723084916..2bc4c48071d7 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -6390,6 +6390,53 @@ SfxVoidItem StoreModuleSource SID_BASICIDE_STOREMODULESOURCE GroupId = GID_MACRO; ] +SfxVoidItem StyleEndPreview SID_STYLE_END_PREVIEW +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_TEMPLATE; +] + +SfxVoidItem StylePreview SID_STYLE_PREVIEW +(SfxStringItem ParamName SID_STYLE_PREVIEW,SfxUInt16Item FamilyType SID_STYLE_FAMILY) +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Synchron; + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = FALSE, + ToolBoxConfig = TRUE, + GroupId = GID_TEMPLATE; +] + //-------------------------------------------------------------------------- SfxTemplateItem StyleApplyState SID_STYLE_APPLY [ diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 2a55713a875f..5bb674a498c2 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -830,7 +830,7 @@ SvTreeListEntry* FillBox_Impl(SvTreeListBox *pBox, // Constructor SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window* pW, bool ) : - + mbIgnoreSelect( false ), aISfxTemplateCommon ( this ), pBindings ( pB ), pWindow ( pW ), @@ -1047,6 +1047,9 @@ void SfxCommonTemplateDialog_Impl::Initialize() SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl() { OUString aEmpty; + Execute_Impl(SID_STYLE_END_PREVIEW, + String(), String(), + 0, 0, 0, 0 ); if ( bIsWater ) Execute_Impl(SID_STYLE_WATERCAN, aEmpty, aEmpty, 0); GetWindow()->Hide(); @@ -1425,6 +1428,12 @@ void SfxCommonTemplateDialog_Impl::UpdateStyles_Impl(sal_uInt16 nFlags) OUString aStyle; if(pState) aStyle = pState->GetStyleName(); + mbIgnoreSelect = true; // in case we get a selection change + // in anycase we should stop any preview + Execute_Impl(SID_STYLE_END_PREVIEW, + String(), String(), + 0, 0, 0, 0 ); + SelectStyle(aStyle); EnableDelete(); } @@ -2319,7 +2328,24 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, FmtSelectHdl, SvTreeListBox *, pListBox EnableDelete(); } if( pListBox ) + { SelectStyle( pListBox->GetEntryText( pListBox->GetHdlEntry() )); + sal_uInt16 nModifier = aFmtLb.GetModifier(); + if ( mbIgnoreSelect ) + { + Execute_Impl(SID_STYLE_END_PREVIEW, + String(), String(), + 0, 0, 0, 0 ); + mbIgnoreSelect = false; + } + else + { + Execute_Impl(SID_STYLE_PREVIEW, + GetSelectedEntry(), String(), + ( sal_uInt16 )GetFamilyItem_Impl()->GetFamily(), + 0, 0, &nModifier ); + } + } return 0; } diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx index 1f4175015718..4a81df5ea04f 100644 --- a/sfx2/source/inc/templdgi.hxx +++ b/sfx2/source/inc/templdgi.hxx @@ -94,7 +94,7 @@ class SfxCommonTemplateDialog_Impl : public SfxListener private: class DeletionWatcher; friend class DeletionWatcher; - + bool mbIgnoreSelect; class ISfxTemplateCommon_Impl : public ISfxTemplateCommon { private: |