diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-22 16:55:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-26 09:38:53 +0200 |
commit | 30b635c26d6cc07b5a84dc0d829f0b0cde3d1f5a (patch) | |
tree | 0ed53ffc7dd75bc6ca40c99453ae39fea3421462 | |
parent | 94c548ac6468a567aa352fc47e5d2acc34076130 (diff) |
loplugin:flatten in sc
Change-Id: I40653af2d90ef123cf77d7223c520cba0e5a3aca
Reviewed-on: https://gerrit.libreoffice.org/42661
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
28 files changed, 1156 insertions, 1230 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index f665c223f571..9d5c6112f767 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -258,16 +258,14 @@ public: { FormulaToken* ref = mFormulaTree->GetFormulaToken(); cl_uint hashCode = 0; - if (ref->GetType() == formula::svString) - { - const rtl::OUString s = ref->GetString().getString().toAsciiUpperCase(); - hashCode = s.hashCode(); - } - else + if (ref->GetType() != formula::svString) { throw Unhandled(__FILE__, __LINE__); } + const rtl::OUString s = ref->GetString().getString().toAsciiUpperCase(); + hashCode = s.hashCode(); + // Pass the scalar result back to the rest of the formula kernel SAL_INFO("sc.opencl", "Kernel " << k << " arg " << argno << ": cl_uint: " << hashCode); cl_int err = clSetKernelArg(k, argno, sizeof(cl_uint), static_cast<void*>(&hashCode)); diff --git a/sc/source/core/opencl/op_database.cxx b/sc/source/core/opencl/op_database.cxx index 444e3deded0d..d095d0f4ab8f 100644 --- a/sc/source/core/opencl/op_database.cxx +++ b/sc/source/core/opencl/op_database.cxx @@ -38,46 +38,43 @@ void OpDmax::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -168,46 +165,43 @@ void OpDmin::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -299,46 +293,43 @@ void OpDproduct::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -429,46 +420,43 @@ void OpDaverage::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -564,46 +552,43 @@ void OpDstdev::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -749,46 +734,43 @@ void OpDstdevp::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -932,46 +914,43 @@ void OpDsum::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -1064,46 +1043,43 @@ void OpDvar::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -1249,46 +1225,43 @@ void OpDvarp::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> - GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=0;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol]-> + GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=0;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -1432,46 +1405,43 @@ void OpDcount::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(vSubArguments[0]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol] - ->GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=DBL_MIN;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol] + ->GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=DBL_MIN;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1] - ->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1] + ->GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) @@ -1563,46 +1533,43 @@ void OpDcount2::GenSlidingWindowFunction(std::stringstream &ss, GenTmpVariables(ss,vSubArguments); int dataCol = 0; int dataRow = 0; - if(vSubArguments[0]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) - { - formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR1= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - dataCol = pCurDVR1->GetArrays().size(); - dataRow = pCurDVR1->GetArrayLength(); - } - else + if(!(vSubArguments[0]->GetFormulaToken()->GetType() == + formula::svDoubleVectorRef)) throw Unhandled(__FILE__, __LINE__); - if(vSubArguments[dataCol]->GetFormulaToken()->GetType() == - formula::svSingleVectorRef) - { - const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const - formula::SingleVectorRefToken *>(vSubArguments[dataCol] - ->GetFormulaToken()); - ss << " tmp"<<dataCol<<"="; - ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; - ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; - ss << "tmp"<<dataCol<<"))\n"; - ss << " tmp"<<dataCol<<"=DBL_MIN;\n"; - } - else + + formula::FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + dataCol = pCurDVR->GetArrays().size(); + dataRow = pCurDVR->GetArrayLength(); + + if(vSubArguments[dataCol]->GetFormulaToken()->GetType() != + formula::svSingleVectorRef) throw Unhandled(__FILE__, __LINE__); + + const formula::SingleVectorRefToken*pTmpDVR1= static_cast<const + formula::SingleVectorRefToken *>(vSubArguments[dataCol] + ->GetFormulaToken()); + ss << " tmp"<<dataCol<<"="; + ss << vSubArguments[dataCol]->GenSlidingWindowDeclRef()<<";\n"; + ss << " if(gid0>="<<pTmpDVR1->GetArrayLength()<<" ||isnan("; + ss << "tmp"<<dataCol<<"))\n"; + ss << " tmp"<<dataCol<<"=DBL_MIN;\n"; + int conditionCol = 0; int conditionRow = 0; - if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() == - formula::svDoubleVectorRef) + if(vSubArguments[dataCol + 1]->GetFormulaToken()->GetType() != + formula::svDoubleVectorRef) { - formula::FormulaToken *tmpCur = vSubArguments[dataCol + 1]-> - GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const - formula::DoubleVectorRefToken *>(tmpCur); - conditionCol = pCurDVR2->GetArrays().size(); - conditionRow = pCurDVR2->GetArrayLength(); - } - else{ throw Unhandled(__FILE__, __LINE__); } + tmpCur = vSubArguments[dataCol + 1]-> + GetFormulaToken(); + pCurDVR= static_cast<const + formula::DoubleVectorRefToken *>(tmpCur); + conditionCol = pCurDVR->GetArrays().size(); + conditionRow = pCurDVR->GetArrayLength(); + if(dataCol!=conditionCol) throw Unhandled(__FILE__, __LINE__); if(dataCol > 0 && dataRow > 0) diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx index 02acb8dce248..b79d5cdd715d 100644 --- a/sc/source/core/opencl/op_spreadsheet.cxx +++ b/sc/source/core/opencl/op_spreadsheet.cxx @@ -55,31 +55,30 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss, index = ::rtl::math::approxFloor(dblToken->GetDouble()); } - if (vSubArguments[1]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef) - { - FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur); - const std::vector<VectorRefArray> items = pCurDVR->GetArrays(); + if (vSubArguments[1]->GetFormulaToken()->GetType() != formula::svDoubleVectorRef) + throw Unhandled(__FILE__, __LINE__); // unusual vlookup. - secondParaWidth = items.size(); + FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken(); + const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur); + const std::vector<VectorRefArray> items = pCurDVR->GetArrays(); - if (index < 1 || index > secondParaWidth) - throw Unhandled(__FILE__, __LINE__); // oob index. + secondParaWidth = items.size(); - if (items[index - 1].mpStringArray) + if (index < 1 || index > secondParaWidth) + throw Unhandled(__FILE__, __LINE__); // oob index. + + if (items[index - 1].mpStringArray) + { + rtl_uString **pStrings = items[index - 1].mpStringArray; + for (size_t i = 0; i < pCurDVR->GetArrayLength(); ++i) { - rtl_uString **pStrings = items[index - 1].mpStringArray; - for (size_t i = 0; i < pCurDVR->GetArrayLength(); ++i) - { - if (pStrings[i] != nullptr) - { // TODO: the GroupTokenConverter should do better. - throw Unhandled(__FILE__, __LINE__); // mixed arguments. - } + if (pStrings[i] != nullptr) + { // TODO: the GroupTokenConverter should do better. + throw Unhandled(__FILE__, __LINE__); // mixed arguments. } } } - else - throw Unhandled(__FILE__, __LINE__); // unusual vlookup. + arg += secondParaWidth; CheckSubArgumentIsNan(ss,vSubArguments,arg++); @@ -97,8 +96,8 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss, if (vSubArguments[1]->GetFormulaToken()->GetType() == formula::svDoubleVectorRef) { - FormulaToken *tmpCur = vSubArguments[1]->GetFormulaToken(); - const formula::DoubleVectorRefToken*pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur); + tmpCur = vSubArguments[1]->GetFormulaToken(); + pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur); size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength() : pCurDVR->GetRefRowSize() ; int unrollSize = 8; ss << " int loop;\n"; diff --git a/sc/source/ui/unoobj/PivotTableDataProvider.cxx b/sc/source/ui/unoobj/PivotTableDataProvider.cxx index 581e5a9c9b25..85e8eabfbd6e 100644 --- a/sc/source/ui/unoobj/PivotTableDataProvider.cxx +++ b/sc/source/ui/unoobj/PivotTableDataProvider.cxx @@ -864,13 +864,11 @@ uno::Reference< beans::XPropertySetInfo> SAL_CALL void SAL_CALL PivotTableDataProvider::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue) { - if (rPropertyName == SC_UNONAME_INCLUDEHIDDENCELLS) - { - if (!(rValue >>= m_bIncludeHiddenCells)) - throw lang::IllegalArgumentException(); - } - else + if (rPropertyName != SC_UNONAME_INCLUDEHIDDENCELLS) throw beans::UnknownPropertyException(); + + if (!(rValue >>= m_bIncludeHiddenCells)) + throw lang::IllegalArgumentException(); } uno::Any SAL_CALL PivotTableDataProvider::getPropertyValue(const OUString& rPropertyName) diff --git a/sc/source/ui/unoobj/TablePivotCharts.cxx b/sc/source/ui/unoobj/TablePivotCharts.cxx index 16d260fec458..6369729d772f 100644 --- a/sc/source/ui/unoobj/TablePivotCharts.cxx +++ b/sc/source/ui/unoobj/TablePivotCharts.cxx @@ -217,10 +217,10 @@ uno::Any SAL_CALL TablePivotCharts::getByIndex(sal_Int32 nIndex) throw lang::IndexOutOfBoundsException(); uno::Reference<table::XTablePivotChart> xChart(new TablePivotChart(m_pDocShell, m_nTab, aName)); - if (xChart.is()) - return uno::makeAny(xChart); - else + if (!xChart.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xChart); } uno::Type SAL_CALL TablePivotCharts::getElementType() @@ -243,10 +243,10 @@ uno::Any SAL_CALL TablePivotCharts::getByName(OUString const & rName) throw container::NoSuchElementException(); uno::Reference<table::XTablePivotChart> xChart(new TablePivotChart(m_pDocShell, m_nTab, rName)); - if (xChart.is()) - return uno::makeAny(xChart); - else + if (!xChart.is()) throw container::NoSuchElementException(); + + return uno::makeAny(xChart); } uno::Sequence<OUString> SAL_CALL TablePivotCharts::getElementNames() diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx index 1097d48b9f0b..2a730b47b406 100644 --- a/sc/source/ui/unoobj/confuno.cxx +++ b/sc/source/ui/unoobj/confuno.cxx @@ -128,253 +128,250 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue( { SolarMutexGuard aGuard; - if(pDocShell) - { - ScDocument& rDoc = pDocShell->GetDocument(); - bool bUpdateHeights = false; + if(!pDocShell) + throw uno::RuntimeException(); - ScViewOptions aViewOpt(rDoc.GetViewOptions()); + ScDocument& rDoc = pDocShell->GetDocument(); + bool bUpdateHeights = false; - /*Stampit enable/disable print cancel */ - if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) - pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - /*Stampit enable/disable print cancel */ + ScViewOptions aViewOpt(rDoc.GetViewOptions()); + + /*Stampit enable/disable print cancel */ + if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) + pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + /*Stampit enable/disable print cancel */ - else if ( aPropertyName == SC_UNO_SHOWZERO ) - aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_SHOWNOTES ) - aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_SHOWGRID ) - aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_GRIDCOLOR ) + else if ( aPropertyName == SC_UNO_SHOWZERO ) + aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_SHOWNOTES ) + aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_SHOWGRID ) + aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_GRIDCOLOR ) + { + sal_Int64 nColor = 0; + if (aValue >>= nColor) { - sal_Int64 nColor = 0; - if (aValue >>= nColor) - { - Color aColor(static_cast<sal_uInt32>(nColor)); - aViewOpt.SetGridColor(aColor, OUString()); - } + Color aColor(static_cast<sal_uInt32>(nColor)); + aViewOpt.SetGridColor(aColor, OUString()); } - else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) - aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNONAME_LINKUPD ) + } + else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) + aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNONAME_LINKUPD ) + { + // XXX NOTE: this is the css::document::Settings property + // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings + // attribute LinkUpdateMode. + sal_Int16 n; + if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER || + n > css::document::LinkUpdateModes::GLOBAL_SETTING) { - // XXX NOTE: this is the css::document::Settings property - // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings - // attribute LinkUpdateMode. - sal_Int16 n; - if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER || - n > css::document::LinkUpdateModes::GLOBAL_SETTING) - { - throw css::lang::IllegalArgumentException( - ("LinkUpdateMode property value must be a SHORT with a value in" - " the range of the css::document::LinkUpdateModes constants"), - css::uno::Reference<css::uno::XInterface>(), -1); - } - ScLkUpdMode eMode; - switch (n) - { - case css::document::LinkUpdateModes::NEVER: - eMode = LM_NEVER; - break; - case css::document::LinkUpdateModes::MANUAL: - eMode = LM_ON_DEMAND; - break; - case css::document::LinkUpdateModes::AUTO: - eMode = LM_ALWAYS; - break; - case css::document::LinkUpdateModes::GLOBAL_SETTING: - default: - eMode = SC_MOD()->GetAppOptions().GetLinkMode(); - break; - } - rDoc.SetLinkMode( eMode ); + throw css::lang::IllegalArgumentException( + ("LinkUpdateMode property value must be a SHORT with a value in" + " the range of the css::document::LinkUpdateModes constants"), + css::uno::Reference<css::uno::XInterface>(), -1); } - else if ( aPropertyName == SC_UNO_COLROWHDR ) - aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_SHEETTABS ) - aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_OUTLSYMB ) - aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_AUTOCALC ) - rDoc.SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_PRINTERNAME ) + ScLkUpdMode eMode; + switch (n) { - OUString sPrinterName; - if ( aValue >>= sPrinterName ) - { - // #i75610# if the name is empty, do nothing (don't create any printer) - if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) - { - SfxPrinter* pPrinter = pDocShell->GetPrinter(); - if (pPrinter) - { - if (pPrinter->GetName() != sPrinterName) - { - VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName ); - if (pNewPrinter->IsKnown()) - pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER ); - else - pNewPrinter.disposeAndClear(); - } - } - else - throw uno::RuntimeException(); - } - } - else - throw lang::IllegalArgumentException(); + case css::document::LinkUpdateModes::NEVER: + eMode = LM_NEVER; + break; + case css::document::LinkUpdateModes::MANUAL: + eMode = LM_ON_DEMAND; + break; + case css::document::LinkUpdateModes::AUTO: + eMode = LM_ALWAYS; + break; + case css::document::LinkUpdateModes::GLOBAL_SETTING: + default: + eMode = SC_MOD()->GetAppOptions().GetLinkMode(); + break; } - else if ( aPropertyName == SC_UNO_PRINTERSETUP ) + rDoc.SetLinkMode( eMode ); + } + else if ( aPropertyName == SC_UNO_COLROWHDR ) + aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_SHEETTABS ) + aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_OUTLSYMB ) + aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_AUTOCALC ) + rDoc.SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_PRINTERNAME ) + { + OUString sPrinterName; + if ( !(aValue >>= sPrinterName) ) + throw lang::IllegalArgumentException(); + + // #i75610# if the name is empty, do nothing (don't create any printer) + if ( !sPrinterName.isEmpty() && pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) { - uno::Sequence<sal_Int8> aSequence; - if ( aValue >>= aSequence ) + SfxPrinter* pPrinter = pDocShell->GetPrinter(); + if (!pPrinter) + throw uno::RuntimeException(); + + if (pPrinter->GetName() != sPrinterName) { - sal_uInt32 nSize = aSequence.getLength(); - // #i75610# if the sequence is empty, do nothing (don't create any printer) - if ( nSize != 0 ) - { - SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ ); - aStream.Seek ( STREAM_SEEK_TO_BEGIN ); - auto pSet = o3tl::make_unique<SfxItemSet>( *rDoc.GetPool(), - svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, - SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, - SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET, - SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>{} ); - pDocShell->SetPrinter( SfxPrinter::Create( aStream, std::move(pSet) ) ); - } + VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName ); + if (pNewPrinter->IsKnown()) + pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER ); + else + pNewPrinter.disposeAndClear(); } + } - else if ( aPropertyName == SC_UNO_APPLYDOCINF ) - { - bool bTmp=true; - if ( aValue >>= bTmp ) - pDocShell->SetUseUserData( bTmp ); - } - else if ( aPropertyName == SC_UNO_FORBIDDEN ) - { - // read-only - should not be set - } - else if ( aPropertyName == SC_UNO_CHARCOMP ) - { - // Int16 contains CharacterCompressionType values - sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue ); - rDoc.SetAsianCompression( (CharCompressType) nUno ); - bUpdateHeights = true; - } - else if ( aPropertyName == SC_UNO_ASIANKERN ) - { - rDoc.SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - bUpdateHeights = true; - } - else if ( aPropertyName == SCSAVEVERSION ) - { - bool bTmp=false; - if ( aValue >>= bTmp ) - pDocShell->SetSaveVersionOnClose( bTmp ); - } - else if ( aPropertyName == SC_UNO_UPDTEMPL ) - { - bool bTmp=true; - if ( aValue >>= bTmp ) - pDocShell->SetQueryLoadTemplate( bTmp ); - } - else if ( aPropertyName == SC_UNO_LOADREADONLY ) - { - bool bTmp=false; - if ( aValue >>= bTmp ) - pDocShell->SetLoadReadonly( bTmp ); - } - else if ( aPropertyName == SC_UNO_SHAREDOC ) + + } + else if ( aPropertyName == SC_UNO_PRINTERSETUP ) + { + uno::Sequence<sal_Int8> aSequence; + if ( aValue >>= aSequence ) { -#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT - bool bDocShared = false; - if ( aValue >>= bDocShared ) + sal_uInt32 nSize = aSequence.getLength(); + // #i75610# if the sequence is empty, do nothing (don't create any printer) + if ( nSize != 0 ) { - pDocShell->SetSharedXMLFlag( bDocShared ); + SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ ); + aStream.Seek ( STREAM_SEEK_TO_BEGIN ); + auto pSet = o3tl::make_unique<SfxItemSet>( *rDoc.GetPool(), + svl::Items<SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, + SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, + SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET, + SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>{} ); + pDocShell->SetPrinter( SfxPrinter::Create( aStream, std::move(pSet) ) ); } -#endif } - else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) + } + else if ( aPropertyName == SC_UNO_APPLYDOCINF ) + { + bool bTmp=true; + if ( aValue >>= bTmp ) + pDocShell->SetUseUserData( bTmp ); + } + else if ( aPropertyName == SC_UNO_FORBIDDEN ) + { + // read-only - should not be set + } + else if ( aPropertyName == SC_UNO_CHARCOMP ) + { + // Int16 contains CharacterCompressionType values + sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue ); + rDoc.SetAsianCompression( (CharCompressType) nUno ); + bUpdateHeights = true; + } + else if ( aPropertyName == SC_UNO_ASIANKERN ) + { + rDoc.SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + bUpdateHeights = true; + } + else if ( aPropertyName == SCSAVEVERSION ) + { + bool bTmp=false; + if ( aValue >>= bTmp ) + pDocShell->SetSaveVersionOnClose( bTmp ); + } + else if ( aPropertyName == SC_UNO_UPDTEMPL ) + { + bool bTmp=true; + if ( aValue >>= bTmp ) + pDocShell->SetQueryLoadTemplate( bTmp ); + } + else if ( aPropertyName == SC_UNO_LOADREADONLY ) + { + bool bTmp=false; + if ( aValue >>= bTmp ) + pDocShell->SetLoadReadonly( bTmp ); + } + else if ( aPropertyName == SC_UNO_SHAREDOC ) + { +#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT + bool bDocShared = false; + if ( aValue >>= bDocShared ) { - uno::Sequence< beans::PropertyValue > aInfo; - if ( !( aValue >>= aInfo ) ) - throw lang::IllegalArgumentException( - "Value of type Sequence<PropertyValue> expected!", - uno::Reference< uno::XInterface >(), - 2 ); - - if ( !pDocShell->SetModifyPasswordInfo( aInfo ) ) - throw beans::PropertyVetoException( - "The hash is not allowed to be changed now!" ); + pDocShell->SetSharedXMLFlag( bDocShared ); } - else if ( aPropertyName == SC_UNO_EMBED_FONTS ) +#endif + } + else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) + { + uno::Sequence< beans::PropertyValue > aInfo; + if ( !( aValue >>= aInfo ) ) + throw lang::IllegalArgumentException( + "Value of type Sequence<PropertyValue> expected!", + uno::Reference< uno::XInterface >(), + 2 ); + + if ( !pDocShell->SetModifyPasswordInfo( aInfo ) ) + throw beans::PropertyVetoException( + "The hash is not allowed to be changed now!" ); + } + else if ( aPropertyName == SC_UNO_EMBED_FONTS ) + { + bool bVal = false; + if ( aValue >>=bVal ) { - bool bVal = false; - if ( aValue >>=bVal ) - { - rDoc.SetIsUsingEmbededFonts(bVal); - } + rDoc.SetIsUsingEmbededFonts(bVal); } - else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) - { - ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); - sal_Int16 nUno = 0; + } + else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) + { + ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); + sal_Int16 nUno = 0; - if( aValue >>= nUno ) + if( aValue >>= nUno ) + { + switch (nUno) { - switch (nUno) - { - case 0: // CONV_OOO - case 2: // CONV_XL_A1 - case 3: // CONV_XL_R1C1 - case 7: // CONV_A1_XL_A1 - aCalcConfig.SetStringRefSyntax( static_cast<formula::FormulaGrammar::AddressConvention>( nUno ) ); - break; - default: - aCalcConfig.SetStringRefSyntax( formula::FormulaGrammar::CONV_UNSPECIFIED ); - break; + case 0: // CONV_OOO + case 2: // CONV_XL_A1 + case 3: // CONV_XL_R1C1 + case 7: // CONV_A1_XL_A1 + aCalcConfig.SetStringRefSyntax( static_cast<formula::FormulaGrammar::AddressConvention>( nUno ) ); + break; + default: + aCalcConfig.SetStringRefSyntax( formula::FormulaGrammar::CONV_UNSPECIFIED ); + break; - } - rDoc.SetCalcConfig( aCalcConfig ); } + rDoc.SetCalcConfig( aCalcConfig ); } + } + else + { + ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); + if ( aPropertyName == SC_UNO_SNAPTORASTER ) + aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_RASTERVIS ) + aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); + else if ( aPropertyName == SC_UNO_RASTERRESX ) + aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); + else if ( aPropertyName == SC_UNO_RASTERRESY ) + aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); + else if ( aPropertyName == SC_UNO_RASTERSUBX ) + aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); + else if ( aPropertyName == SC_UNO_RASTERSUBY ) + aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); + else if ( aPropertyName == SC_UNO_RASTERSYNC ) + aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); else - { - ScGridOptions aGridOpt(aViewOpt.GetGridOptions()); - if ( aPropertyName == SC_UNO_SNAPTORASTER ) - aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_RASTERVIS ) - aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else if ( aPropertyName == SC_UNO_RASTERRESX ) - aGridOpt.SetFieldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); - else if ( aPropertyName == SC_UNO_RASTERRESY ) - aGridOpt.SetFieldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); - else if ( aPropertyName == SC_UNO_RASTERSUBX ) - aGridOpt.SetFieldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); - else if ( aPropertyName == SC_UNO_RASTERSUBY ) - aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) ); - else if ( aPropertyName == SC_UNO_RASTERSYNC ) - aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); - else - throw beans::UnknownPropertyException(); - aViewOpt.SetGridOptions(aGridOpt); - } - rDoc.SetViewOptions(aViewOpt); + throw beans::UnknownPropertyException(); + aViewOpt.SetGridOptions(aGridOpt); + } + rDoc.SetViewOptions(aViewOpt); - if ( bUpdateHeights && !rDoc.IsImportingXML() ) - { - // update automatic row heights and repaint - SCTAB nTabCount = rDoc.GetTableCount(); - for (SCTAB nTab=0; nTab<nTabCount; nTab++) - if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) ) - pDocShell->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PaintPartFlags::Grid); - pDocShell->SetDocumentModified(); - } + if ( bUpdateHeights && !rDoc.IsImportingXML() ) + { + // update automatic row heights and repaint + SCTAB nTabCount = rDoc.GetTableCount(); + for (SCTAB nTab=0; nTab<nTabCount; nTab++) + if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) ) + pDocShell->PostPaint(ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab), PaintPartFlags::Grid); + pDocShell->SetDocumentModified(); } - else - throw uno::RuntimeException(); + } uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPropertyName ) @@ -382,179 +379,178 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPr SolarMutexGuard aGuard; uno::Any aRet; - if(pDocShell) - { - ScDocument& rDoc = pDocShell->GetDocument(); - const ScViewOptions& aViewOpt = rDoc.GetViewOptions(); - - /*Stampit enable/disable print cancel */ - if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) - aRet <<= pDocShell->Stamp_GetPrintCancelState(); - /*Stampit enable/disable print cancel */ + if(!pDocShell) + throw uno::RuntimeException(); - else if ( aPropertyName == SC_UNO_SHOWZERO ) - aRet <<= aViewOpt.GetOption( VOPT_NULLVALS ); - else if ( aPropertyName == SC_UNO_SHOWNOTES ) - aRet <<= aViewOpt.GetOption( VOPT_NOTES ); - else if ( aPropertyName == SC_UNO_SHOWGRID ) - aRet <<= aViewOpt.GetOption( VOPT_GRID ); - else if ( aPropertyName == SC_UNO_GRIDCOLOR ) - { - OUString aColorName; - Color aColor = aViewOpt.GetGridColor(&aColorName); - aRet <<= static_cast<sal_Int64>(aColor.GetColor()); - } - else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) - aRet <<= aViewOpt.GetOption( VOPT_PAGEBREAKS ); - else if ( aPropertyName == SC_UNONAME_LINKUPD ) - { - sal_Int16 nLUM; - switch (rDoc.GetLinkMode()) - { - case LM_ALWAYS: - nLUM = css::document::LinkUpdateModes::AUTO; - break; - case LM_NEVER: - nLUM = css::document::LinkUpdateModes::NEVER; - break; - case LM_ON_DEMAND: - nLUM = css::document::LinkUpdateModes::MANUAL; - break; - case LM_UNKNOWN: - default: - nLUM = css::document::LinkUpdateModes::GLOBAL_SETTING; - break; - } - aRet <<= nLUM; - } - else if ( aPropertyName == SC_UNO_COLROWHDR ) - aRet <<= aViewOpt.GetOption( VOPT_HEADER ); - else if ( aPropertyName == SC_UNO_SHEETTABS ) - aRet <<= aViewOpt.GetOption( VOPT_TABCONTROLS ); - else if ( aPropertyName == SC_UNO_OUTLSYMB ) - aRet <<= aViewOpt.GetOption( VOPT_OUTLINER ); - else if ( aPropertyName == SC_UNO_AUTOCALC ) - aRet <<= rDoc.GetAutoCalc(); - else if ( aPropertyName == SC_UNO_PRINTERNAME ) - { - // #i75610# don't create the printer, return empty string if no printer created yet - // (as in SwXDocumentSettings) - SfxPrinter* pPrinter = rDoc.GetPrinter( false ); - if (pPrinter) - aRet <<= pPrinter->GetName(); - else - aRet <<= OUString(); - } - else if ( aPropertyName == SC_UNO_PRINTERSETUP ) + ScDocument& rDoc = pDocShell->GetDocument(); + const ScViewOptions& aViewOpt = rDoc.GetViewOptions(); + + /*Stampit enable/disable print cancel */ + if ( aPropertyName == SC_UNO_ALLOWPRINTJOBCANCEL ) + aRet <<= pDocShell->Stamp_GetPrintCancelState(); + /*Stampit enable/disable print cancel */ + + else if ( aPropertyName == SC_UNO_SHOWZERO ) + aRet <<= aViewOpt.GetOption( VOPT_NULLVALS ); + else if ( aPropertyName == SC_UNO_SHOWNOTES ) + aRet <<= aViewOpt.GetOption( VOPT_NOTES ); + else if ( aPropertyName == SC_UNO_SHOWGRID ) + aRet <<= aViewOpt.GetOption( VOPT_GRID ); + else if ( aPropertyName == SC_UNO_GRIDCOLOR ) + { + OUString aColorName; + Color aColor = aViewOpt.GetGridColor(&aColorName); + aRet <<= static_cast<sal_Int64>(aColor.GetColor()); + } + else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) + aRet <<= aViewOpt.GetOption( VOPT_PAGEBREAKS ); + else if ( aPropertyName == SC_UNONAME_LINKUPD ) + { + sal_Int16 nLUM; + switch (rDoc.GetLinkMode()) { - // #i75610# don't create the printer, return empty sequence if no printer created yet - // (as in SwXDocumentSettings) - SfxPrinter* pPrinter = rDoc.GetPrinter( false ); - if (pPrinter) - { - SvMemoryStream aStream; - pPrinter->Store( aStream ); - aStream.Seek ( STREAM_SEEK_TO_END ); - sal_uInt32 nSize = aStream.Tell(); - aStream.Seek ( STREAM_SEEK_TO_BEGIN ); - uno::Sequence < sal_Int8 > aSequence( nSize ); - aStream.ReadBytes(aSequence.getArray(), nSize); - aRet <<= aSequence; - } - else - aRet <<= uno::Sequence<sal_Int8>(); + case LM_ALWAYS: + nLUM = css::document::LinkUpdateModes::AUTO; + break; + case LM_NEVER: + nLUM = css::document::LinkUpdateModes::NEVER; + break; + case LM_ON_DEMAND: + nLUM = css::document::LinkUpdateModes::MANUAL; + break; + case LM_UNKNOWN: + default: + nLUM = css::document::LinkUpdateModes::GLOBAL_SETTING; + break; } - else if ( aPropertyName == SC_UNO_APPLYDOCINF ) - aRet <<= pDocShell->IsUseUserData(); - else if ( aPropertyName == SC_UNO_FORBIDDEN ) + aRet <<= nLUM; + } + else if ( aPropertyName == SC_UNO_COLROWHDR ) + aRet <<= aViewOpt.GetOption( VOPT_HEADER ); + else if ( aPropertyName == SC_UNO_SHEETTABS ) + aRet <<= aViewOpt.GetOption( VOPT_TABCONTROLS ); + else if ( aPropertyName == SC_UNO_OUTLSYMB ) + aRet <<= aViewOpt.GetOption( VOPT_OUTLINER ); + else if ( aPropertyName == SC_UNO_AUTOCALC ) + aRet <<= rDoc.GetAutoCalc(); + else if ( aPropertyName == SC_UNO_PRINTERNAME ) + { + // #i75610# don't create the printer, return empty string if no printer created yet + // (as in SwXDocumentSettings) + SfxPrinter* pPrinter = rDoc.GetPrinter( false ); + if (pPrinter) + aRet <<= pPrinter->GetName(); + else + aRet <<= OUString(); + } + else if ( aPropertyName == SC_UNO_PRINTERSETUP ) + { + // #i75610# don't create the printer, return empty sequence if no printer created yet + // (as in SwXDocumentSettings) + SfxPrinter* pPrinter = rDoc.GetPrinter( false ); + if (pPrinter) { - aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell )); + SvMemoryStream aStream; + pPrinter->Store( aStream ); + aStream.Seek ( STREAM_SEEK_TO_END ); + sal_uInt32 nSize = aStream.Tell(); + aStream.Seek ( STREAM_SEEK_TO_BEGIN ); + uno::Sequence < sal_Int8 > aSequence( nSize ); + aStream.ReadBytes(aSequence.getArray(), nSize); + aRet <<= aSequence; } - else if ( aPropertyName == SC_UNO_CHARCOMP ) - aRet <<= static_cast<sal_Int16> ( rDoc.GetAsianCompression() ); - else if ( aPropertyName == SC_UNO_ASIANKERN ) - aRet <<= rDoc.GetAsianKerning(); - else if ( aPropertyName == SCSAVEVERSION ) - aRet <<= pDocShell->IsSaveVersionOnClose(); - else if ( aPropertyName == SC_UNO_UPDTEMPL ) - aRet <<= pDocShell->IsQueryLoadTemplate(); - else if ( aPropertyName == SC_UNO_LOADREADONLY ) - aRet <<= pDocShell->IsLoadReadonly(); - else if ( aPropertyName == SC_UNO_SHAREDOC ) - { + else + aRet <<= uno::Sequence<sal_Int8>(); + } + else if ( aPropertyName == SC_UNO_APPLYDOCINF ) + aRet <<= pDocShell->IsUseUserData(); + else if ( aPropertyName == SC_UNO_FORBIDDEN ) + { + aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell )); + } + else if ( aPropertyName == SC_UNO_CHARCOMP ) + aRet <<= static_cast<sal_Int16> ( rDoc.GetAsianCompression() ); + else if ( aPropertyName == SC_UNO_ASIANKERN ) + aRet <<= rDoc.GetAsianKerning(); + else if ( aPropertyName == SCSAVEVERSION ) + aRet <<= pDocShell->IsSaveVersionOnClose(); + else if ( aPropertyName == SC_UNO_UPDTEMPL ) + aRet <<= pDocShell->IsQueryLoadTemplate(); + else if ( aPropertyName == SC_UNO_LOADREADONLY ) + aRet <<= pDocShell->IsLoadReadonly(); + else if ( aPropertyName == SC_UNO_SHAREDOC ) + { #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT - aRet <<= pDocShell->HasSharedXMLFlagSet(); + aRet <<= pDocShell->HasSharedXMLFlagSet(); #endif - } - else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) - aRet <<= pDocShell->GetModifyPasswordInfo(); - else if ( aPropertyName == SC_UNO_EMBED_FONTS ) + } + else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO ) + aRet <<= pDocShell->GetModifyPasswordInfo(); + else if ( aPropertyName == SC_UNO_EMBED_FONTS ) + { + aRet <<= rDoc.IsUsingEmbededFonts(); + } + else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) + { + ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); + formula::FormulaGrammar::AddressConvention eConv = aCalcConfig.meStringRefAddressSyntax; + + // don't save "unspecified" string ref syntax ... query formula grammar + // and save that instead + if( eConv == formula::FormulaGrammar::CONV_UNSPECIFIED) { - aRet <<= rDoc.IsUsingEmbededFonts(); + eConv = rDoc.GetAddressConvention(); } - else if ( aPropertyName == SC_UNO_SYNTAXSTRINGREF ) - { - ScCalcConfig aCalcConfig = rDoc.GetCalcConfig(); - formula::FormulaGrammar::AddressConvention eConv = aCalcConfig.meStringRefAddressSyntax; - // don't save "unspecified" string ref syntax ... query formula grammar - // and save that instead - if( eConv == formula::FormulaGrammar::CONV_UNSPECIFIED) - { - eConv = rDoc.GetAddressConvention(); - } - - // write if it has been read|imported or explicitly changed - // or if ref syntax isn't what would be native for our file format - // i.e. CalcA1 in this case - if ( aCalcConfig.mbHasStringRefSyntax || - (eConv != formula::FormulaGrammar::CONV_OOO) ) + // write if it has been read|imported or explicitly changed + // or if ref syntax isn't what would be native for our file format + // i.e. CalcA1 in this case + if ( aCalcConfig.mbHasStringRefSyntax || + (eConv != formula::FormulaGrammar::CONV_OOO) ) + { + switch (eConv) { - switch (eConv) + case formula::FormulaGrammar::CONV_OOO: + case formula::FormulaGrammar::CONV_XL_A1: + case formula::FormulaGrammar::CONV_XL_R1C1: + case formula::FormulaGrammar::CONV_A1_XL_A1: + aRet <<= static_cast<sal_Int16>( eConv ); + break; + + case formula::FormulaGrammar::CONV_UNSPECIFIED: + case formula::FormulaGrammar::CONV_ODF: + case formula::FormulaGrammar::CONV_XL_OOX: + case formula::FormulaGrammar::CONV_LOTUS_A1: + case formula::FormulaGrammar::CONV_LAST: { - case formula::FormulaGrammar::CONV_OOO: - case formula::FormulaGrammar::CONV_XL_A1: - case formula::FormulaGrammar::CONV_XL_R1C1: - case formula::FormulaGrammar::CONV_A1_XL_A1: - aRet <<= static_cast<sal_Int16>( eConv ); - break; - - case formula::FormulaGrammar::CONV_UNSPECIFIED: - case formula::FormulaGrammar::CONV_ODF: - case formula::FormulaGrammar::CONV_XL_OOX: - case formula::FormulaGrammar::CONV_LOTUS_A1: - case formula::FormulaGrammar::CONV_LAST: - { - aRet <<= sal_Int16(9999); - break; - } - } + aRet <<= sal_Int16(9999); + break; + } } - } + } + } + else + { + const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); + if ( aPropertyName == SC_UNO_SNAPTORASTER ) + aRet <<= aGridOpt.GetUseGridSnap(); + else if ( aPropertyName == SC_UNO_RASTERVIS ) + aRet <<= aGridOpt.GetGridVisible(); + else if ( aPropertyName == SC_UNO_RASTERRESX ) + aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawX() ); + else if ( aPropertyName == SC_UNO_RASTERRESY ) + aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawY() ); + else if ( aPropertyName == SC_UNO_RASTERSUBX ) + aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionX() ); + else if ( aPropertyName == SC_UNO_RASTERSUBY ) + aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionY() ); + else if ( aPropertyName == SC_UNO_RASTERSYNC ) + aRet <<= aGridOpt.GetSynchronize(); else - { - const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions(); - if ( aPropertyName == SC_UNO_SNAPTORASTER ) - aRet <<= aGridOpt.GetUseGridSnap(); - else if ( aPropertyName == SC_UNO_RASTERVIS ) - aRet <<= aGridOpt.GetGridVisible(); - else if ( aPropertyName == SC_UNO_RASTERRESX ) - aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawX() ); - else if ( aPropertyName == SC_UNO_RASTERRESY ) - aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDrawY() ); - else if ( aPropertyName == SC_UNO_RASTERSUBX ) - aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionX() ); - else if ( aPropertyName == SC_UNO_RASTERSUBY ) - aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFieldDivisionY() ); - else if ( aPropertyName == SC_UNO_RASTERSYNC ) - aRet <<= aGridOpt.GetSynchronize(); - else - throw beans::UnknownPropertyException(); - } + throw beans::UnknownPropertyException(); } - else - throw uno::RuntimeException(); + return aRet; } diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 646dd5fae664..f9f79add95d7 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -2357,19 +2357,17 @@ void ScUnnamedDatabaseRangesObj::setByTable( const table::CellRangeAddress& aRan uno::Any ScUnnamedDatabaseRangesObj::getByTable( sal_Int32 nTab ) { SolarMutexGuard aGuard; - if (pDocShell) - { - if ( pDocShell->GetDocument().GetTableCount() <= nTab ) - throw lang::IndexOutOfBoundsException(); - uno::Reference<sheet::XDatabaseRange> xRange( - new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab))); - if (xRange.is()) - return uno::makeAny(xRange); - else - throw container::NoSuchElementException(); - } - else + if (!pDocShell) throw uno::RuntimeException(); + + if ( pDocShell->GetDocument().GetTableCount() <= nTab ) + throw lang::IndexOutOfBoundsException(); + uno::Reference<sheet::XDatabaseRange> xRange( + new ScDatabaseRangeObj(pDocShell, static_cast<SCTAB>(nTab))); + if (!xRange.is()) + throw container::NoSuchElementException(); + + return uno::makeAny(xRange); } sal_Bool ScUnnamedDatabaseRangesObj::hasByTable( sal_Int32 nTab ) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index c985cb5b61aa..629b2c6816e3 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3568,24 +3568,21 @@ uno::Sequence < uno::Reference< table::XCellRange > > SAL_CALL ScTableSheetsObj: ScRangeList aRangeList; ScDocument& rDoc = pDocShell->GetDocument(); - if (ScRangeStringConverter::GetRangeListFromString( aRangeList, aRange, &rDoc, ::formula::FormulaGrammar::CONV_OOO, ';' )) + if (!ScRangeStringConverter::GetRangeListFromString( aRangeList, aRange, &rDoc, ::formula::FormulaGrammar::CONV_OOO, ';' )) + throw lang::IllegalArgumentException(); + + size_t nCount = aRangeList.size(); + if (!nCount) + throw lang::IllegalArgumentException(); + + xRet.realloc(nCount); + for( size_t nIndex = 0; nIndex < nCount; nIndex++ ) { - size_t nCount = aRangeList.size(); - if (nCount) - { - xRet.realloc(nCount); - for( size_t nIndex = 0; nIndex < nCount; nIndex++ ) - { - const ScRange* pRange = aRangeList[ nIndex ]; - if( pRange ) - xRet[nIndex] = new ScCellRangeObj(pDocShell, *pRange); - } - } - else - throw lang::IllegalArgumentException(); + const ScRange* pRange = aRangeList[ nIndex ]; + if( pRange ) + xRet[nIndex] = new ScCellRangeObj(pDocShell, *pRange); } - else - throw lang::IllegalArgumentException(); + return xRet; } diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index 1187454cab57..45cd9a418107 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -375,10 +375,10 @@ uno::Any SAL_CALL ScTableConditionalFormat::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference<sheet::XSheetConditionalEntry> xEntry(GetObjectByIndex_Impl((sal_uInt16)nIndex)); - if (xEntry.is()) - return uno::makeAny(xEntry); - else + if (!xEntry.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xEntry); } uno::Type SAL_CALL ScTableConditionalFormat::getElementType() @@ -416,10 +416,10 @@ uno::Any SAL_CALL ScTableConditionalFormat::getByName( const OUString& aName ) break; } - if (xEntry.is()) - return uno::makeAny(xEntry); - else + if (!xEntry.is()) throw container::NoSuchElementException(); + + return uno::makeAny(xEntry); } uno::Sequence<OUString> SAL_CALL ScTableConditionalFormat::getElementNames() diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx index 64892b6a6bc9..ad0da525309d 100644 --- a/sc/source/ui/unoobj/linkuno.cxx +++ b/sc/source/ui/unoobj/linkuno.cxx @@ -470,10 +470,10 @@ uno::Any SAL_CALL ScSheetLinksObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference<beans::XPropertySet> xLink(GetObjectByIndex_Impl(nIndex)); - if (xLink.is()) - return uno::makeAny(xLink); - else + if (!xLink.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xLink); } uno::Type SAL_CALL ScSheetLinksObj::getElementType() @@ -492,11 +492,10 @@ uno::Any SAL_CALL ScSheetLinksObj::getByName( const OUString& aName ) { SolarMutexGuard aGuard; uno::Reference<beans::XPropertySet> xLink(GetObjectByName_Impl(aName)); - if (xLink.is()) - return uno::makeAny(xLink); - else + if (!xLink.is()) throw container::NoSuchElementException(); -// return uno::Any(); + + return uno::makeAny(xLink); } sal_Bool SAL_CALL ScSheetLinksObj::hasByName( const OUString& aName ) @@ -974,10 +973,11 @@ uno::Any SAL_CALL ScAreaLinksObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference<sheet::XAreaLink> xLink(GetObjectByIndex_Impl(nIndex)); - if (xLink.is()) - return uno::makeAny(xLink); - else + if (!xLink.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xLink); + } uno::Type SAL_CALL ScAreaLinksObj::getElementType() @@ -1264,10 +1264,10 @@ uno::Any SAL_CALL ScDDELinksObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference<sheet::XDDELink> xLink(GetObjectByIndex_Impl(nIndex)); - if (xLink.is()) - return uno::makeAny(xLink); - else + if (!xLink.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xLink); } uno::Type SAL_CALL ScDDELinksObj::getElementType() @@ -1286,10 +1286,10 @@ uno::Any SAL_CALL ScDDELinksObj::getByName( const OUString& aName ) { SolarMutexGuard aGuard; uno::Reference<sheet::XDDELink> xLink(GetObjectByName_Impl(aName)); - if (xLink.is()) - return uno::makeAny(xLink); - else + if (!xLink.is()) throw container::NoSuchElementException(); + + return uno::makeAny(xLink); } uno::Sequence<OUString> SAL_CALL ScDDELinksObj::getElementNames() diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index 2a266d94dd17..864f8f5bb6db 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -601,10 +601,10 @@ uno::Any SAL_CALL ScNamedRangesObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference< sheet::XNamedRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex)); - if ( xRange.is() ) - return uno::makeAny(xRange); - else + if ( !xRange.is() ) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xRange); } uno::Type SAL_CALL ScNamedRangesObj::getElementType() @@ -652,10 +652,10 @@ uno::Any SAL_CALL ScNamedRangesObj::getByName( const OUString& aName ) { SolarMutexGuard aGuard; uno::Reference< sheet::XNamedRange > xRange(GetObjectByName_Impl(aName)); - if ( xRange.is() ) - return uno::makeAny(xRange); - else + if ( !xRange.is() ) throw container::NoSuchElementException(); + + return uno::makeAny(xRange); } uno::Sequence<OUString> SAL_CALL ScNamedRangesObj::getElementNames() @@ -1144,10 +1144,10 @@ uno::Any SAL_CALL ScLabelRangesObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference< sheet::XLabelRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex)); - if ( xRange.is() ) - return uno::makeAny(xRange); - else + if ( !xRange.is() ) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xRange); } uno::Type SAL_CALL ScLabelRangesObj::getElementType() diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx index c8656949b904..b11f98dadb2d 100644 --- a/sc/source/ui/unoobj/shapeuno.cxx +++ b/sc/source/ui/unoobj/shapeuno.cxx @@ -327,101 +327,101 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const if ( aPropertyName == SC_UNONAME_ANCHOR ) { uno::Reference<sheet::XCellRangeAddressable> xRangeAdd(aValue, uno::UNO_QUERY); - if (xRangeAdd.is()) + if (!xRangeAdd.is()) + throw lang::IllegalArgumentException("only XCell or XSpreadsheet objects allowed", static_cast<cppu::OWeakObject*>(this), 0); + + SdrObject *pObj = GetSdrObject(); + if (pObj) { - SdrObject *pObj = GetSdrObject(); - if (pObj) + ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); + SdrPage* pPage = pObj->GetPage(); + if ( pModel && pPage ) { - ScDrawLayer* pModel = static_cast<ScDrawLayer*>(pObj->GetModel()); - SdrPage* pPage = pObj->GetPage(); - if ( pModel && pPage ) + ScDocument* pDoc = pModel->GetDocument(); + if ( pDoc ) { - ScDocument* pDoc = pModel->GetDocument(); - if ( pDoc ) + SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); + if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) { - SfxObjectShell* pObjSh = pDoc->GetDocumentShell(); - if ( pObjSh && dynamic_cast<const ScDocShell*>( pObjSh) != nullptr ) - { - ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pObjSh); - SCTAB nTab = 0; - if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + SCTAB nTab = 0; + if ( lcl_GetPageNum( pPage, *pModel, nTab ) ) + { + table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress(); + if (nTab == aAddress.Sheet) { - table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress(); - if (nTab == aAddress.Sheet) + tools::Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow), + static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet )); + awt::Point aRelPoint; + uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); + if (xShape.is()) { - tools::Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow), - static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet )); - awt::Point aRelPoint; - uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY ); - if (xShape.is()) + Point aPoint; + Point aEndPoint; + if (pDoc->IsNegativePage(nTab)) { - Point aPoint; - Point aEndPoint; - if (pDoc->IsNegativePage(nTab)) - { - aPoint = aRect.TopRight(); - aEndPoint = aRect.BottomLeft(); - } - else - { - aPoint = aRect.TopLeft(); - aEndPoint = aRect.BottomRight(); - } - awt::Size aUnoSize; - awt::Point aCaptionPoint; - ScRange aRange; - aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ); - awt::Point aUnoPoint(aRelPoint); - - aUnoPoint.X += aPoint.X(); - aUnoPoint.Y += aPoint.Y(); - - if ( aUnoPoint.Y > aEndPoint.Y() ) - aUnoPoint.Y = aEndPoint.Y() - 2; - if (pDoc->IsNegativePage(nTab)) - { - if ( aUnoPoint.X < aEndPoint.X() ) - aUnoPoint.X = aEndPoint.X() + 2; - aUnoPoint.X -= aUnoSize.Width; - // remove difference to caption point - if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width) - aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width; - } - else - { - if ( aUnoPoint.X > aEndPoint.X() ) - aUnoPoint.X = aEndPoint.X() - 2; - if (aCaptionPoint.X < 0) - aUnoPoint.X -= aCaptionPoint.X; - } - if (aCaptionPoint.Y < 0) - aUnoPoint.Y -= aCaptionPoint.Y; - - xShape->setPosition(aUnoPoint); - pDocSh->SetModified(); + aPoint = aRect.TopRight(); + aEndPoint = aRect.BottomLeft(); } + else + { + aPoint = aRect.TopLeft(); + aEndPoint = aRect.BottomRight(); + } + awt::Size aUnoSize; + awt::Point aCaptionPoint; + ScRange aRange; + aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ); + awt::Point aUnoPoint(aRelPoint); - if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet + aUnoPoint.X += aPoint.X(); + aUnoPoint.Y += aPoint.Y(); + + if ( aUnoPoint.Y > aEndPoint.Y() ) + aUnoPoint.Y = aEndPoint.Y() - 2; + if (pDoc->IsNegativePage(nTab)) { - OSL_ENSURE(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW && - aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet"); - ScDrawLayer::SetPageAnchored(*pObj); + if ( aUnoPoint.X < aEndPoint.X() ) + aUnoPoint.X = aEndPoint.X() + 2; + aUnoPoint.X -= aUnoSize.Width; + // remove difference to caption point + if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width) + aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width; } else { - OSL_ENSURE(aAddress.StartRow == aAddress.EndRow && - aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell"); - ScDrawObjData aAnchor; - aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet); - aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y); - //Uno sets the Anchor in terms of the unrotated shape, not much we can do - //about that since uno also displays the shape geometry in terms of the unrotated - //shape. #TODO think about changing the anchoring behaviour here too - //Currently we've only got a start anchor, not an end-anchor, so generate that now - ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, aAnchor, *pDoc, aAddress.Sheet); - ScDrawLayer::SetCellAnchored(*pObj, aAnchor); + if ( aUnoPoint.X > aEndPoint.X() ) + aUnoPoint.X = aEndPoint.X() - 2; + if (aCaptionPoint.X < 0) + aUnoPoint.X -= aCaptionPoint.X; } + if (aCaptionPoint.Y < 0) + aUnoPoint.Y -= aCaptionPoint.Y; + + xShape->setPosition(aUnoPoint); + pDocSh->SetModified(); + } + + if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet + { + OSL_ENSURE(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW && + aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet"); + ScDrawLayer::SetPageAnchored(*pObj); + } + else + { + OSL_ENSURE(aAddress.StartRow == aAddress.EndRow && + aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell"); + ScDrawObjData aAnchor; + aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet); + aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y); + //Uno sets the Anchor in terms of the unrotated shape, not much we can do + //about that since uno also displays the shape geometry in terms of the unrotated + //shape. #TODO think about changing the anchoring behaviour here too + //Currently we've only got a start anchor, not an end-anchor, so generate that now + ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, aAnchor, *pDoc, aAddress.Sheet); + ScDrawLayer::SetCellAnchored(*pObj, aAnchor); } } } @@ -429,8 +429,7 @@ void SAL_CALL ScShapeObj::setPropertyValue(const OUString& aPropertyName, const } } } - else - throw lang::IllegalArgumentException("only XCell or XSpreadsheet objects allowed", static_cast<cppu::OWeakObject*>(this), 0); + } else if ( aPropertyName == SC_UNONAME_IMAGEMAP ) { @@ -1163,10 +1162,10 @@ void SAL_CALL ScShapeObj::insertString( const uno::Reference<text::XTextRange>& SolarMutexGuard aGuard; uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg)); - if ( xAggSimpleText.is() ) - xAggSimpleText->insertString( xRange, aString, bAbsorb ); - else + if ( !xAggSimpleText.is() ) throw uno::RuntimeException(); + + xAggSimpleText->insertString( xRange, aString, bAbsorb ); } void SAL_CALL ScShapeObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange, @@ -1175,10 +1174,10 @@ void SAL_CALL ScShapeObj::insertControlCharacter( const uno::Reference<text::XTe SolarMutexGuard aGuard; uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg)); - if ( xAggSimpleText.is() ) - xAggSimpleText->insertControlCharacter( xRange, nControlCharacter, bAbsorb ); - else + if ( !xAggSimpleText.is() ) throw uno::RuntimeException(); + + xAggSimpleText->insertControlCharacter( xRange, nControlCharacter, bAbsorb ); } // XTextRange @@ -1194,12 +1193,10 @@ uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getStart() SolarMutexGuard aGuard; uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg)); - if ( xAggTextRange.is() ) - return xAggTextRange->getStart(); - else + if ( !xAggTextRange.is() ) throw uno::RuntimeException(); -// return uno::Reference<text::XTextRange>(); + return xAggTextRange->getStart(); } uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getEnd() @@ -1207,12 +1204,10 @@ uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getEnd() SolarMutexGuard aGuard; uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg)); - if ( xAggTextRange.is() ) - return xAggTextRange->getEnd(); - else + if ( !xAggTextRange.is() ) throw uno::RuntimeException(); -// return uno::Reference<text::XTextRange>(); + return xAggTextRange->getEnd(); } OUString SAL_CALL ScShapeObj::getString() @@ -1220,12 +1215,10 @@ OUString SAL_CALL ScShapeObj::getString() SolarMutexGuard aGuard; uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg)); - if ( xAggTextRange.is() ) - return xAggTextRange->getString(); - else + if ( !xAggTextRange.is() ) throw uno::RuntimeException(); -// return OUString(); + return xAggTextRange->getString(); } void SAL_CALL ScShapeObj::setString( const OUString& aText ) @@ -1233,10 +1226,10 @@ void SAL_CALL ScShapeObj::setString( const OUString& aText ) SolarMutexGuard aGuard; uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg)); - if ( xAggTextRange.is() ) - xAggTextRange->setString( aText ); - else + if ( !xAggTextRange.is() ) throw uno::RuntimeException(); + + xAggTextRange->setString( aText ); } // XChild @@ -1381,20 +1374,18 @@ public: uno::Sequence< beans::PropertyValue > aProperties; ScMacroInfo* pInfo = getInfo(false); - if ( aName == SC_EVENTACC_ONCLICK ) + if ( aName != SC_EVENTACC_ONCLICK ) { - if ( pInfo && !pInfo->GetMacro().isEmpty() ) - { - aProperties.realloc( 2 ); - aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE; - aProperties[ 0 ].Value <<= OUString(SC_EVENTACC_SCRIPT); - aProperties[ 1 ].Name = SC_EVENTACC_SCRIPT; - aProperties[ 1 ].Value <<= pInfo->GetMacro(); - } + throw container::NoSuchElementException(); } - else + + if ( pInfo && !pInfo->GetMacro().isEmpty() ) { - throw container::NoSuchElementException(); + aProperties.realloc( 2 ); + aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE; + aProperties[ 0 ].Value <<= OUString(SC_EVENTACC_SCRIPT); + aProperties[ 1 ].Name = SC_EVENTACC_SCRIPT; + aProperties[ 1 ].Value <<= pInfo->GetMacro(); } return uno::Any( aProperties ); diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx index e23568887f47..a8ded0aee7d5 100644 --- a/sc/source/ui/unoobj/styleuno.cxx +++ b/sc/source/ui/unoobj/styleuno.cxx @@ -468,11 +468,10 @@ uno::Any SAL_CALL ScStyleFamiliesObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference< container::XNameContainer > xFamily(GetObjectByIndex_Impl(nIndex)); - if (xFamily.is()) - return uno::makeAny(xFamily); - else + if (!xFamily.is()) throw lang::IndexOutOfBoundsException(); -// return uno::Any(); + + return uno::makeAny(xFamily); } uno::Type SAL_CALL ScStyleFamiliesObj::getElementType() @@ -493,11 +492,10 @@ uno::Any SAL_CALL ScStyleFamiliesObj::getByName( const OUString& aName ) { SolarMutexGuard aGuard; uno::Reference< container::XNameContainer > xFamily(GetObjectByName_Impl(aName)); - if (xFamily.is()) - return uno::makeAny(xFamily); - else + if (!xFamily.is()) throw container::NoSuchElementException(); -// return uno::Any(); + + return uno::makeAny(xFamily); } uno::Sequence<OUString> SAL_CALL ScStyleFamiliesObj::getElementNames() @@ -664,21 +662,20 @@ void SAL_CALL ScStyleFamilyObj::insertByName( const OUString& aName, const uno:: //! DocFunc function ??? //! Undo ????????????? - if ( !pStylePool->Find( aNameStr, eFamily ) ) // not available yet - { - (void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF ); + if ( pStylePool->Find( aNameStr, eFamily ) ) // not available yet + throw container::ElementExistException(); - if ( eFamily == SfxStyleFamily::Para && !rDoc.IsImportingXML() ) - rDoc.GetPool()->CellStyleCreated( aNameStr, &rDoc ); + (void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF ); - pStyleObj->InitDoc( pDocShell, aNameStr ); // object can be used + if ( eFamily == SfxStyleFamily::Para && !rDoc.IsImportingXML() ) + rDoc.GetPool()->CellStyleCreated( aNameStr, &rDoc ); + + pStyleObj->InitDoc( pDocShell, aNameStr ); // object can be used + + if (!rDoc.IsImportingXML()) + pDocShell->SetDocumentModified(); // new style not used yet + bDone = true; - if (!rDoc.IsImportingXML()) - pDocShell->SetDocumentModified(); // new style not used yet - bDone = true; - } - else - throw container::ElementExistException(); } } @@ -770,11 +767,10 @@ uno::Any SAL_CALL ScStyleFamilyObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference< style::XStyle > xObj(GetObjectByIndex_Impl(nIndex)); - if (xObj.is()) - return uno::makeAny(xObj); - else + if (!xObj.is()) throw lang::IndexOutOfBoundsException(); -// return uno::Any(); + + return uno::makeAny(xObj); } uno::Type SAL_CALL ScStyleFamilyObj::getElementType() @@ -796,11 +792,10 @@ uno::Any SAL_CALL ScStyleFamilyObj::getByName( const OUString& aName ) SolarMutexGuard aGuard; uno::Reference< style::XStyle > xObj( GetObjectByName_Impl( ScStyleNameConversion::ProgrammaticToDisplayName( aName, eFamily ) )); - if (xObj.is()) - return uno::makeAny(xObj); - else + if (!xObj.is()) throw container::NoSuchElementException(); -// return uno::Any(); + + return uno::makeAny(xObj); } uno::Sequence<OUString> SAL_CALL ScStyleFamilyObj::getElementNames() @@ -863,28 +858,26 @@ uno::Any SAL_CALL ScStyleFamilyObj::getPropertyValue( const OUString& sPropertyN { uno::Any aRet; - if ( sPropertyName == "DisplayName" ) + if ( sPropertyName != "DisplayName" ) { - SolarMutexGuard aGuard; - const char* pResId = nullptr; - switch ( eFamily ) - { - case SfxStyleFamily::Para: - pResId = STR_STYLE_FAMILY_CELL; break; - case SfxStyleFamily::Page: - pResId = STR_STYLE_FAMILY_PAGE; break; - default: - OSL_FAIL( "ScStyleFamilyObj::getPropertyValue(): invalid family" ); - } - if (pResId) - { - OUString sDisplayName(ScGlobal::GetRscString(pResId)); - aRet <<= sDisplayName; - } + throw beans::UnknownPropertyException( "unknown property: " + sPropertyName, static_cast<OWeakObject *>(this) ); } - else + + SolarMutexGuard aGuard; + const char* pResId = nullptr; + switch ( eFamily ) { - throw beans::UnknownPropertyException( "unknown property: " + sPropertyName, static_cast<OWeakObject *>(this) ); + case SfxStyleFamily::Para: + pResId = STR_STYLE_FAMILY_CELL; break; + case SfxStyleFamily::Page: + pResId = STR_STYLE_FAMILY_PAGE; break; + default: + OSL_FAIL( "ScStyleFamilyObj::getPropertyValue(): invalid family" ); + } + if (pResId) + { + OUString sDisplayName(ScGlobal::GetRscString(pResId)); + aRet <<= sDisplayName; } return aRet; @@ -1659,10 +1652,11 @@ void ScStyleObj::setPropertyValue_Impl( const OUString& rPropertyName, const Sfx } } } - if ( bFound ) - rSet.Put( SvxPaperBinItem( ATTR_PAGE_PAPERBIN, nTray ) ); - else + if ( !bFound ) throw lang::IllegalArgumentException(); + + rSet.Put( SvxPaperBinItem( ATTR_PAGE_PAPERBIN, nTray ) ); + } break; case ATTR_PAGE_SCALETO: diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx index a9b4e220b4fe..42aa2a067ef1 100644 --- a/sc/source/ui/unoobj/tokenuno.cxx +++ b/sc/source/ui/unoobj/tokenuno.cxx @@ -190,20 +190,19 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue( else if ( aPropertyName == SC_UNO_COMPILEENGLISH ) { bool bOldEnglish = mbEnglish; - if (aValue >>= mbEnglish) + if (!(aValue >>= mbEnglish)) + throw lang::IllegalArgumentException(); + + // Need to recreate the symbol map to change English property + // because the map is const. So for performance reasons set + // CompileEnglish _before_ OpCodeMap! + if (mxOpCodeMap.get() && mbEnglish != bOldEnglish) { - // Need to recreate the symbol map to change English property - // because the map is const. So for performance reasons set - // CompileEnglish _before_ OpCodeMap! - if (mxOpCodeMap.get() && mbEnglish != bOldEnglish) - { - ScDocument& rDoc = mpDocShell->GetDocument(); - ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar()); - mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); - } + ScDocument& rDoc = mpDocShell->GetDocument(); + ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar()); + mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); } - else - throw lang::IllegalArgumentException(); + } else if ( aPropertyName == SC_UNO_FORMULACONVENTION ) { @@ -215,14 +214,13 @@ void SAL_CALL ScFormulaParserObj::setPropertyValue( } else if ( aPropertyName == SC_UNO_OPCODEMAP ) { - if (aValue >>= maOpCodeMapping) - { - ScDocument& rDoc = mpDocShell->GetDocument(); - ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar()); - mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); - } - else + if (!(aValue >>= maOpCodeMapping)) throw lang::IllegalArgumentException(); + + ScDocument& rDoc = mpDocShell->GetDocument(); + ScCompiler aCompiler( &rDoc, ScAddress(), rDoc.GetGrammar()); + mxOpCodeMap = formula::FormulaCompiler::CreateOpCodeMap( maOpCodeMapping, mbEnglish); + } else if ( aPropertyName == SC_UNO_EXTERNALLINKS ) { diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 3ddf6dd0af62..dc757a29b797 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -989,10 +989,10 @@ uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex ) { SolarMutexGuard aGuard; uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((sal_uInt16)nIndex)); - if (xPane.is()) - return uno::makeAny(xPane); - else + if (!xPane.is()) throw lang::IndexOutOfBoundsException(); + + return uno::makeAny(xPane); } uno::Type SAL_CALL ScTabViewObj::getElementType() diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 1c915d15ae3b..31e7b114c7bb 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -569,12 +569,11 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) if( Scroll.hasValue() ) { bool aScroll = false; - if( Scroll >>= aScroll ) - { - bScroll = aScroll; - } - else + if( !(Scroll >>= aScroll) ) throw uno::RuntimeException("second parameter should be boolean" ); + + bScroll = aScroll; + } OUString sRangeName; diff --git a/sc/source/ui/vba/vbaborders.cxx b/sc/source/ui/vba/vbaborders.cxx index 169597f39be1..2b54dad4fd17 100644 --- a/sc/source/ui/vba/vbaborders.cxx +++ b/sc/source/ui/vba/vbaborders.cxx @@ -172,13 +172,12 @@ public: sal_Int32 nColor = 0; _color >>= nColor; table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) - { - aBorderLine.Color = XLRGBToOORGB( nColor ); - setBorderLine( aBorderLine ); - } - else + if ( !getBorderLine( aBorderLine ) ) throw uno::RuntimeException("No Implementation available" ); + + aBorderLine.Color = XLRGBToOORGB( nColor ); + setBorderLine( aBorderLine ); + } uno::Any SAL_CALL getColorIndex() override @@ -236,29 +235,28 @@ public: sal_Int32 nWeight = 0; _weight >>= nWeight; table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) + if ( !getBorderLine( aBorderLine ) ) + throw uno::RuntimeException("Method failed" ); + + switch ( nWeight ) { - switch ( nWeight ) - { - case XlBorderWeight::xlThin: - aBorderLine.OuterLineWidth = OOLineThin; - break; - case XlBorderWeight::xlMedium: - aBorderLine.OuterLineWidth = OOLineMedium; - break; - case XlBorderWeight::xlThick: - aBorderLine.OuterLineWidth = OOLineThick; - break; - case XlBorderWeight::xlHairline: - aBorderLine.OuterLineWidth = OOLineHairline; - break; - default: - throw uno::RuntimeException("Bad param" ); - } - setBorderLine( aBorderLine ); + case XlBorderWeight::xlThin: + aBorderLine.OuterLineWidth = OOLineThin; + break; + case XlBorderWeight::xlMedium: + aBorderLine.OuterLineWidth = OOLineMedium; + break; + case XlBorderWeight::xlThick: + aBorderLine.OuterLineWidth = OOLineThick; + break; + case XlBorderWeight::xlHairline: + aBorderLine.OuterLineWidth = OOLineHairline; + break; + default: + throw uno::RuntimeException("Bad param" ); } - else - throw uno::RuntimeException("Method failed" ); + setBorderLine( aBorderLine ); + } void SAL_CALL setTintAndShade( const uno::Any& /*rAny*/ ) override @@ -283,26 +281,25 @@ public: sal_Int32 nLineStyle = 0; _linestyle >>= nLineStyle; table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) + if ( !getBorderLine( aBorderLine ) ) + throw uno::RuntimeException("Method failed" ); + + switch ( nLineStyle ) { - switch ( nLineStyle ) - { - case XlLineStyle::xlContinuous: - case XlLineStyle::xlDash: - case XlLineStyle::xlDashDot: - case XlLineStyle::xlDashDotDot: - case XlLineStyle::xlDot: - case XlLineStyle::xlDouble: - case XlLineStyle::xlLineStyleNone: - case XlLineStyle::xlSlantDashDot: - break; - default: - throw uno::RuntimeException("Bad param" ); - } - setBorderLine( aBorderLine ); + case XlLineStyle::xlContinuous: + case XlLineStyle::xlDash: + case XlLineStyle::xlDashDot: + case XlLineStyle::xlDashDotDot: + case XlLineStyle::xlDot: + case XlLineStyle::xlDouble: + case XlLineStyle::xlLineStyleNone: + case XlLineStyle::xlSlantDashDot: + break; + default: + throw uno::RuntimeException("Bad param" ); } - else - throw uno::RuntimeException("Method failed" ); + setBorderLine( aBorderLine ); + } }; diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx index 07fd2447b1f4..50c78108ba8b 100644 --- a/sc/source/ui/vba/vbachart.cxx +++ b/sc/source/ui/vba/vbachart.cxx @@ -551,10 +551,11 @@ ScVbaChart::Activate() // e.g. 'ThisWorkbook' uno::Reference< XHelperInterface > xParent( getParent() ); ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() ); - if ( pChartObj ) - pChartObj->Activate(); - else + if ( !pChartObj ) throw script::BasicErrorException( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), "no ChartObject as parent" ); + + pChartObj->Activate(); + } void SAL_CALL diff --git a/sc/source/ui/vba/vbachartobject.cxx b/sc/source/ui/vba/vbachartobject.cxx index 617e61128e8f..8337d037e8ec 100644 --- a/sc/source/ui/vba/vbachartobject.cxx +++ b/sc/source/ui/vba/vbachartobject.cxx @@ -96,10 +96,11 @@ ScVbaChartObject::Delete() uno::Reference< excel::XWorksheet > xParent( getParent(), uno::UNO_QUERY_THROW ); uno::Reference< excel::XChartObjects > xColl( xParent->ChartObjects( uno::Any() ), uno::UNO_QUERY_THROW ); ScVbaChartObjects* pChartObjectsImpl = static_cast< ScVbaChartObjects* >( xColl.get() ); - if (pChartObjectsImpl) - pChartObjectsImpl->removeByName( getPersistName() ); - else + if (!pChartObjectsImpl) throw script::BasicErrorException( OUString(), uno::Reference< uno::XInterface >(), sal_uInt32(ERRCODE_BASIC_METHOD_FAILED), "Parent is not ChartObjects" ); + + pChartObjectsImpl->removeByName( getPersistName() ); + } void diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx index 6e7b626a8702..3178d88ca6dc 100644 --- a/sc/source/ui/vba/vbainterior.cxx +++ b/sc/source/ui/vba/vbainterior.cxx @@ -304,13 +304,12 @@ ScVbaInterior::getPattern() void SAL_CALL ScVbaInterior::setPattern( const uno::Any& _pattern ) { - if( _pattern >>= m_nPattern ) - { - SetUserDefinedAttributes( PATTERN, SetAttributeData( m_nPattern ) ); - SetMixedColor(); - } - else + if( !(_pattern >>= m_nPattern) ) throw uno::RuntimeException("Invalid Pattern index" ); + + SetUserDefinedAttributes( PATTERN, SetAttributeData( m_nPattern ) ); + SetMixedColor(); + } Color ScVbaInterior::GetBackColor() @@ -352,13 +351,12 @@ void SAL_CALL ScVbaInterior::setPatternColor( const uno::Any& _patterncolor ) { sal_Int32 nPattColor = 0; - if( _patterncolor >>= nPattColor ) - { - SetUserDefinedAttributes( PATTERNCOLOR, SetAttributeData( XLRGBToOORGB( nPattColor ) ) ); - SetMixedColor(); - } - else + if( !(_patterncolor >>= nPattColor) ) throw uno::RuntimeException("Invalid Pattern Color" ); + + SetUserDefinedAttributes( PATTERNCOLOR, SetAttributeData( XLRGBToOORGB( nPattColor ) ) ); + SetMixedColor(); + } uno::Any SAL_CALL ScVbaInterior::getPatternColorIndex() @@ -372,16 +370,15 @@ void SAL_CALL ScVbaInterior::setPatternColorIndex( const uno::Any& _patterncolorindex ) { sal_Int32 nColorIndex = 0; - if( _patterncolorindex >>= nColorIndex ) - { - if( nColorIndex == 0 ) - return; - sal_Int32 nPattColor = 0; - GetIndexColor( nColorIndex ) >>= nPattColor; - setPatternColor( uno::makeAny( OORGBToXLRGB( nPattColor ) ) ); - } - else + if( !(_patterncolorindex >>= nColorIndex) ) throw uno::RuntimeException("Invalid Pattern Color" ); + + if( nColorIndex == 0 ) + return; + sal_Int32 nPattColor = 0; + GetIndexColor( nColorIndex ) >>= nPattColor; + setPatternColor( uno::makeAny( OORGBToXLRGB( nPattColor ) ) ); + } uno::Any SAL_CALL ScVbaInterior::getThemeColor() diff --git a/sc/source/ui/vba/vbamenubars.cxx b/sc/source/ui/vba/vbamenubars.cxx index 1c2759990c66..fb5eb65ea7a5 100644 --- a/sc/source/ui/vba/vbamenubars.cxx +++ b/sc/source/ui/vba/vbamenubars.cxx @@ -31,14 +31,12 @@ public: virtual uno::Any SAL_CALL nextElement() override { // FIXME: should be add menubar - if( hasMoreElements() ) - { - uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) ); - return uno::makeAny( xMenuBar ); - } - else + if( !hasMoreElements() ) throw container::NoSuchElementException(); + + uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); + uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) ); + return uno::makeAny( xMenuBar ); } }; diff --git a/sc/source/ui/vba/vbamenuitems.cxx b/sc/source/ui/vba/vbamenuitems.cxx index 8d12983e28d6..fc89a1e3415b 100644 --- a/sc/source/ui/vba/vbamenuitems.cxx +++ b/sc/source/ui/vba/vbamenuitems.cxx @@ -34,23 +34,22 @@ public: virtual uno::Any SAL_CALL nextElement() override { // FIXME: should be add menu - if( hasMoreElements() ) + if( !hasMoreElements() ) + throw container::NoSuchElementException(); + + uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); + if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup ) { - uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup ) - { - uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) ); - return uno::makeAny( xMenu ); - } - else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton ) - { - uno::Reference< excel::XMenuItem > xMenuItem( new ScVbaMenuItem( m_xParent, m_xContext, xCommandBarControl ) ); - return uno::makeAny( xMenuItem ); - } - nextElement(); + uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) ); + return uno::makeAny( xMenu ); } - else - throw container::NoSuchElementException(); + else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton ) + { + uno::Reference< excel::XMenuItem > xMenuItem( new ScVbaMenuItem( m_xParent, m_xContext, xCommandBarControl ) ); + return uno::makeAny( xMenuItem ); + } + nextElement(); + return uno::Any(); } }; diff --git a/sc/source/ui/vba/vbamenus.cxx b/sc/source/ui/vba/vbamenus.cxx index 9c3f86ad904c..d2a73bf10bde 100644 --- a/sc/source/ui/vba/vbamenus.cxx +++ b/sc/source/ui/vba/vbamenus.cxx @@ -33,18 +33,17 @@ public: virtual uno::Any SAL_CALL nextElement() override { // FIXME: should be add menu - if( hasMoreElements() ) + if( !hasMoreElements() ) + throw container::NoSuchElementException(); + + uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); + if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup ) { - uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup ) - { - uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) ); - return uno::makeAny( xMenu ); - } - nextElement(); + uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) ); + return uno::makeAny( xMenu ); } - else - throw container::NoSuchElementException(); + nextElement(); + return uno::Any(); } }; diff --git a/sc/source/ui/vba/vbapalette.cxx b/sc/source/ui/vba/vbapalette.cxx index 4010200a370f..557b00937e0b 100644 --- a/sc/source/ui/vba/vbapalette.cxx +++ b/sc/source/ui/vba/vbapalette.cxx @@ -95,10 +95,11 @@ ScVbaPalette::getPalette() const { uno::Reference< container::XIndexAccess > xIndex; uno::Reference< beans::XPropertySet > xProps; - if ( m_pShell ) - xProps.set( m_pShell->GetModel(), uno::UNO_QUERY_THROW ); - else + if ( !m_pShell ) throw uno::RuntimeException("Can't extract palette, no doc shell" ); + + xProps.set( m_pShell->GetModel(), uno::UNO_QUERY_THROW ); + xIndex.set( xProps->getPropertyValue("ColorPalette"), uno::UNO_QUERY ); if ( !xIndex.is() ) return new DefaultPalette(); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 756b7cc6be6c..f0dd8bb376cc 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -3335,25 +3335,27 @@ void updateTableSortField( const uno::Reference< table::XCellRange >& xParentRan // make sure that upper left point of key range is within the // parent range - if ( ( !bIsSortColumn && colRowKeyAddress.StartColumn >= parentRangeAddress.StartColumn && - colRowKeyAddress.StartColumn <= parentRangeAddress.EndColumn ) || ( bIsSortColumn && - colRowKeyAddress.StartRow >= parentRangeAddress.StartRow && - colRowKeyAddress.StartRow <= parentRangeAddress.EndRow ) ) - { - //determine col/row index - if ( bIsSortColumn ) - aTableField.Field = colRowKeyAddress.StartRow - parentRangeAddress.StartRow; - else - aTableField.Field = colRowKeyAddress.StartColumn - parentRangeAddress.StartColumn; - aTableField.IsCaseSensitive = bMatchCase; + if ( + ( bIsSortColumn || colRowKeyAddress.StartColumn < parentRangeAddress.StartColumn || + colRowKeyAddress.StartColumn > parentRangeAddress.EndColumn ) + && + ( !bIsSortColumn || colRowKeyAddress.StartRow < parentRangeAddress.StartRow || + colRowKeyAddress.StartRow > parentRangeAddress.EndRow ) + ) + throw uno::RuntimeException("Illegal Key param" ); - if ( nOrder == excel::XlSortOrder::xlAscending ) - aTableField.IsAscending = true; - else - aTableField.IsAscending = false; - } + //determine col/row index + if ( bIsSortColumn ) + aTableField.Field = colRowKeyAddress.StartRow - parentRangeAddress.StartRow; else - throw uno::RuntimeException("Illegal Key param" ); + aTableField.Field = colRowKeyAddress.StartColumn - parentRangeAddress.StartColumn; + aTableField.IsCaseSensitive = bMatchCase; + + if ( nOrder == excel::XlSortOrder::xlAscending ) + aTableField.IsAscending = true; + else + aTableField.IsAscending = false; + } @@ -4873,25 +4875,24 @@ uno::Any ScVbaRange::getShowDetail() // check if the specified range is a single summary column or row. table::CellRangeAddress thisAddress = helper.getCellRangeAddressable()->getRangeAddress(); - if( (thisAddress.StartRow == thisAddress.EndRow && thisAddress.EndRow == aOutlineAddress.EndRow ) || - (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn )) - { - bool bColumn = thisAddress.StartRow != thisAddress.EndRow; - ScDocument& rDoc = getDocumentFromRange( mxRange ); - ScOutlineTable* pOutlineTable = rDoc.GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), true); - const ScOutlineArray& rOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); - SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1); - const ScOutlineEntry* pEntry = rOutlineArray.GetEntryByPos( 0, nPos ); - if( pEntry ) - { - const bool bShowDetail = !pEntry->IsHidden(); - return uno::makeAny( bShowDetail ); - } - } - else + if( (thisAddress.StartRow != thisAddress.EndRow || thisAddress.EndRow != aOutlineAddress.EndRow ) && + (thisAddress.StartColumn != thisAddress.EndColumn || thisAddress.EndColumn != aOutlineAddress.EndColumn )) { throw uno::RuntimeException("Can not set Range.ShowDetail attribute" ); } + + bool bColumn = thisAddress.StartRow != thisAddress.EndRow; + ScDocument& rDoc = getDocumentFromRange( mxRange ); + ScOutlineTable* pOutlineTable = rDoc.GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), true); + const ScOutlineArray& rOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray(); + SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1); + const ScOutlineEntry* pEntry = rOutlineArray.GetEntryByPos( 0, nPos ); + if( pEntry ) + { + const bool bShowDetail = !pEntry->IsHidden(); + return uno::makeAny( bShowDetail ); + } + return aNULL(); } @@ -4913,21 +4914,20 @@ void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) // check if the specified range is a single summary column or row. table::CellRangeAddress thisAddress = helper.getCellRangeAddressable()->getRangeAddress(); - if( (thisAddress.StartRow == thisAddress.EndRow && thisAddress.EndRow == aOutlineAddress.EndRow ) || - (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn )) - { - // #FIXME, seems there is a different behavior between MSO and OOo. - // In OOo, the showDetail will show all the level entrys, while only show the first level entry in MSO - uno::Reference< sheet::XSheetOutline > xSheetOutline( helper.getSpreadSheet(), uno::UNO_QUERY_THROW ); - if( bShowDetail ) - xSheetOutline->showDetail( aOutlineAddress ); - else - xSheetOutline->hideDetail( aOutlineAddress ); - } - else + if( (thisAddress.StartRow != thisAddress.EndRow || thisAddress.EndRow != aOutlineAddress.EndRow ) && + (thisAddress.StartColumn != thisAddress.EndColumn || thisAddress.EndColumn != aOutlineAddress.EndColumn )) { throw uno::RuntimeException("Can not set Range.ShowDetail attribute" ); } + + // #FIXME, seems there is a different behavior between MSO and OOo. + // In OOo, the showDetail will show all the level entrys, while only show the first level entry in MSO + uno::Reference< sheet::XSheetOutline > xSheetOutline( helper.getSpreadSheet(), uno::UNO_QUERY_THROW ); + if( bShowDetail ) + xSheetOutline->showDetail( aOutlineAddress ); + else + xSheetOutline->hideDetail( aOutlineAddress ); + } uno::Reference< excel::XRange > SAL_CALL diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 8b4f68e64f50..1fd605d8b972 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -242,10 +242,11 @@ ScVbaWorkbooks::Open( const OUString& rFileName, const uno::Any& /*UpdateLinks*/ throw uno::RuntimeException("Expected value for Delimiter" ); OUString sStr; Delimiter >>= sStr; - if ( !sStr.isEmpty() ) - nDelim = sStr[0]; - else + if ( sStr.isEmpty() ) throw uno::RuntimeException("Incorrect value for Delimiter" ); + + nDelim = sStr[0]; + } getCurrentDelim() = nDelim; //set new current diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 265f3c46ad6b..4ded2493209a 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -335,26 +335,25 @@ ScVbaWorksheet::getEnableSelection() { uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW ); SCTAB nTab = 0; - if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) + if ( !ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) + throw uno::RuntimeException("Sheet Name does not exist." ); + + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); + bool bLockedCells = false; + bool bUnlockedCells = false; + if( pProtect ) { - uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); - ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); - bool bLockedCells = false; - bool bUnlockedCells = false; - if( pProtect ) - { - bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); - bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); - } - if( bLockedCells ) - return excel::XlEnableSelection::xlNoRestrictions; - if( bUnlockedCells ) - return excel::XlEnableSelection::xlUnlockedCells; - return excel::XlEnableSelection::xlNoSelection; + bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); + bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); } - else - throw uno::RuntimeException("Sheet Name does not exist." ); + if( bLockedCells ) + return excel::XlEnableSelection::xlNoRestrictions; + if( bUnlockedCells ) + return excel::XlEnableSelection::xlUnlockedCells; + return excel::XlEnableSelection::xlNoSelection; + } void @@ -369,31 +368,30 @@ ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW ); SCTAB nTab = 0; - if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) + if ( !ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) ) + throw uno::RuntimeException("Sheet Name does not exist." ); + + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); + ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); + ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); + // default is xlNoSelection + bool bLockedCells = false; + bool bUnlockedCells = false; + if( nSelection == excel::XlEnableSelection::xlNoRestrictions ) { - uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument(); - ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); - // default is xlNoSelection - bool bLockedCells = false; - bool bUnlockedCells = false; - if( nSelection == excel::XlEnableSelection::xlNoRestrictions ) - { - bLockedCells = true; - bUnlockedCells = true; - } - else if( nSelection == excel::XlEnableSelection::xlUnlockedCells ) - { - bUnlockedCells = true; - } - if( pProtect ) - { - pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells ); - pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells ); - } + bLockedCells = true; + bUnlockedCells = true; } - else - throw uno::RuntimeException("Sheet Name does not exist." ); + else if( nSelection == excel::XlEnableSelection::xlUnlockedCells ) + { + bUnlockedCells = true; + } + if( pProtect ) + { + pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells ); + pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells ); + } + } diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 7c209dd42bbe..0a9a79401d3a 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -350,17 +350,16 @@ void SAL_CALL ScVbaWorksheets::setVisible( const uno::Any& _visible ) { bool bState = false; - if ( _visible >>= bState ) + if ( !(_visible >>= bState) ) + throw uno::RuntimeException("Visible property doesn't support non boolean #FIXME" ); + + uno::Reference< container::XEnumeration > xEnum( createEnumeration(), uno::UNO_QUERY_THROW ); + while ( xEnum->hasMoreElements() ) { - uno::Reference< container::XEnumeration > xEnum( createEnumeration(), uno::UNO_QUERY_THROW ); - while ( xEnum->hasMoreElements() ) - { - uno::Reference< excel::XWorksheet > xSheet( xEnum->nextElement(), uno::UNO_QUERY_THROW ); - xSheet->setVisible( bState ? 1 : 0 ); - } + uno::Reference< excel::XWorksheet > xSheet( xEnum->nextElement(), uno::UNO_QUERY_THROW ); + xSheet->setVisible( bState ? 1 : 0 ); } - else - throw uno::RuntimeException("Visible property doesn't support non boolean #FIXME" ); + } void SAL_CALL |