Kaydet (Commit) 8a1ad93a authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

reduce code duplication

Change-Id: Ie5910239d7a54a29262e556af779bda9fa2dddca
üst cc6bd125
...@@ -56,6 +56,7 @@ class SdPage; ...@@ -56,6 +56,7 @@ class SdPage;
namespace sd { namespace sd {
class DrawDocShell; class DrawDocShell;
class DrawViewShell;
} }
extern OUString getPageApiName( SdPage* pPage ); extern OUString getPageApiName( SdPage* pPage );
...@@ -123,6 +124,9 @@ private: ...@@ -123,6 +124,9 @@ private:
OUString maBuildId; OUString maBuildId;
void initializeDocument(); void initializeDocument();
sd::DrawViewShell* GetViewShell();
public: public:
SdXImpressDocument( ::sd::DrawDocShell* pShell, bool bClipBoard = false ) throw(); SdXImpressDocument( ::sd::DrawDocShell* pShell, bool bClipBoard = false ) throw();
SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard = false ) throw(); SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard = false ) throw();
......
...@@ -2188,11 +2188,26 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r ...@@ -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, void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight, int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY, int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight ) long nTileWidth, long nTileHeight )
{ {
DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh)
return;
// Scaling. Must convert from pixels to twips. We know // Scaling. Must convert from pixels to twips. We know
// that VirtualDevices use a DPI of 96. // that VirtualDevices use a DPI of 96.
// We specifically calculate these scales first as we're still // We specifically calculate these scales first as we're still
...@@ -2221,18 +2236,20 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice, ...@@ -2221,18 +2236,20 @@ void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
rDevice.SetMapMode( aMapMode ); rDevice.SetMapMode( aMapMode );
rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) ); rDevice.SetOutputSizePixel( Size(nOutputWidth, nOutputHeight) );
mpDoc->GetDocSh()->GetViewShell()->GetView()->CompleteRedraw(
&rDevice, Point aPoint(nTilePosX, nTilePosY);
Region( Size aSize(nTileWidth, nTileHeight);
Rectangle( Point( nTilePosX, nTilePosY ), Rectangle aRect(aPoint, aSize);
Size( nTileWidth, nTileHeight ) ) ) );
pViewSh->GetView()->CompleteRedraw(&rDevice, Region(aRect));
} }
void SdXImpressDocument::setPart( int nPart ) void SdXImpressDocument::setPart( int nPart )
{ {
DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); DrawViewShell* pViewSh = GetViewShell();
if (pViewSh) if (!pViewSh)
{ return;
// TODO: have an API to allow selecting between PK_STANDARD (just slide) // 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 // 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 // a PK_HANDOUT -- that however just shows multiple empty pages (it's also
...@@ -2240,7 +2257,6 @@ void SdXImpressDocument::setPart( int nPart ) ...@@ -2240,7 +2257,6 @@ void SdXImpressDocument::setPart( int nPart )
// then actually select what is on the handout page, which defaults to // then actually select what is on the handout page, which defaults to
// a 4x4 grid of empty pages). // a 4x4 grid of empty pages).
pViewSh->SwitchPage( nPart ); pViewSh->SwitchPage( nPart );
}
} }
int SdXImpressDocument::getParts() int SdXImpressDocument::getParts()
...@@ -2252,29 +2268,31 @@ int SdXImpressDocument::getParts() ...@@ -2252,29 +2268,31 @@ int SdXImpressDocument::getParts()
int SdXImpressDocument::getPart() int SdXImpressDocument::getPart()
{ {
DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); DrawViewShell* pViewSh = GetViewShell();
if (pViewSh) if (!pViewSh)
{ return 0;
// curPageId seems to start at 1 // curPageId seems to start at 1
return pViewSh->GetCurPageId() - 1; return pViewSh->GetCurPageId() - 1;
}
return 0;
} }
OUString SdXImpressDocument::getPartName( int nPart ) OUString SdXImpressDocument::getPartName( int nPart )
{ {
SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD ); SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD );
assert( pPage ); if (!pPage)
{
SAL_WARN("sd", "DrawViewShell not available!");
return OUString();
}
return pPage->GetName(); return pPage->GetName();
} }
void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode ) void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
{ {
DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh) if (!pViewSh)
{
return; return;
}
PageKind aPageKind( PK_STANDARD ); PageKind aPageKind( PK_STANDARD );
switch ( ePartMode ) switch ( ePartMode )
...@@ -2303,14 +2321,12 @@ void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode ) ...@@ -2303,14 +2321,12 @@ void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
Size SdXImpressDocument::getDocumentSize() Size SdXImpressDocument::getDocumentSize()
{ {
DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDoc->GetDocSh()->GetViewShell()); DrawViewShell* pViewSh = GetViewShell();
if (!pViewSh) if (!pViewSh)
{
SAL_WARN("sd", "DrawViewShell not available!");
return Size(); return Size();
}
SdrPageView* pCurPageView = pViewSh->GetView()->GetSdrPageView(); SdrPageView* pCurPageView = pViewSh->GetView()->GetSdrPageView();
Size aSize = pCurPageView->GetPageRect().GetSize(); Size aSize = pCurPageView->GetPageRect().GetSize();
// Convert the size in 100th mm to TWIP // Convert the size in 100th mm to TWIP
// See paintTile above for further info. // See paintTile above for further info.
......
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