summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-13 09:08:59 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-13 09:27:47 +0200
commit8a1ad93aa41e1749eb6f1eedf1f25015d15f41e7 (patch)
treed9b2b8d9028da7d0d03dd68ddfda3388cf8fe9df /sd
parentcc6bd1254296b8dccbf4af2e1138e640d11df2c4 (diff)
reduce code duplication
Change-Id: Ie5910239d7a54a29262e556af779bda9fa2dddca
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/unomodel.hxx4
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx78
2 files changed, 51 insertions, 31 deletions
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index e620ca5d96cb..c7bf63bb8394 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -56,6 +56,7 @@ class SdPage;
namespace sd {
class DrawDocShell;
+class DrawViewShell;
}
extern OUString getPageApiName( SdPage* pPage );
@@ -123,6 +124,9 @@ private:
OUString maBuildId;
void initializeDocument();
+
+ sd::DrawViewShell* GetViewShell();
+
public:
SdXImpressDocument( ::sd::DrawDocShell* pShell, bool bClipBoard = false ) throw();
SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard = false ) throw();
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 79146e9c2ccc..83da209c16df 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2188,11 +2188,26 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
}
}
+DrawViewShell* SdXImpressDocument::GetViewShell()
+{
+ DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell());
+ if (!pViewSh)
+ {
+ SAL_WARN("sd", "DrawViewShell not available!");
+ return NULL;
+ }
+ return pViewSh;
+}
+
void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return;
+
// Scaling. Must convert from pixels to twips. We know
// that VirtualDevices use a DPI of 96.
// We specifically calculate these scales first as we're still
@@ -2221,26 +2236,27 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
rDevice.SetMapMode( aMapMode );
rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) );
- mpDoc->GetDocSh()->GetViewShell()->GetView()->CompleteRedraw(
- &rDevice,
- Region(
- Rectangle( Point( nTilePosX, nTilePosY ),
- Size( nTileWidth, nTileHeight ) ) ) );
+
+ Point aPoint(nTilePosX, nTilePosY);
+ Size aSize(nTileWidth, nTileHeight);
+ Rectangle aRect(aPoint, aSize);
+
+ pViewSh->GetView()->CompleteRedraw(&rDevice, Region(aRect));
}
void SdXImpressDocument::setPart( int nPart )
{
- DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() );
- if (pViewSh)
- {
- // TODO: have an API to allow selecting between PK_STANDARD (just slide)
- // and PK_NOTES (which shows the combined slide above notes). There is alo
- // a PK_HANDOUT -- that however just shows multiple empty pages (it's also
- // only possible to select page 0 in this mode, I have no idea how you
- // then actually select what is on the handout page, which defaults to
- // a 4x4 grid of empty pages).
- pViewSh->SwitchPage( nPart );
- }
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return;
+
+ // TODO: have an API to allow selecting between PK_STANDARD (just slide)
+ // and PK_NOTES (which shows the combined slide above notes). There is alo
+ // a PK_HANDOUT -- that however just shows multiple empty pages (it's also
+ // only possible to select page 0 in this mode, I have no idea how you
+ // then actually select what is on the handout page, which defaults to
+ // a 4x4 grid of empty pages).
+ pViewSh->SwitchPage( nPart );
}
int SdXImpressDocument::getParts()
@@ -2252,29 +2268,31 @@ int SdXImpressDocument::getParts()
int SdXImpressDocument::getPart()
{
- DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() );
- if (pViewSh)
- {
- // curPageId seems to start at 1
- return pViewSh->GetCurPageId() - 1;
- }
- return 0;
+ DrawViewShell* pViewSh = GetViewShell();
+ if (!pViewSh)
+ return 0;
+
+ // curPageId seems to start at 1
+ return pViewSh->GetCurPageId() - 1;
}
OUString SdXImpressDocument::getPartName( int nPart )
{
SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD );
- assert( pPage );
+ if (!pPage)
+ {
+ SAL_WARN("sd", "DrawViewShell not available!");
+ return OUString();
+ }
+
return pPage->GetName();
}
void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
{
- DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() );
+ DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh)
- {
return;
- }
PageKind aPageKind( PK_STANDARD );
switch ( ePartMode )
@@ -2303,14 +2321,12 @@ void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
Size SdXImpressDocument::getDocumentSize()
{
- DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDoc->GetDocSh()->GetViewShell());
+ DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh)
- {
- SAL_WARN("sd", "DrawViewShell not available!");
return Size();
- }
SdrPageView* pCurPageView = pViewSh->GetView()->GetSdrPageView();
+
Size aSize = pCurPageView->GetPageRect().GetSize();
// Convert the size in 100th mm to TWIP
// See paintTile above for further info.