[Libreoffice-commits] .: 2 commits - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Jan 19 00:13:16 PST 2013


 sc/source/core/data/table2.cxx            |   26 ++++++++++++++++++++++++++
 sc/source/ui/condformat/condformatdlg.cxx |    8 ++++++++
 sc/source/ui/condformat/condformatmgr.cxx |   14 +++++++-------
 sc/source/ui/view/cellsh1.cxx             |    5 ++++-
 4 files changed, 45 insertions(+), 8 deletions(-)

New commits:
commit 5c8e6ccaf6ea7a187e3d16f3d865cbed5eba0874
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jan 19 09:09:29 2013 +0100

    copy styles from cond format between different docs, fdo#59159
    
    Change-Id: I5472ab648b248d925f1f07cd4194c1201230ff20

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 2d909c0..2ad97a6 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -671,6 +671,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)
@@ -695,6 +696,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() );
     }
 }
@@ -980,7 +1004,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)
     {
commit e2170dd77ffbeda24aabb2b704deedd4440d7620
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jan 18 15:07:00 2013 +0100

    prevent to create cond formats with empty range, fdo#58778
    
    Change-Id: I54bac843dc60c419c23c6d3f22c8d2f4b5805327

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 784f1ed..4bd4c05 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -467,12 +467,20 @@ void ScCondFormatDlg::SetReference(const ScRange& rRef, ScDocument*)
 ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
 {
     rtl::OUString aRangeStr = maEdRange.GetText();
+    if(aRangeStr.isEmpty())
+        return NULL;
+
     ScRangeList aRange;
     sal_uInt16 nFlags = aRange.Parse(aRangeStr, mpDoc, SCA_VALID, mpDoc->GetAddressConvention(), maPos.Tab());
     ScConditionalFormat* pFormat = maCondFormList.GetConditionalFormat();
 
     if(nFlags & SCA_VALID && !aRange.empty() && pFormat)
         pFormat->AddRange(aRange);
+    else
+    {
+        delete pFormat;
+        pFormat = NULL;
+    }
 
     return pFormat;
 }
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index af9e383..977cc36 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -275,14 +275,14 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, AddBtnHdl)
     if(pDlg->Execute() == RET_OK)
     {
         ScConditionalFormat* pNewFormat = pDlg->GetConditionalFormat();
-        if(!pNewFormat)
-            return 0;
-
-        mpFormatList->InsertNew(pNewFormat);
-        pNewFormat->SetKey(FindKey(mpFormatList));
-        maCtrlManager.Update();
+        if(pNewFormat)
+        {
+            mpFormatList->InsertNew(pNewFormat);
+            pNewFormat->SetKey(FindKey(mpFormatList));
+            maCtrlManager.Update();
 
-        mbModified = true;
+            mbModified = true;
+        }
     }
     Show(true, 0);
     pScMod->SetRefDialog( nId, false );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 5c4d42b..0c96dd5 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1886,7 +1886,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 if( pCondFormatDlg->Execute() == RET_OK )
                 {
                     ScConditionalFormat* pFormat = pCondFormatDlg->GetConditionalFormat();
-                    pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, aPos.Tab(), pFormat->GetRange());
+                    if(pFormat)
+                        pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, pFormat, aPos.Tab(), pFormat->GetRange());
+                    else
+                        pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nKey, NULL, aPos.Tab(), ScRangeList());
                 }
 
                 pScMod->SetRefDialog( nId, false );


More information about the Libreoffice-commits mailing list