summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/wrapper/wrapper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/pdfimport/wrapper/wrapper.cxx')
-rwxr-xr-xsdext/source/pdfimport/wrapper/wrapper.cxx52
1 files changed, 47 insertions, 5 deletions
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 51817ce5eacf..daa7cd42b61e 100755
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -158,6 +158,8 @@ class Parser
sal_Int32 m_nNextToken;
sal_Int32 m_nCharIndex;
+ const double minAreaThreshold;
+ const double minLineWidth;
::rtl::OString readNextToken();
void readInt32( sal_Int32& o_Value );
@@ -167,7 +169,7 @@ class Parser
double readDouble();
void readBinaryData( uno::Sequence<sal_Int8>& rBuf );
- uno::Reference<rendering::XPolyPolygon2D> readPath();
+ uno::Reference<rendering::XPolyPolygon2D> readPath( double* );
void readChar();
void readLineCap();
@@ -199,7 +201,9 @@ public:
m_aLine(),
m_aFontMap(101),
m_nNextToken(-1),
- m_nCharIndex(-1)
+ m_nCharIndex(-1),
+ minAreaThreshold( 300.0 ),
+ minLineWidth( 12 )
{}
void parseLine( const ::rtl::OString& rLine );
@@ -306,7 +310,7 @@ void Parser::readBinaryData( uno::Sequence<sal_Int8>& rBuf )
OSL_PRECOND(nRes==osl_File_E_None, "inconsistent data");
}
-uno::Reference<rendering::XPolyPolygon2D> Parser::readPath()
+uno::Reference<rendering::XPolyPolygon2D> Parser::readPath( double* pArea = NULL )
{
const rtl::OString aSubPathMarker( "subpath" );
@@ -366,6 +370,15 @@ uno::Reference<rendering::XPolyPolygon2D> Parser::readPath()
readNextToken();
}
+ if( pArea )
+ {
+ basegfx::B2DRange aRange( aResult.getB2DRange() );
+ if( aRange.getWidth() <= minLineWidth || aRange.getHeight() <= minLineWidth)
+ *pArea = 0.0;
+ else
+ *pArea = aRange.getWidth() * aRange.getHeight();
+ }
+
return static_cast<rendering::XLinePolyPolygon2D*>(
new basegfx::unotools::UnoPolyPolygon(aResult));
}
@@ -805,9 +818,25 @@ void Parser::parseLine( const ::rtl::OString& rLine )
case EOCLIPPATH:
m_pSink->intersectEoClip(readPath()); break;
case EOFILLPATH:
- m_pSink->eoFillPath(readPath()); break;
+ {
+ double area = 0.0;
+ uno::Reference<rendering::XPolyPolygon2D> path = readPath( &area );
+ m_pSink->eoFillPath(path);
+ // if area is smaller than required, add borders.
+ if(area < minAreaThreshold)
+ m_pSink->strokePath(path);
+ }
+ break;
case FILLPATH:
- m_pSink->fillPath(readPath()); break;
+ {
+ double area = 0.0;
+ uno::Reference<rendering::XPolyPolygon2D> path = readPath( &area );
+ m_pSink->fillPath(path);
+ // if area is smaller than required, add borders.
+ if(area < minAreaThreshold)
+ m_pSink->strokePath(path);
+ }
+ break;
case RESTORESTATE:
m_pSink->popState(); break;
case SAVESTATE:
@@ -913,6 +942,8 @@ static bool checkEncryption( const rtl::OUString&
rtl::OString aIsoPwd = rtl::OUStringToOString( io_rPwd,
RTL_TEXTENCODING_ISO_8859_1 );
bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd.getStr() );
+ // trash password string on heap
+ rtl_zeroMemory( (void*)aIsoPwd.getStr(), aIsoPwd.getLength() );
}
if( bAuthenticated )
bSuccess = true;
@@ -927,12 +958,23 @@ static bool checkEncryption( const rtl::OUString&
rtl::OString aIsoPwd = rtl::OUStringToOString( io_rPwd,
RTL_TEXTENCODING_ISO_8859_1 );
bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd.getStr() );
+ // trash password string on heap
+ rtl_zeroMemory( (void*)aIsoPwd.getStr(), aIsoPwd.getLength() );
} while( bEntered && ! bAuthenticated );
}
OSL_TRACE( "password: %s\n", bAuthenticated ? "matches" : "does not match" );
bSuccess = bAuthenticated;
}
+ // trash password string on heap
+ rtl_zeroMemory( (void*)io_rPwd.getStr(), io_rPwd.getLength()*sizeof(sal_Unicode) );
+ if( bAuthenticated )
+ {
+ rtl::OUStringBuffer aBuf( 128 );
+ aBuf.appendAscii( "_OOO_pdfi_Credentials_" );
+ aBuf.append( pPDFFile->getDecryptionKey() );
+ io_rPwd = aBuf.makeStringAndClear();
+ }
}
else
bSuccess = true;