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

Reduce excessive scoping.

üst 2a5e99cb
...@@ -612,77 +612,112 @@ bool ScXMLExport::HasDrawPages(uno::Reference <sheet::XSpreadsheetDocument>& xDo ...@@ -612,77 +612,112 @@ 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))) ));
} }
namespace {
/**
* Update the progress bar state when an instance of this class goes out of
* scope.
*/
class ProgressBarUpdater
{
ProgressBarHelper& mrHelper;
const sal_Int32& mrTableCount;
const sal_Int32& mrShapesCount;
const sal_Int32 mnCellCount;
public:
ProgressBarUpdater(ProgressBarHelper& rHelper,
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) void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCount, const sal_Int32 nCellCount)
{ {
if (GetModel().is()) 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();
if (!pSharedData)
CreateSharedData(nTableCount);
pCellStyles->AddNewTable(nTableCount - 1);
pDoc->InitializeAllNoteCaptions(true);
if (!HasDrawPages(xSpreadDoc))
return;
rtl::OUString sCaptionPoint(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint"));
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable)
{ {
uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY ); nCurrentTable = sal::static_int_cast<sal_uInt16>(nTable);
if ( xSpreadDoc.is()) uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY);
if (xDrawPageSupplier.is())
{ {
uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY ); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage());
if ( xIndex.is() ) ScMyDrawPage aDrawPage;
aDrawPage.bHasForms = false;
aDrawPage.xDrawPage.set(xDrawPage);
pSharedData->AddDrawPage(aDrawPage, nTable);
uno::Reference<container::XIndexAccess> xShapesIndex(xDrawPage, uno::UNO_QUERY);
if (xShapesIndex.is())
{ {
nTableCount = xIndex->getCount(); sal_Int32 nShapes = xShapesIndex->getCount();
if (!pSharedData) for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape)
CreateSharedData(nTableCount);
pCellStyles->AddNewTable(nTableCount - 1);
pDoc->InitializeAllNoteCaptions( true );
if (HasDrawPages(xSpreadDoc))
{ {
rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )); uno::Reference<drawing::XShape> xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY);
for (SCTAB nTable = 0; nTable < nTableCount; ++nTable) if (xShape.is())
{ {
nCurrentTable = sal::static_int_cast<sal_uInt16>( nTable ); uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xIndex->getByIndex(nTable), uno::UNO_QUERY); if( xShapeProp.is() )
if (xDrawPageSupplier.is())
{ {
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage()); sal_Int16 nLayerID = 0;
ScMyDrawPage aDrawPage; if( xShapeProp->getPropertyValue(sLayerID) >>= nLayerID )
aDrawPage.bHasForms = false;
aDrawPage.xDrawPage.set(xDrawPage);
pSharedData->AddDrawPage(aDrawPage, nTable);
uno::Reference<container::XIndexAccess> xShapesIndex (xDrawPage, uno::UNO_QUERY);
if (xShapesIndex.is())
{ {
sal_Int32 nShapes(xShapesIndex->getCount()); if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
for (sal_Int32 nShape = 0; nShape < nShapes; ++nShape) CollectInternalShape(xShape);
else
{ {
uno::Reference<drawing::XShape> xShape(xShapesIndex->getByIndex(nShape), uno::UNO_QUERY); ++nShapesCount;
if (xShape.is()) if (SvxShape* pShapeImp = SvxShape::getImplementation(xShape))
{ {
uno::Reference< beans::XPropertySet > xShapeProp( xShape, uno::UNO_QUERY ); if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
if( xShapeProp.is() )
{ {
sal_Int16 nLayerID = 0; if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData( pSdrObj ))
if( xShapeProp->getPropertyValue(sLayerID) >>= nLayerID )
{ {
if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) ) ScMyShape aMyShape;
CollectInternalShape( xShape ); aMyShape.aAddress = pAnchor->maStart;
else aMyShape.aEndAddress = pAnchor->maEnd;
{ aMyShape.nEndX = pAnchor->maEndOffset.X();
++nShapesCount; aMyShape.nEndY = pAnchor->maEndOffset.Y();
if (SvxShape* pShapeImp = SvxShape::getImplementation(xShape)) aMyShape.xShape = xShape;
{ pSharedData->AddNewShape(aMyShape);
if (SdrObject *pSdrObj = pShapeImp->GetSdrObject()) pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
{ pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData( pSdrObj ))
{
ScMyShape aMyShape;
aMyShape.aAddress = pAnchor->maStart;
aMyShape.aEndAddress = pAnchor->maEnd;
aMyShape.nEndX = pAnchor->maEndOffset.X();
aMyShape.nEndY = pAnchor->maEndOffset.Y();
aMyShape.xShape = xShape;
pSharedData->AddNewShape(aMyShape);
pSharedData->SetLastColumn(nTable, pAnchor->maStart.Col());
pSharedData->SetLastRow(nTable, pAnchor->maStart.Row());
}
else
pSharedData->AddTableShape(nTable, xShape);
}
}
}
} }
else
pSharedData->AddTableShape(nTable, xShape);
} }
} }
} }
...@@ -693,9 +728,6 @@ void ScXMLExport::CollectSharedData(sal_Int32& nTableCount, sal_Int32& nShapesCo ...@@ -693,9 +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