summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh1.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-09-18 16:14:35 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-09-19 10:10:09 +0000
commit5b8c22379e2eae74f7ed78326ab89483db5c6624 (patch)
tree60cbfdd24bca243b4a911ff1dab298ef91590b5b /sc/source/ui/view/cellsh1.cxx
parent96646c351e20fa6699fa368457a05ee70f76f103 (diff)
tdf#96453, tdf#100793 rework transfer of data between cond format dlgs
The xml based transfer of information was a bad idea from the start. It can obviously not transport the temporary conditional format information from the manager dialog. Therefore the whole handling here was completely broken and deleted formats came back, changed formats were not saved and added formats got applied directly to the document. Now the document fornat list and the one from the manager are indepedent again and as long as the manager has not been closed with ok nothing is written to the document. Change-Id: I9802be11cd15c2d2d877e55c91d836735fe0e0ff Reviewed-on: https://gerrit.libreoffice.org/28995 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r--sc/source/ui/view/cellsh1.cxx74
1 files changed, 44 insertions, 30 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c31db963100e..af92bf76aa84 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -77,6 +77,7 @@
#include "docpool.hxx"
#include "condformatdlg.hxx"
#include "attrib.hxx"
+#include "condformatdlgitem.hxx"
#include "globstr.hrc"
#include "scui_def.hxx"
@@ -1934,20 +1935,18 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_OPENDLG_CONDDATE:
{
sal_uInt32 nIndex = sal_uInt32(-1);
- sal_uInt8 nType = 0;
bool bManaged = false;
- // Get the pool item stored it by Conditional Format Manager Dialog.
- sal_uInt32 nItems(pTabViewShell->GetPool().GetItemCount2( SCITEM_STRING ));
+ // Get the pool item stored by Conditional Format Manager Dialog.
+ sal_uInt32 nItems(pTabViewShell->GetPool().GetItemCount2( SCITEM_CONDFORMATDLGDATA ));
for( sal_uInt32 nIter = 0; nIter < nItems; ++nIter )
{
- const SfxPoolItem* pItem = pTabViewShell->GetPool().GetItem2( SCITEM_STRING, nIter );
+ const SfxPoolItem* pItem = pTabViewShell->GetPool().GetItem2( SCITEM_CONDFORMATDLGDATA, nIter );
if( pItem != nullptr )
{
- if ( ScCondFormatDlg::ParseXmlString(
- static_cast<const SfxStringItem*>(pItem)->GetValue(),
- nIndex, nType, bManaged))
- break;
+ const ScCondFormatDlgItem* pDlgItem = static_cast<const ScCondFormatDlgItem*>(pItem);
+ nIndex = pDlgItem->GetIndex();
+ break;
}
}
@@ -2070,12 +2069,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
{
// Put the xml string parameter to initialize the
// Conditional Format Dialog.
- pTabViewShell->GetPool().Put( SfxStringItem( SCITEM_STRING,
- ScCondFormatDlg::GenerateXmlString(
- pCondFormat ? pCondFormat->GetKey() : sal_uInt32(-1),
- sal_uInt8(eType),
- false
- ) ) );
+ ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false);
+ aDlgItem.SetDialogType(eType);
+ pTabViewShell->GetPool().Put(aDlgItem);
sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId();
SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
@@ -2424,7 +2420,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
case SID_OPENDLG_CONDFRMT_MANAGER:
{
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
+ assert(pFact);
ScViewData* pData = GetViewData();
ScDocument* pDoc = pData->GetDocument();
@@ -2437,44 +2433,62 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
- ScConditionalFormatList* pList = pDoc->GetCondFormList( aPos.Tab() );
+ ScConditionalFormatList* pList = nullptr;
+
+ sal_uInt32 nItems(pTabViewShell->GetPool().GetItemCount2( SCITEM_CONDFORMATDLGDATA ));
+ const ScCondFormatDlgItem* pDlgItem = nullptr;
+ for( sal_uInt32 nIter = 0; nIter < nItems; ++nIter )
+ {
+ const SfxPoolItem* pItem = pTabViewShell->GetPool().GetItem2( SCITEM_CONDFORMATDLGDATA, nIter );
+ if( pItem != nullptr )
+ {
+ pDlgItem= static_cast<const ScCondFormatDlgItem*>(pItem);
+ pList = const_cast<ScCondFormatDlgItem*>(pDlgItem)->GetConditionalFormatList();
+ break;
+ }
+ }
+
+ if (!pList)
+ pList = pDoc->GetCondFormList( aPos.Tab() );
+
std::unique_ptr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg(
pTabViewShell->GetDialogParent(), pDoc, pList));
+
+ if (pDlgItem)
+ pDlg->SetModified();
+
short nRet = pDlg->Execute();
+ ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
if(nRet == RET_OK && pDlg->CondFormatsChanged())
{
- ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
}
else if(nRet == DLG_RET_ADD)
{
// Put the xml string parameter to initialize the
// Conditional Format Dialog. ( add new )
- pTabViewShell->GetPool().Put( SfxStringItem( SCITEM_STRING,
- ScCondFormatDlg::GenerateXmlString(
- sal_uInt32(-1),
- sal_uInt8(condformat::dialog::ScCondFormatDialogType::CONDITION),
- true
- ) ) );
-
+ pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
+ std::shared_ptr<ScConditionalFormatList>(pCondFormatList), -1, true));
// Queue message to open Conditional Format Dialog
GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
}
else if (nRet == DLG_RET_EDIT)
{
ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected();
+ sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1;
// Put the xml string parameter to initialize the
// Conditional Format Dialog. ( edit selected conditional format )
- pTabViewShell->GetPool().Put( SfxStringItem( SCITEM_STRING,
- ScCondFormatDlg::GenerateXmlString(
- pFormat ? pFormat->GetKey() : sal_uInt32(-1),
- sal_uInt8(condformat::dialog::ScCondFormatDialogType::CONDITION),
- true
- ) ) );
+ pTabViewShell->GetPool().Put(ScCondFormatDlgItem(
+ std::shared_ptr<ScConditionalFormatList>(pCondFormatList), nIndex, true));
// Queue message to open Conditional Format Dialog
GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT, SfxCallMode::ASYNCHRON );
}
+ else
+ delete pCondFormatList;
+
+ if (pDlgItem)
+ pTabViewShell->GetPool().Remove(*pDlgItem);
}
break;