Kaydet (Commit) 277ef71c authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Reduce excessive scoping.

üst 2a5e99cb
...@@ -612,27 +612,66 @@ bool ScXMLExport::HasDrawPages(uno::Reference <sheet::XSpreadsheetDocument>& xDo ...@@ -612,27 +612,66 @@ bool ScXMLExport::HasDrawPages(uno::Reference <sheet::XSpreadsheetDocument>& xDo
return (xDocProps.is() && ::cppu::any2bool( xDocProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_HASDRAWPAGES))) )); return (xDocProps.is() && ::cppu::any2bool( xDocProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_HASDRAWPAGES))) ));
} }
void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount) namespace {
/**
* Update the progress bar state when an instance of this class goes out of
* scope.
*/
class ProgressBarUpdater
{ {
if (GetModel().is()) ProgressBarHelper& mrHelper;
{ const sal_Int32& mrTableCount;
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); const sal_Int32& mrShapesCount;
if ( xSpreadDoc.is()) const sal_Int32 mnCellCount;
{ public:
uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); ProgressBarUpdater(ProgressBarHelper& rHelper,
if ( xIndex.is() ) const sal_Int32& rTableCount, const sal_Int32& rShapesCount,
const sal_Int32 nCellCount) :
mrHelper(rHelper),
mrTableCount(rTableCount),
mrShapesCount(rShapesCount),
mnCellCount(nCellCount) {}
~ProgressBarUpdater()
{ {
sal_Int32 nRef = mnCellCount + (2 * mrTableCount) + (2 * mrShapesCount);
mrHelper.SetReference(nRef);
mrHelper.SetValue(0);
}
};
}
void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount)
{
ProgressBarUpdater(*GetProgressBarHelper(), nTableCount, nShapesCount, nCellCount);
if (!GetModel().is())
return;
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc(GetModel(), uno::UNO_QUERY);
if (!xSpreadDoc.is())
return;
uno::Reference<container::XIndexAccess> xIndex(xSpreadDoc->getSheets(), uno::UNO_QUERY);
if (!xIndex.is())
return;
nTableCount = xIndex->getCount(); nTableCount = xIndex->getCount();
if (!pSharedData) if (!pSharedData)
CreateSharedData(nTableCount); CreateSharedData(nTableCount);
pCellStyles->AddNewTable(nTableCount - 1); pCellStyles->AddNewTable(nTableCount - 1);
pDoc->InitializeAllNoteCaptions( true ); pDoc->InitializeAllNoteCaptions(true);
if (HasDrawPages(xSpreadDoc)) if (!HasDrawPages(xSpreadDoc))
{ return;
rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
rtl::OUString sCaptionPoint(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint"));
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable) for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
{ {
nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable ); nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
if (xDrawPageSupplier.is()) if (xDrawPageSupplier.is())
{ {
...@@ -641,23 +680,23 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo ...@@ -641,23 +680,23 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo
aDrawPage.bHasForms = false; aDrawPage.bHasForms = false;
aDrawPage.xDrawPage.set(xDrawPage); aDrawPage.xDrawPage.set(xDrawPage);
pSharedData->AddDrawPage(aDrawPage, nTable); pSharedData->AddDrawPage(aDrawPage, nTable);
uno::Reference<container::XIndexAccess> xShapesIndex (xDrawPage, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xShapesIndex(xDrawPage, uno::UNO_QUERY);
if (xShapesIndex.is()) if (xShapesIndex.is())
{ {
sal_Int32 nShapes(xShapesIndex->getCount()); sal_Int32 nShapes = xShapesIndex->getCount();
for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape) for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
{ {
uno::Reference<drawing::XShape> xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY);
if (xShape.is()) if (xShape.is())
{ {
uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
if( xShapeProp.is() ) if( xShapeProp.is() )
{ {
sal_Int16 nLayerID = 0; sal_Int16 nLayerID = 0;
if( xShapeProp->getPropertyValue(sLayerID) >>= nLayerID ) if( xShapeProp->getPropertyValue(sLayerID) >>= nLayerID )
{ {
if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) ) if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
CollectInternalShape( xShape ); CollectInternalShape(xShape);
else else
{ {
++nShapesCount; ++nShapesCount;
...@@ -689,13 +728,6 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo ...@@ -689,13 +728,6 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo
} }
} }
} }
}
}
}
}
sal_Int32 nRef(nCellCount + (2 * nTableCount) + (2 * nShapesCount));
GetProgressBarHelper()->SetReference(nRef);
GetProgressBarHelper()->SetValue(0);
} }
void ScXMLExport::CollectShapesAutoStyles(const sal_Int32 nTableCount) void ScXMLExport::CollectShapesAutoStyles(const sal_Int32 nTableCount)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment