summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/gdimtf.hxx2
-rw-r--r--vcl/inc/vcl/print.hxx1
-rw-r--r--vcl/source/gdi/gdimtf.cxx43
-rw-r--r--vcl/source/gdi/metaact.cxx2
-rwxr-xr-xvcl/source/gdi/print3.cxx38
-rw-r--r--vcl/source/glyphs/graphite_layout.cxx71
-rwxr-xr-xvcl/win/source/gdi/winlayout.cxx5
7 files changed, 136 insertions, 26 deletions
diff --git a/vcl/inc/vcl/gdimtf.hxx b/vcl/inc/vcl/gdimtf.hxx
index 06f7a0d14a2e..636fc4a979f3 100644
--- a/vcl/inc/vcl/gdimtf.hxx
+++ b/vcl/inc/vcl/gdimtf.hxx
@@ -158,6 +158,8 @@ public:
sal_Bool IsEqual( const GDIMetaFile& rMtf ) const;
BOOL Mirror( ULONG nMirrorFlags );
void Move( long nX, long nY );
+ // additional Move method getting specifics how to handle MapMode( MAP_PIXEL )
+ void Move( long nX, long nY, long nDPIX, long nDPIY );
void Scale( double fScaleX, double fScaleY );
void Scale( const Fraction& rScaleX, const Fraction& rScaleY );
void Rotate( long nAngle10 );
diff --git a/vcl/inc/vcl/print.hxx b/vcl/inc/vcl/print.hxx
index 96822d9bc756..0cd56e32d83d 100644
--- a/vcl/inc/vcl/print.hxx
+++ b/vcl/inc/vcl/print.hxx
@@ -520,6 +520,7 @@ public:
SAL_DLLPRIVATE void setPrinter( const boost::shared_ptr<Printer>& );
SAL_DLLPRIVATE void setOptionChangeHdl( const Link& );
SAL_DLLPRIVATE void createProgressDialog();
+ SAL_DLLPRIVATE bool isProgressCanceled() const;
SAL_DLLPRIVATE void setMultipage( const MultiPageSetup& );
SAL_DLLPRIVATE const MultiPageSetup& getMultipage() const;
SAL_DLLPRIVATE void setLastPage( sal_Bool i_bLastPage );
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 01b34286a086..818a31a10c0f 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -841,6 +841,49 @@ void GDIMetaFile::Move( long nX, long nY )
}
}
+void GDIMetaFile::Move( long nX, long nY, long nDPIX, long nDPIY )
+{
+ const Size aBaseOffset( nX, nY );
+ Size aOffset( aBaseOffset );
+ VirtualDevice aMapVDev;
+
+ aMapVDev.EnableOutput( FALSE );
+ aMapVDev.SetReferenceDevice( nDPIX, nDPIY );
+ aMapVDev.SetMapMode( GetPrefMapMode() );
+
+ for( MetaAction* pAct = (MetaAction*) First(); pAct; pAct = (MetaAction*) Next() )
+ {
+ const long nType = pAct->GetType();
+ MetaAction* pModAct;
+
+ if( pAct->GetRefCount() > 1 )
+ {
+ Replace( pModAct = pAct->Clone(), GetCurPos() );
+ pAct->Delete();
+ }
+ else
+ pModAct = pAct;
+
+ if( ( META_MAPMODE_ACTION == nType ) ||
+ ( META_PUSH_ACTION == nType ) ||
+ ( META_POP_ACTION == nType ) )
+ {
+ pModAct->Execute( &aMapVDev );
+ if( aMapVDev.GetMapMode().GetMapUnit() == MAP_PIXEL )
+ {
+ aOffset = aMapVDev.LogicToPixel( aBaseOffset, GetPrefMapMode() );
+ MapMode aMap( aMapVDev.GetMapMode() );
+ aOffset.Width() = aOffset.Width() * (double)aMap.GetScaleX();
+ aOffset.Height() = aOffset.Height() * (double)aMap.GetScaleY();
+ }
+ else
+ aOffset = aMapVDev.LogicToLogic( aBaseOffset, GetPrefMapMode(), aMapVDev.GetMapMode() );
+ }
+
+ pModAct->Move( aOffset.Width(), aOffset.Height() );
+ }
+}
+
// ------------------------------------------------------------------------
void GDIMetaFile::Scale( double fScaleX, double fScaleY )
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 752a4222bcb2..94f07b8f17d1 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -4078,7 +4078,7 @@ void MetaCommentAction::Move( long nXMove, long nYMove )
aMemStm >> aFill;
PolyPolygon aPath;
aFill.getPath( aPath );
- aPath.Scale( nXMove, nYMove );
+ aPath.Move( nXMove, nYMove );
aFill.setPath( aPath );
aDest << aFill;
}
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 0aeb928856fc..375c570f1a16 100755
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -444,8 +444,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr
if( ! aDlg.Execute() )
{
GDIMetaFile aPageFile;
- i_pController->setLastPage( sal_True );
- i_pController->getFilteredPageFile( 0, aPageFile );
+ i_pController->abortJob();
return;
}
if( aDlg.isPrintToFile() )
@@ -453,9 +452,7 @@ void Printer::ImplPrintJob( const boost::shared_ptr<PrinterController>& i_pContr
rtl::OUString aFile = queryFile( pController->getPrinter().get() );
if( ! aFile.getLength() )
{
- GDIMetaFile aPageFile;
- i_pController->setLastPage( sal_True );
- i_pController->getFilteredPageFile( 0, aPageFile );
+ i_pController->abortJob();
return;
}
pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LocalFileName" ) ),
@@ -612,7 +609,7 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
for( int nJobIteration = 0; nJobIteration < nJobs; nJobIteration++ )
{
- bool bError = false;
+ bool bError = false, bAborted = false;
if( mpPrinter->StartJob( pPrintFile,
i_rJobName,
Application::GetDisplayName(),
@@ -624,11 +621,11 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
mbJobActive = TRUE;
i_pController->createProgressDialog();
int nPages = i_pController->getFilteredPageCount();
- for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount; nOuterIteration++ )
+ for( int nOuterIteration = 0; nOuterIteration < nOuterRepeatCount && ! bAborted; nOuterIteration++ )
{
- for( int nPage = 0; nPage < nPages; nPage++ )
+ for( int nPage = 0; nPage < nPages && ! bAborted; nPage++ )
{
- for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount; nInnerIteration++ )
+ for( int nInnerIteration = 0; nInnerIteration < nInnerRepeatCount && ! bAborted; nInnerIteration++ )
{
if( nPage == nPages-1 &&
nOuterIteration == nOuterRepeatCount-1 &&
@@ -638,6 +635,11 @@ bool Printer::StartJob( const rtl::OUString& i_rJobName, boost::shared_ptr<vcl::
i_pController->setLastPage( sal_True );
}
i_pController->printFilteredPage( nPage );
+ if( i_pController->isProgressCanceled() )
+ {
+ i_pController->abortJob();
+ bAborted = true;
+ }
}
}
// FIXME: duplex ?
@@ -956,7 +958,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
o_rMtf.WindStart();
long nDX = (aPaperSize.Width() - aPageSize.aSize.Width()) / 2;
long nDY = (aPaperSize.Height() - aPageSize.aSize.Height()) / 2;
- o_rMtf.Move( nDX, nDY );
+ o_rMtf.Move( nDX, nDY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
o_rMtf.WindStart();
o_rMtf.SetPrefSize( aPaperSize );
aPageSize.aSize = aPaperSize;
@@ -1031,7 +1033,7 @@ PrinterController::PageSize PrinterController::getFilteredPageFile( int i_nFilte
long nOffY = (aSubPageSize.Height() - long(double(aPageSize.aSize.Height()) * fScale)) / 2;
long nX = rMPS.nLeftMargin + nOffX + nAdvX * nCellX;
long nY = rMPS.nTopMargin + nOffY + nAdvY * nCellY;
- aPageFile.Move( nX, nY );
+ aPageFile.Move( nX, nY, mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
aPageFile.WindStart();
// calculate border rectangle
Rectangle aSubPageRect( Point( nX, nY ),
@@ -1151,7 +1153,7 @@ void PrinterController::printFilteredPage( int i_nPage )
{
Point aPageOffset( mpImplData->mpPrinter->GetPageOffset() );
aPageFile.WindStart();
- aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y() );
+ aPageFile.Move( -aPageOffset.X(), -aPageOffset.Y(), mpImplData->mpPrinter->ImplGetDPIX(), mpImplData->mpPrinter->ImplGetDPIY() );
}
GDIMetaFile aCleanedFile;
@@ -1183,6 +1185,13 @@ void PrinterController::jobFinished( view::PrintableState )
void PrinterController::abortJob()
{
setJobState( view::PrintableState_JOB_ABORTED );
+ // applications (well, sw) depend on a page request with "IsLastPage" = true
+ // to free resources, else they (well, sw) will crash eventually
+ setLastPage( sal_True );
+ delete mpImplData->mpProgress;
+ mpImplData->mpProgress = NULL;
+ GDIMetaFile aMtf;
+ getPageFile( 0, aMtf, false );
}
void PrinterController::setLastPage( sal_Bool i_bLastPage )
@@ -1515,6 +1524,11 @@ void PrinterController::createProgressDialog()
mpImplData->mpProgress->reset();
}
+bool PrinterController::isProgressCanceled() const
+{
+ return mpImplData->mpProgress && mpImplData->mpProgress->isCanceled();
+}
+
void PrinterController::setMultipage( const MultiPageSetup& i_rMPS )
{
mpImplData->maMultiPage = i_rMPS;
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index ae7ec8246e33..0f7d2f5f3005 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -594,21 +594,39 @@ bool GraphiteLayout::LayoutText(ImplLayoutArgs & rArgs)
{
#ifdef GRCACHE
GrSegRecord * pSegRecord = NULL;
- gr::Segment * pSegment = CreateSegment(rArgs, &pSegRecord);
- if (!pSegment)
- return false;
-
+ gr::Segment * pSegment = NULL;
+ // Graphite can in rare cases crash with a zero length
+ if (rArgs.mnMinCharPos < rArgs.mnEndCharPos)
+ {
+ pSegment = CreateSegment(rArgs, &pSegRecord);
+ if (!pSegment)
+ return false;
+ }
+ else
+ {
+ clear();
+ return true;
+ }
// layout the glyphs as required by OpenOffice
bool success = LayoutGlyphs(rArgs, pSegment, pSegRecord);
if (pSegRecord) pSegRecord->unlock();
else delete pSegment;
#else
- gr::Segment * pSegment = CreateSegment(rArgs);
- if (!pSegment)
- return false;
- bool success = LayoutGlyphs(rArgs, pSegment);
- delete pSegment;
+ gr::Segment * pSegment = NULL;
+ bool success = true;
+ if (rArgs.mnMinCharPos < rArgs.mnEndCharPos)
+ {
+ pSegment = CreateSegment(rArgs);
+ if (!pSegment)
+ return false;
+ success = LayoutGlyphs(rArgs, pSegment);
+ if (pSegment) delete pSegment;
+ }
+ else
+ {
+ clear();
+ }
#endif
return success;
}
@@ -659,7 +677,7 @@ public:
return hash;
};
protected:
- virtual void UniqueCacheInfo(std::wstring & stuFace, bool & fBold, bool & fItalic)
+ virtual void UniqueCacheInfo( ext_std::wstring& stuFace, bool& fBold, bool& fItalic )
{
#ifdef WIN32
dynamic_cast<GraphiteWinFont&>(mrRealFont).UniqueCacheInfo(stuFace, fBold, fItalic);
@@ -722,7 +740,7 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs)
(GraphiteCacheHandler::instance).getCache(aFontHash);
if (pCache)
{
- *pSegRecord = pCache->getSegment(rArgs, bRtl, nSegCharLimit);
+ *pSegRecord = pCache->getSegment(rArgs, bRtl, limit);
if (*pSegRecord)
{
pSegment = (*pSegRecord)->getSegment();
@@ -736,7 +754,34 @@ gr::Segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs)
(*pSegRecord)->clearVectors();
}
mpTextSrc->switchLayoutArgs(rArgs);
- return pSegment;
+ if (limit > rArgs.mnMinCharPos && limit == rArgs.mnEndCharPos
+ && pSegment->stopCharacter() != limit)
+ {
+ // check that the last character is not part of a ligature
+ glyph_set_range_t aGlyphSet = pSegment->charToGlyphs(limit - 1);
+ if (aGlyphSet.first == aGlyphSet.second)
+ {
+ // no glyphs associated with this glyph - occurs mid ligature
+ pSegment = NULL;
+ *pSegRecord = NULL;
+ }
+ else
+ {
+ while (aGlyphSet.first != aGlyphSet.second)
+ {
+ int lastChar = static_cast<int>((*aGlyphSet.first).lastChar());
+ if (lastChar >= limit)
+ {
+ pSegment = NULL;
+ *pSegRecord = NULL;
+ break;
+ }
+ aGlyphSet.first++;
+ }
+ }
+ }
+ if (pSegment)
+ return pSegment;
}
}
#endif
@@ -1058,7 +1103,7 @@ void GraphiteLayout::ApplyDXArray(ImplLayoutArgs &args, std::vector<int> & rDelt
{
nXOffset = args.mpDXArray[nChars - 1] - mvCharDxs[nChars - 1];
}
- int nPrevClusterGlyph = (bRtl)? mvGlyphs.size() : -1;
+ int nPrevClusterGlyph = (bRtl)? (signed)mvGlyphs.size() : -1;
int nPrevClusterLastChar = -1;
for (size_t i = 0; i < nChars; i++)
{
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 6f0c98279e7b..806d3b420b33 100755
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -2894,6 +2894,11 @@ void GraphiteWinLayout::RestoreDC(gr::Segment & segment) const
bool GraphiteWinLayout::LayoutText( ImplLayoutArgs & args)
{
+ if (args.mnMinCharPos >= args.mnEndCharPos)
+ {
+ maImpl.clear();
+ return true;
+ }
HFONT hUnRotatedFont;
if (args.mnOrientation)
{