diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-19 09:09:29 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-01-21 16:31:01 +0000 |
commit | dc62ab3a0c41fe91f776929824a7f7109508a0ae (patch) | |
tree | 74f5556e8c5329eb11fd1d590d57148f83173c21 /sc | |
parent | 64403ab585e616595dd339f592c6f2ca41d5e2f8 (diff) |
copy styles from cond format between different docs, fdo#59159
Change-Id: I5472ab648b248d925f1f07cd4194c1201230ff20
Reviewed-on: https://gerrit.libreoffice.org/1779
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/table2.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 073f7263f60e..07ab79e8652c 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -658,6 +658,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { ScRange aOldRange( nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab); ScRange aNewRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); + bool bSameDoc = pDocument == pTable->pDocument; for(ScConditionalFormatList::const_iterator itr = pTable->mpCondFormatList->begin(), itrEnd = pTable->mpCondFormatList->end(); itr != itrEnd; ++itr) @@ -682,6 +683,29 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO pNewFormat->SetKey(nMax + 1); mpCondFormatList->InsertNew(pNewFormat); + if(!bSameDoc) + { + for(size_t i = 0, n = pNewFormat->size(); + i < n; ++i) + { + OUString aStyleName; + const ScFormatEntry* pEntry = pNewFormat->GetEntry(i); + if(pEntry->GetType() == condformat::CONDITION) + aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle(); + else if(pEntry->GetType() == condformat::DATE) + aStyleName = static_cast<const ScCondDateFormatEntry*>(pEntry)->GetStyleName(); + + if(!aStyleName.isEmpty()) + { + if(pDocument->GetStyleSheetPool()->Find(aStyleName, SFX_STYLE_FAMILY_PARA)) + continue; + + pDocument->GetStyleSheetPool()->CopyStyleFrom( + pTable->pDocument->GetStyleSheetPool(), aStyleName, SFX_STYLE_FAMILY_PARA ); + } + } + } + pDocument->AddCondFormatData( pNewFormat->GetRange(), nTab, pNewFormat->GetKey() ); } } @@ -967,7 +991,9 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, } if(pDestTab->pDocument->IsUndo() && (nFlags & IDF_ATTRIB)) + { pDestTab->mpCondFormatList.reset(new ScConditionalFormatList(pDestTab->pDocument, *mpCondFormatList)); + } if (pDBDataNoName) { |