summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-01-29 04:19:14 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-01-30 02:21:07 +0100
commit36d99c6cb26938a7cbeae77e64fcef5bd250025a (patch)
tree27fc5bca438d7e9df550d9b733418e1bab9f2f96 /sc
parentmake some more methods const (diff)
downloadcore-36d99c6cb26938a7cbeae77e64fcef5bd250025a.tar.gz
core-36d99c6cb26938a7cbeae77e64fcef5bd250025a.zip
move these methods to ScDocShell
Change-Id: I050e4d992c601c7af1a83b30137ab38fd05b8a74
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/documen3.cxx89
-rw-r--r--sc/source/ui/docshell/docsh4.cxx88
-rw-r--r--sc/source/ui/docshell/docsh6.cxx4
-rw-r--r--sc/source/ui/inc/docsh.hxx3
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx2
5 files changed, 91 insertions, 95 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 60e5a4e2bd35..fd505d6c49d2 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1778,95 +1778,6 @@ void ScDocument::SetEmbedded( const Rectangle& rRect ) // aus VisArea (
aEmbedRange = GetRange( nVisibleTab, rRect );
}
-// VisArea auf Zellgrenzen anpassen
-
-static void lcl_SnapHor( ScTable* pTable, long& rVal, SCCOL& rStartCol )
-{
- SCCOL nCol = 0;
- long nTwips = (long) (rVal / HMM_PER_TWIPS);
- long nSnap = 0;
- while ( nCol<MAXCOL )
- {
- long nAdd = pTable->GetColWidth(nCol);
- if ( nSnap + nAdd/2 < nTwips || nCol < rStartCol )
- {
- nSnap += nAdd;
- ++nCol;
- }
- else
- break;
- }
- rVal = (long) ( nSnap * HMM_PER_TWIPS );
- rStartCol = nCol;
-}
-
-static void lcl_SnapVer( ScTable* pTable, long& rVal, SCROW& rStartRow )
-{
- SCROW nRow = 0;
- long nTwips = (long) (rVal / HMM_PER_TWIPS);
- long nSnap = 0;
-
- bool bFound = false;
- for (SCROW i = nRow; i <= MAXROW; ++i)
- {
- SCROW nLastRow;
- if (pTable->RowHidden(i, NULL, &nLastRow))
- {
- i = nLastRow;
- continue;
- }
-
- nRow = i;
- long nAdd = pTable->GetRowHeight(i);
- if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow )
- {
- nSnap += nAdd;
- ++nRow;
- }
- else
- {
- bFound = true;
- break;
- }
- }
- if (!bFound)
- nRow = MAXROW; // all hidden down to the bottom
-
- rVal = (long) ( nSnap * HMM_PER_TWIPS );
- rStartRow = nRow;
-}
-
-void ScDocument::SnapVisArea( Rectangle& rRect ) const
-{
- ScTable* pTable = NULL;
- if (nVisibleTab < static_cast<SCTAB>(maTabs.size()))
- pTable = maTabs[nVisibleTab];
- else
- OSL_FAIL("table out of range");
- if (!pTable)
- {
- OSL_FAIL("SetEmbedded ohne Tabelle");
- return;
- }
-
- bool bNegativePage = IsNegativePage( nVisibleTab );
- if ( bNegativePage )
- ScDrawLayer::MirrorRectRTL( rRect ); // calculate with positive (LTR) values
-
- SCCOL nCol = 0;
- lcl_SnapHor( pTable, rRect.Left(), nCol );
- ++nCol; // mindestens eine Spalte
- lcl_SnapHor( pTable, rRect.Right(), nCol );
-
- SCROW nRow = 0;
- lcl_SnapVer( pTable, rRect.Top(), nRow );
- ++nRow; // mindestens eine Zeile
- lcl_SnapVer( pTable, rRect.Bottom(), nRow );
-
- if ( bNegativePage )
- ScDrawLayer::MirrorRectRTL( rRect ); // back to real rectangle
-}
-
ScDocProtection* ScDocument::GetDocProtection() const
{
return pDocProtection.get();
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index df3f2ade6650..4509c11b6a30 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -1874,7 +1874,7 @@ void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uI
Rectangle aBoundRect = GetVisArea( ASPECT_THUMBNAIL );
ScViewData aTmpData( this, NULL );
aTmpData.SetTabNo(nVisTab);
- aDocument.SnapVisArea( aBoundRect );
+ SnapVisArea( aBoundRect );
aTmpData.SetScreen( aBoundRect );
ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, sal_True );
}
@@ -1883,7 +1883,7 @@ void ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, sal_uI
Rectangle aBoundRect = SfxObjectShell::GetVisArea();
ScViewData aTmpData( this, NULL );
aTmpData.SetTabNo(nVisTab);
- aDocument.SnapVisArea( aBoundRect );
+ SnapVisArea( aBoundRect );
aTmpData.SetScreen( aBoundRect );
ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, sal_True );
}
@@ -1907,7 +1907,7 @@ Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
sal_Bool bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() );
if ( bNegativePage )
ScDrawLayer::MirrorRectRTL( aArea );
- aDocument.SnapVisArea( aArea );
+ SnapVisArea( aArea );
return aArea;
}
else if( nAspect == ASPECT_CONTENT && eShellMode != SFX_CREATE_MODE_EMBEDDED )
@@ -1940,6 +1940,88 @@ Rectangle ScDocShell::GetVisArea( sal_uInt16 nAspect ) const
return SfxObjectShell::GetVisArea( nAspect );
}
+namespace {
+
+void SnapHor( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCCOL& rStartCol )
+{
+ SCCOL nCol = 0;
+ long nTwips = (long) (rVal / HMM_PER_TWIPS);
+ long nSnap = 0;
+ while ( nCol<MAXCOL )
+ {
+ long nAdd = rDoc.GetColWidth(nCol, nTab);
+ if ( nSnap + nAdd/2 < nTwips || nCol < rStartCol )
+ {
+ nSnap += nAdd;
+ ++nCol;
+ }
+ else
+ break;
+ }
+ rVal = (long) ( nSnap * HMM_PER_TWIPS );
+ rStartCol = nCol;
+}
+
+void SnapVer( const ScDocument& rDoc, SCTAB nTab, long& rVal, SCROW& rStartRow )
+{
+ SCROW nRow = 0;
+ long nTwips = (long) (rVal / HMM_PER_TWIPS);
+ long nSnap = 0;
+
+ bool bFound = false;
+ for (SCROW i = nRow; i <= MAXROW; ++i)
+ {
+ SCROW nLastRow;
+ if (rDoc.RowHidden(i, nTab, NULL, &nLastRow))
+ {
+ i = nLastRow;
+ continue;
+ }
+
+ nRow = i;
+ long nAdd = rDoc.GetRowHeight(i, nTab);
+ if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow )
+ {
+ nSnap += nAdd;
+ ++nRow;
+ }
+ else
+ {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound)
+ nRow = MAXROW; // all hidden down to the bottom
+
+ rVal = (long) ( nSnap * HMM_PER_TWIPS );
+ rStartRow = nRow;
+}
+
+
+}
+
+void ScDocShell::SnapVisArea( Rectangle& rRect ) const
+{
+ SCTAB nTab = aDocument.GetVisibleTab();
+ bool bNegativePage = aDocument.IsNegativePage( nTab );
+ if ( bNegativePage )
+ ScDrawLayer::MirrorRectRTL( rRect ); // calculate with positive (LTR) values
+
+ SCCOL nCol = 0;
+ SnapHor( aDocument, nTab, rRect.Left(), nCol );
+ ++nCol; // mindestens eine Spalte
+ SnapHor( aDocument, nTab, rRect.Right(), nCol );
+
+ SCROW nRow = 0;
+ SnapVer( aDocument, nTab, rRect.Top(), nRow );
+ ++nRow; // mindestens eine Zeile
+ SnapVer( aDocument, nTab, rRect.Bottom(), nRow );
+
+ if ( bNegativePage )
+ ScDrawLayer::MirrorRectRTL( rRect ); // back to real rectangle
+}
+
void ScDocShell::GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet,
SCTAB nCurTab,
bool& rbHeader,
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 4c035ef5eb3a..c9eec1c1a0a6 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -133,7 +133,7 @@ void ScDocShell::SetVisAreaOrSize( const Rectangle& rVisArea, sal_Bool bModifySt
// when loading an ole object, the VisArea is set from the document's
// view settings and must be used as-is (document content may not be complete yet).
if ( !aDocument.IsImportingXML() )
- aDocument.SnapVisArea( aArea );
+ SnapVisArea( aArea );
//TODO/LATER: it's unclear which IPEnv is used here
/*
@@ -209,7 +209,7 @@ void ScDocShell::UpdateOle( const ScViewData* pViewData, sal_Bool bSnapSize )
else
aNewArea.SetPos( aMMRect.TopLeft() );
if (bSnapSize)
- aDocument.SnapVisArea(aNewArea); // uses the new VisibleTab
+ SnapVisArea(aNewArea); // uses the new VisibleTab
}
if (aNewArea != aOldArea)
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 854763b3448c..b49bbe462ea1 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -429,6 +429,9 @@ public:
virtual void SetChangeRecording( bool bActivate );
virtual bool SetProtectionPassword( const String &rPassword );
virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
+
+
+ void SnapVisArea( Rectangle& rRect ) const;
};
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index d154b0148b53..70868b3cc3bd 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -467,7 +467,7 @@ void ScTabViewShell::QueryObjAreaPixel( Rectangle& rRect ) const
}
aLogicRect.SetSize( aLogicSize );
- pDoc->SnapVisArea( aLogicRect );
+ pViewData->GetDocShell()->SnapVisArea( aLogicRect );
rRect.SetSize( pWin->LogicToPixel( aLogicRect.GetSize() ) );
}