summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-14 16:03:23 +0200
committerobo <obo@openoffice.org>2010-06-14 16:03:23 +0200
commita7847f4c5e4338003756873ef0e94284f33a84c6 (patch)
treebe5f4365d86ca70ecd18b2a56be44685287af3b3
parentd959aa306fbfcdaae1c31d6b93efe79a4d4f8e38 (diff)
parent0de390d94080af03bdc9a49a97b18852598f7297 (diff)
CWS-TOOLING: integrate CWS pdfextfix03
-rwxr-xr-xsdext/source/pdfimport/config/description.xml2
-rw-r--r--sdext/source/pdfimport/filterdet.cxx4
-rw-r--r--sdext/source/pdfimport/filterdet.hxx4
-rwxr-xr-xsdext/source/pdfimport/inc/pdfihelper.hxx4
-rw-r--r--sdext/source/pdfimport/misc/pwdinteract.cxx19
-rw-r--r--sdext/source/pdfimport/pdfiadaptor.cxx2
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfparse.cxx37
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.cxx165
-rw-r--r--sdext/source/pdfimport/tree/drawtreevisiting.hxx11
-rw-r--r--sdext/source/pdfimport/tree/genericelements.hxx13
-rw-r--r--sdext/source/pdfimport/tree/pdfiprocessor.cxx7
-rw-r--r--sdext/source/pdfimport/tree/pdfiprocessor.hxx5
-rwxr-xr-xsdext/source/pdfimport/wrapper/wrapper.cxx92
13 files changed, 280 insertions, 85 deletions
diff --git a/sdext/source/pdfimport/config/description.xml b/sdext/source/pdfimport/config/description.xml
index ec30133996c8..b22b81587fc7 100755
--- a/sdext/source/pdfimport/config/description.xml
+++ b/sdext/source/pdfimport/config/description.xml
@@ -16,7 +16,7 @@
</simple-license>
</registration>
- <version value="1.0.2" />
+ <version value="1.0.3" />
<platform value="UPDATED_SUPPORTED_PLATFORM" />
diff --git a/sdext/source/pdfimport/filterdet.cxx b/sdext/source/pdfimport/filterdet.cxx
index 9dac0acf7e1e..e9d58cfdb3b2 100644
--- a/sdext/source/pdfimport/filterdet.cxx
+++ b/sdext/source/pdfimport/filterdet.cxx
@@ -736,10 +736,12 @@ uno::Reference< io::XStream > getAdditionalStream( const rtl::OUString&
break;
}
+ rtl::OUString aDocName( rInPDFFileURL.copy( rInPDFFileURL.lastIndexOf( sal_Unicode('/') )+1 ) );
+
bool bEntered = false;
do
{
- bEntered = getPassword( xIntHdl, io_rPwd, ! bEntered );
+ bEntered = getPassword( xIntHdl, io_rPwd, ! bEntered, aDocName );
rtl::OString aIsoPwd = rtl::OUStringToOString( io_rPwd,
RTL_TEXTENCODING_ISO_8859_1 );
bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd.getStr() );
diff --git a/sdext/source/pdfimport/filterdet.hxx b/sdext/source/pdfimport/filterdet.hxx
index 5a35320c91c5..4be260eb4254 100644
--- a/sdext/source/pdfimport/filterdet.hxx
+++ b/sdext/source/pdfimport/filterdet.hxx
@@ -104,7 +104,9 @@ bool checkDocChecksum( const rtl::OUString& rInPDFFileURL,
bool getPassword( const com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >& xHandler,
rtl::OUString& o_rPwd,
- bool bFirstTry );
+ bool bFirstTry,
+ const rtl::OUString& i_rDocName
+ );
}
diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx
index bcc69b0e9eda..9abc22214a6c 100755
--- a/sdext/source/pdfimport/inc/pdfihelper.hxx
+++ b/sdext/source/pdfimport/inc/pdfihelper.hxx
@@ -190,7 +190,9 @@ namespace pdfi
bool getPassword( const ::com::sun::star::uno::Reference<
::com::sun::star::task::XInteractionHandler >& xHandler,
rtl::OUString& rOutPwd,
- bool bFirstTry );
+ bool bFirstTry,
+ const rtl::OUString& rDocName
+ );
}
#define USTR(x) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
diff --git a/sdext/source/pdfimport/misc/pwdinteract.cxx b/sdext/source/pdfimport/misc/pwdinteract.cxx
index a68c63054137..43dfd1151964 100644
--- a/sdext/source/pdfimport/misc/pwdinteract.cxx
+++ b/sdext/source/pdfimport/misc/pwdinteract.cxx
@@ -33,7 +33,7 @@
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <com/sun/star/task/XInteractionRequest.hpp>
#include <com/sun/star/task/XInteractionPassword.hpp>
-#include <com/sun/star/task/PasswordRequest.hpp>
+#include <com/sun/star/task/DocumentPasswordRequest.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/compbase2.hxx>
@@ -53,12 +53,12 @@ class PDFPasswordRequest : private cppu::BaseMutex,
public PDFPasswordRequestBase
{
private:
- task::PasswordRequest m_aRequest;
- rtl::OUString m_aPassword;
- bool m_bSelected;
+ task::DocumentPasswordRequest m_aRequest;
+ rtl::OUString m_aPassword;
+ bool m_bSelected;
public:
- explicit PDFPasswordRequest(bool bFirstTry);
+ explicit PDFPasswordRequest(bool bFirstTry, const rtl::OUString& rName);
// XInteractionRequest
virtual uno::Any SAL_CALL getRequest( ) throw (uno::RuntimeException);
@@ -74,7 +74,7 @@ public:
bool isSelected() const { osl::MutexGuard const guard( m_aMutex ); return m_bSelected; }
};
-PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry ) :
+PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry, const rtl::OUString& rName ) :
PDFPasswordRequestBase( m_aMutex ),
m_aRequest(),
m_aPassword(),
@@ -84,6 +84,7 @@ PDFPasswordRequest::PDFPasswordRequest( bool bFirstTry ) :
task::PasswordRequestMode_PASSWORD_ENTER :
task::PasswordRequestMode_PASSWORD_REENTER;
m_aRequest.Classification = task::InteractionClassification_QUERY;
+ m_aRequest.Name = rName;
}
uno::Any SAL_CALL PDFPasswordRequest::getRequest() throw (uno::RuntimeException)
@@ -132,13 +133,15 @@ namespace pdfi
bool getPassword( const uno::Reference< task::XInteractionHandler >& xHandler,
rtl::OUString& rOutPwd,
- bool bFirstTry )
+ bool bFirstTry,
+ const rtl::OUString& rDocName
+ )
{
bool bSuccess = false;
PDFPasswordRequest* pRequest;
uno::Reference< task::XInteractionRequest > xReq(
- pRequest = new PDFPasswordRequest( bFirstTry ) );
+ pRequest = new PDFPasswordRequest( bFirstTry, rDocName ) );
try
{
xHandler->handle( xReq );
diff --git a/sdext/source/pdfimport/pdfiadaptor.cxx b/sdext/source/pdfimport/pdfiadaptor.cxx
index 08faf9a87f69..16af49409fc5 100644
--- a/sdext/source/pdfimport/pdfiadaptor.cxx
+++ b/sdext/source/pdfimport/pdfiadaptor.cxx
@@ -242,7 +242,7 @@ bool PDFIRawAdaptor::parse( const uno::Reference<io::XInputStream>& xInput
{
// container for metaformat
boost::shared_ptr<PDFIProcessor> pSink(
- new PDFIProcessor(xStatus));
+ new PDFIProcessor(xStatus, m_xContext));
// TEMP! TEMP!
if( m_bEnableToplevelText )
diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
index b8d0aaca6b74..b3ffa64427dd 100644
--- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
@@ -108,6 +108,40 @@ public:
iteratorT m_aGlobalBegin;
public:
+ struct pdf_string_parser
+ {
+ typedef nil_t result_t;
+ template <typename ScannerT>
+ std::ptrdiff_t
+ operator()(ScannerT const& scan, result_t& result) const
+ {
+ std::ptrdiff_t len = 0;
+
+ int nBraceLevel = 0;
+ while( ! scan.at_end() )
+ {
+ char c = *scan;
+ if( c == ')' )
+ {
+ nBraceLevel--;
+ if( nBraceLevel < 0 )
+ break;
+ }
+ else if( c == '(' )
+ nBraceLevel++;
+ else if( c == '\\' ) // ignore escaped braces
+ {
+ ++len;
+ ++scan;
+ if( scan.at_end() )
+ break;
+ }
+ ++len;
+ ++scan;
+ }
+ return scan.at_end() ? -1 : len;
+ }
+ };
template< typename ScannerT >
struct definition
@@ -135,7 +169,8 @@ public:
//stringtype = ( confix_p("(",*anychar_p, ")") |
// confix_p("<",*xdigit_p, ">") )
// [boost::bind(&PDFGrammar::pushString,pSelf, _1, _2)];
- stringtype = ( ( ch_p('(') >> *(str_p("\\)")|(anychar_p - ch_p(')'))) >> ch_p(')') ) |
+
+ stringtype = ( ( ch_p('(') >> functor_parser<pdf_string_parser>() >> ch_p(')') ) |
( ch_p('<') >> *xdigit_p >> ch_p('>') ) )
[boost::bind(&PDFGrammar::pushString,pSelf, _1, _2)];
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
index 664a19c7763d..2fd17d059e23 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx
@@ -39,10 +39,46 @@
#include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <basegfx/range/b2drange.hxx>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "comphelper/processfactory.hxx"
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <string.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::uno;
namespace pdfi
{
+const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& DrawXmlOptimizer::GetBreakIterator()
+{
+ if ( !mxBreakIter.is() )
+ {
+ Reference< XComponentContext > xContext( this->m_rProcessor.m_xContext, uno::UNO_SET_THROW );
+ Reference< XMultiComponentFactory > xMSF( xContext->getServiceManager(), uno::UNO_SET_THROW );
+ Reference < XInterface > xInterface = xMSF->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator"), xContext);
+
+ mxBreakIter = uno::Reference< i18n::XBreakIterator >( xInterface, uno::UNO_QUERY );
+ }
+ return mxBreakIter;
+}
+
+const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& DrawXmlEmitter::GetBreakIterator()
+{
+ if ( !mxBreakIter.is() )
+ {
+ Reference< XComponentContext > xContext( m_rEmitContext.m_xContext, uno::UNO_SET_THROW );
+ Reference< XMultiComponentFactory > xMSF( xContext->getServiceManager(), uno::UNO_SET_THROW );
+ Reference < XInterface > xInterface = xMSF->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator"), xContext);
+ mxBreakIter = uno::Reference< i18n::XBreakIterator >( xInterface, uno::UNO_QUERY );
+ }
+ return mxBreakIter;
+}
+
void DrawXmlEmitter::visit( HyperlinkElement& elem, const std::list< Element* >::const_iterator& )
{
if( elem.Children.empty() )
@@ -72,6 +108,7 @@ void DrawXmlEmitter::visit( TextElement& elem, const std::list< Element* >::cons
return;
rtl::OUString strSpace(32);
+ rtl::OUString strNbSpace(160);
rtl::OUString tabSpace(0x09);
PropertyMap aProps;
if( elem.StyleId != -1 )
@@ -80,27 +117,50 @@ void DrawXmlEmitter::visit( TextElement& elem, const std::list< Element* >::cons
m_rEmitContext.rStyles.getStyleName( elem.StyleId );
}
+ rtl::OUString str(elem.Text.getStr());
+
+ // Check for CTL
+ bool isComplex = false;
+ for(int i=0; i< elem.Text.getLength(); i++)
+ {
+ sal_Int16 nType = GetBreakIterator()->getScriptType( str, i + 1);
+ if (nType == ::com::sun::star::i18n::ScriptType::COMPLEX)
+ isComplex = true;
+ }
+
+ #if 0
+ // FIXME: need to have a service to do this mirroring
+ if (isComplex) // If so, reverse string
+ {
+ rtl::OUString flippedStr(RTL_CONSTASCII_USTRINGPARAM( "" ));
+ for(int i = str.getLength() - 1; i >= 0; i--)
+ {
+ sal_Unicode cChar = str[ i ];
+ cChar = static_cast<sal_Unicode>(GetMirroredChar( cChar ));
+ rtl::OUString uC(cChar);
+ flippedStr += uC;
+ }
+ str = flippedStr;
+ }
+ #endif
+
m_rEmitContext.rEmitter.beginTag( "text:span", aProps );
- rtl::OUString str(elem.Text.getStr());
for(int i=0; i< elem.Text.getLength(); i++)
{
rtl::OUString strToken= str.copy(i,1) ;
- if( strSpace.equals(strToken) )
+ if( strSpace.equals(strToken) || strNbSpace.equals(strToken))
{
aProps[ USTR( "text:c" ) ] = USTR( "1" );
m_rEmitContext.rEmitter.beginTag( "text:s", aProps );
m_rEmitContext.rEmitter.endTag( "text:s");
-
}
else
{
if( tabSpace.equals(strToken) )
{
-
m_rEmitContext.rEmitter.beginTag( "text:tab", aProps );
m_rEmitContext.rEmitter.endTag( "text:tab");
-
}
else
{
@@ -608,6 +668,29 @@ void DrawXmlOptimizer::visit( PageElement& elem, const std::list< Element* >::co
elem.applyToChildren(*this);
}
+bool isSpaces(TextElement* pTextElem)
+{
+ rtl::OUString strSpace(32);
+ ::rtl::OUString ouTxt2(pTextElem->Text);
+ for(int i=0; i< pTextElem->Text.getLength(); i++)
+ {
+ rtl::OUString strToken = ouTxt2.copy(i,1) ;
+ if( !strSpace.equals(strToken) )
+ return false;
+ }
+ return true;
+}
+
+bool notTransformed(GraphicsContext GC)
+{
+ return (
+ GC.Transformation.get(0,0) == 100.00 &&
+ GC.Transformation.get(1,0) == 0.00 &&
+ GC.Transformation.get(0,1) == 0.00 &&
+ GC.Transformation.get(1,1) == -100.00
+ );
+}
+
void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
{
if( rParent.Children.empty() ) // this should not happen
@@ -616,9 +699,6 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
return;
}
- bool bFirstTime= true;
- double fPrevY = 0;
-
// concatenate child elements with same font id
std::list< Element* >::iterator next = rParent.Children.begin();
std::list< Element* >::iterator it = next++;
@@ -634,15 +714,22 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
{
bool bConcat = false;
TextElement* pCur = dynamic_cast<TextElement*>(*it);
- if( bFirstTime )
- {
- bFirstTime=false;
- fPrevY = pCur->y;
- }
if( pCur )
{
TextElement* pNext = dynamic_cast<TextElement*>(*next);
+ bool isComplex = false;
+ rtl::OUString str(pCur->Text.getStr());
+ for(int i=0; i< str.getLength(); i++)
+ {
+ sal_Int16 nType = GetBreakIterator()->getScriptType( str, i );
+ if (nType == ::com::sun::star::i18n::ScriptType::COMPLEX)
+ isComplex = true;
+ }
+ bool bPara = strspn("ParagraphElement", typeid(rParent).name());
+ ParagraphElement* pPara = dynamic_cast<ParagraphElement*>(&rParent);
+ if (bPara && isComplex)
+ pPara->bRtl = true;
if( pNext )
{
const GraphicsContext& rCurGC = m_rProcessor.getGraphicsContext( pCur->GCId );
@@ -650,20 +737,29 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
// line and space optimization; works only in strictly horizontal mode
-
// concatenate consecutive text elements unless there is a
// font or text color or matrix change, leave a new span in that case
- if( pCur->FontId == pNext->FontId &&
+ if( (pCur->FontId == pNext->FontId || isSpaces(pNext)) &&
rCurGC.FillColor.Red == rNextGC.FillColor.Red &&
rCurGC.FillColor.Green == rNextGC.FillColor.Green &&
rCurGC.FillColor.Blue == rNextGC.FillColor.Blue &&
rCurGC.FillColor.Alpha == rNextGC.FillColor.Alpha &&
- rCurGC.Transformation == rNextGC.Transformation
+ (rCurGC.Transformation == rNextGC.Transformation || notTransformed(rNextGC))
)
{
pCur->updateGeometryWith( pNext );
// append text to current element
- pCur->Text.append( pNext->Text.getStr(), pNext->Text.getLength() );
+ pCur->Text.append( pNext->Text.getStr(), pNext->Text.getLength() );
+
+ str = pCur->Text.getStr();
+ for(int i=0; i< str.getLength(); i++)
+ {
+ sal_Int16 nType = GetBreakIterator()->getScriptType( str, i );
+ if (nType == ::com::sun::star::i18n::ScriptType::COMPLEX)
+ isComplex = true;
+ }
+ if (bPara && isComplex)
+ pPara->bRtl = true;
// append eventual children to current element
// and clear children (else the children just
// appended to pCur would be destroyed)
@@ -677,16 +773,11 @@ void DrawXmlOptimizer::optimizeTextElements(Element& rParent)
}
else if( dynamic_cast<HyperlinkElement*>(*it) )
optimizeTextElements( **it );
- if( bConcat )
- {
+ if ( bConcat )
next = it;
- ++next;
- }
else
- {
++it;
- ++next;
- }
+ ++next;
}
}
@@ -763,19 +854,21 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< Element* >::co
// family name
aFontProps[ USTR( "fo:font-family" ) ] = rFont.familyName;
+ aFontProps[ USTR( "style:font-family-complex" ) ] = rFont.familyName;
+
// bold
if( rFont.isBold )
{
aFontProps[ USTR( "fo:font-weight" ) ] = USTR( "bold" );
aFontProps[ USTR( "fo:font-weight-asian" ) ] = USTR( "bold" );
- aFontProps[ USTR( "fo:font-weight-complex" ) ] = USTR( "bold" );
+ aFontProps[ USTR( "style:font-weight-complex" ) ] = USTR( "bold" );
}
// italic
if( rFont.isItalic )
{
aFontProps[ USTR( "fo:font-style" ) ] = USTR( "italic" );
aFontProps[ USTR( "fo:font-style-asian" ) ] = USTR( "italic" );
- aFontProps[ USTR( "fo:font-style-complex" ) ] = USTR( "italic" );
+ aFontProps[ USTR( "style:font-style-complex" ) ] = USTR( "italic" );
}
// underline
if( rFont.isUnderline )
@@ -809,6 +902,26 @@ void DrawXmlFinalizer::visit( TextElement& elem, const std::list< Element* >::co
void DrawXmlFinalizer::visit( ParagraphElement& elem, const std::list< Element* >::const_iterator& )
{
+
+ PropertyMap aProps;
+ aProps[ USTR( "style:family" ) ] = USTR( "paragraph" );
+ // generate standard paragraph style if necessary
+ m_rStyleContainer.getStandardStyleId( "paragraph" );
+
+ PropertyMap aParProps;
+
+ aParProps[ USTR("fo:text-align")] = USTR("start");
+ if (elem.bRtl)
+ aParProps[ USTR("style:writing-mode")] = USTR("rl-tb");
+ else
+ aParProps[ USTR("style:writing-mode")] = USTR("lr-tb");
+
+ StyleContainer::Style aStyle( "style:style", aProps );
+ StyleContainer::Style aSubStyle( "style:paragraph-properties", aParProps );
+ aStyle.SubStyles.push_back( &aSubStyle );
+
+ elem.StyleId = m_rStyleContainer.getStyleId( aStyle );
+
// update page boundaries
if( elem.Parent )
{
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.hxx b/sdext/source/pdfimport/tree/drawtreevisiting.hxx
index b7b94371c6da..fd347fa4f302 100644
--- a/sdext/source/pdfimport/tree/drawtreevisiting.hxx
+++ b/sdext/source/pdfimport/tree/drawtreevisiting.hxx
@@ -29,7 +29,9 @@
#define INCLUDED_PDFI_DRAWTREEVISITING_HXX
#include "treevisiting.hxx"
-
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
namespace pdfi
{
@@ -42,6 +44,8 @@ namespace pdfi
void optimizeTextElements(Element& rParent);
public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIter;
+ const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
explicit DrawXmlOptimizer(PDFIProcessor& rProcessor) :
m_rProcessor(rProcessor)
{}
@@ -82,6 +86,10 @@ namespace pdfi
class DrawXmlEmitter : public ElementTreeVisitor
{
private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xCtx;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIter;
+
EmitContext& m_rEmitContext ;
/// writes Impress doc when false
const bool m_bWriteDrawDocument;
@@ -91,6 +99,7 @@ namespace pdfi
const EmitContext& rEmitContext );
public:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
enum DocType{ DRAW_DOC, IMPRESS_DOC };
explicit DrawXmlEmitter(EmitContext& rEmitContext, DocType eDocType) :
m_rEmitContext(rEmitContext),
diff --git a/sdext/source/pdfimport/tree/genericelements.hxx b/sdext/source/pdfimport/tree/genericelements.hxx
index 88293673ee3a..d7cd690aba61 100644
--- a/sdext/source/pdfimport/tree/genericelements.hxx
+++ b/sdext/source/pdfimport/tree/genericelements.hxx
@@ -32,6 +32,7 @@
#include "treevisiting.hxx"
#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/range/b2drange.hxx>
#include <rtl/ustring.hxx>
@@ -56,12 +57,15 @@ namespace pdfi
ImageContainer& _rImages,
PDFIProcessor& _rProcessor,
const com::sun::star::uno::Reference<
- com::sun::star::task::XStatusIndicator>& _xStatusIndicator ) :
+ com::sun::star::task::XStatusIndicator>& _xStatusIndicator,
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext)
+ :
rEmitter(_rEmitter),
rStyles(_rStyles),
rImages(_rImages),
rProcessor(_rProcessor),
- xStatusIndicator(_xStatusIndicator)
+ xStatusIndicator(_xStatusIndicator),
+ m_xContext(xContext)
{}
XmlEmitter& rEmitter;
@@ -70,6 +74,8 @@ namespace pdfi
PDFIProcessor& rProcessor;
com::sun::star::uno::Reference<
com::sun::star::task::XStatusIndicator> xStatusIndicator;
+ com::sun::star::uno::Reference<
+ com::sun::star::uno::XComponentContext > m_xContext;
};
struct Element : public ElementTreeVisitable
@@ -178,7 +184,7 @@ namespace pdfi
{
friend class ElementFactory;
protected:
- ParagraphElement( Element* pParent ) : Element( pParent ), Type( Normal ) {}
+ ParagraphElement( Element* pParent ) : Element( pParent ), Type( Normal ), bRtl( false ) {}
public:
// ElementTreeVisitable
@@ -194,6 +200,7 @@ namespace pdfi
enum ParagraphType { Normal, Headline };
ParagraphType Type;
+ bool bRtl;
};
struct PolyPolyElement : public DrawElement
diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
index d132c8f74c31..d823cac524cf 100644
--- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx
+++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx
@@ -61,7 +61,10 @@ using namespace com::sun::star;
namespace pdfi
{
- PDFIProcessor::PDFIProcessor( const uno::Reference< task::XStatusIndicator >& xStat ) :
+ PDFIProcessor::PDFIProcessor( const uno::Reference< task::XStatusIndicator >& xStat ,
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext) :
+
+ m_xContext(xContext),
fYPrevTextPosition(-10000.0),
fPrevTextHeight(0.0),
fXPrevTextPosition(0.0),
@@ -842,7 +845,7 @@ void PDFIProcessor::emit( XmlEmitter& rEmitter,
m_pDocument->visitedBy( *finalizingVisitor, std::list<Element*>::iterator() );
- EmitContext aContext( rEmitter, aStyles, m_aImages, *this, m_xStatusIndicator );
+ EmitContext aContext( rEmitter, aStyles, m_aImages, *this, m_xStatusIndicator, m_xContext );
ElementTreeVisitorSharedPtr aEmittingVisitor(
rVisitorFactory.createEmittingVisitor(aContext));
diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.hxx b/sdext/source/pdfimport/tree/pdfiprocessor.hxx
index 6a9d4ab85a4d..e646d6999df7 100644
--- a/sdext/source/pdfimport/tree/pdfiprocessor.hxx
+++ b/sdext/source/pdfimport/tree/pdfiprocessor.hxx
@@ -72,13 +72,16 @@ namespace pdfi
class PDFIProcessor : public ContentSink
{
public:
+ com::sun::star::uno::Reference<
+ com::sun::star::uno::XComponentContext > m_xContext;
double fYPrevTextPosition;
double fPrevTextHeight;
double fXPrevTextPosition;
double fPrevTextWidth;
enum DocumentTextDirecion { LrTb, RlTb, TbLr };
- explicit PDFIProcessor( const com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator >& );
+ explicit PDFIProcessor( const com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator >& xStat,
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext) ;
/// TEMP - enable writer-like text:p on doc level
void enableToplevelText();
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 0eafbbb83327..51817ce5eacf 100755
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -70,6 +70,10 @@
#include <hash_map>
#include <string.h>
+#ifdef WNT
+#include <stdlib.h>
+#include <ctype.h>
+#endif
#include "rtl/bootstrap.h"
@@ -180,6 +184,10 @@ class Parser
void readLink();
void readMaskedImage();
void readSoftMaskedImage();
+ int parseFontCheckForString( const sal_Unicode* pCopy, const char* str, sal_Int32& nLen,
+ FontAttributes& aResult, bool bItalic, bool bBold);
+ int parseFontRemoveSuffix( const sal_Unicode* pCopy, const char* s, sal_Int32& nLen);
+
public:
Parser( const ContentSinkSharedPtr& rSink,
@@ -455,6 +463,35 @@ rendering::ARGBColor Parser::readColor()
return aRes;
}
+int Parser::parseFontCheckForString( const sal_Unicode* pCopy, const char* s, sal_Int32& nLen,
+ FontAttributes& aResult, bool bItalic, bool bBold)
+{
+ int l = strlen(s);
+ if (nLen < l)
+ return 0;
+ for (int i = 0; i < l; i++)
+ if (tolower(pCopy[i]) != s[i]
+ && toupper(pCopy[i]) != s[i])
+ return 0;
+ aResult.isItalic = bItalic;
+ aResult.isBold = bBold;
+ nLen -= l;
+ pCopy += l;
+ return l;
+}
+
+int Parser::parseFontRemoveSuffix( const sal_Unicode* pCopy, const char* s, sal_Int32& nLen)
+{
+ int l = strlen(s);
+ if (nLen < l)
+ return 0;
+ for (int i = 0; i < l; i++)
+ if ( pCopy[nLen - l + i] != s[i] )
+ return 0;
+ nLen -= l;
+ return l;
+}
+
void Parser::parseFontFamilyName( FontAttributes& aResult )
{
rtl::OUStringBuffer aNewFamilyName( aResult.familyName.getLength() );
@@ -470,39 +507,17 @@ void Parser::parseFontFamilyName( FontAttributes& aResult )
while( nLen )
{
- if( nLen > 5 &&
- ( *pCopy == 'i' || *pCopy == 'I' ) &&
- pCopy[1] == 't' &&
- pCopy[2] == 'a' &&
- pCopy[3] == 'l' &&
- pCopy[4] == 'i' &&
- pCopy[5] == 'c' )
- {
- aResult.isItalic = true;
- nLen -=6;
- pCopy += 6;
- }
- else if( nLen > 3 &&
- ( *pCopy == 'B' || *pCopy == 'b' ) &&
- pCopy[1] == 'o' &&
- pCopy[2] == 'l' &&
- pCopy[3] == 'd' )
- {
- aResult.isBold = true;
- nLen -=4;
- pCopy += 4;
- }
- else if( nLen > 5 &&
- *pCopy == '-' &&
- ( pCopy[1] == 'R' || pCopy[1] == 'r' ) &&
- pCopy[2] == 'o' &&
- pCopy[3] == 'm' &&
- pCopy[4] == 'a' &&
- pCopy[5] == 'n' )
- {
- nLen -= 6;
- pCopy += 6;
- }
+ if (parseFontRemoveSuffix( pCopy, "PSMT", nLen)) {}
+ else if (parseFontRemoveSuffix( pCopy, "MT", nLen)) {}
+
+ if (parseFontCheckForString( pCopy, "Italic", nLen, aResult, true, false)) {}
+ else if (parseFontCheckForString( pCopy, "-Bold", nLen, aResult, false, true)) {}
+ else if (parseFontCheckForString( pCopy, "Bold", nLen, aResult, false, true)) {}
+ else if (parseFontCheckForString( pCopy, "-Roman", nLen, aResult, false, false)) {}
+ else if (parseFontCheckForString( pCopy, "-LightOblique", nLen, aResult, true, false)) {}
+ else if (parseFontCheckForString( pCopy, "-BoldOblique", nLen, aResult, true, true)) {}
+ else if (parseFontCheckForString( pCopy, "-Light", nLen, aResult, false, false)) {}
+ else if (parseFontCheckForString( pCopy, "-Reg", nLen, aResult, false, false)) {}
else
{
if( *pCopy != '-' )
@@ -557,7 +572,6 @@ void Parser::readFont()
// extract textual attributes (bold, italic in the name, etc.)
parseFontFamilyName(aResult);
-
// need to read font file?
if( nFileLen )
{
@@ -582,6 +596,7 @@ void Parser::readFont()
if( aRes >>= aFD )
{
aResult.familyName = aFD.Name;
+ parseFontFamilyName(aResult);
aResult.isBold = (aFD.Weight > 100.0);
aResult.isItalic = (aFD.Slant == awt::FontSlant_OBLIQUE ||
aFD.Slant == awt::FontSlant_ITALIC );
@@ -602,7 +617,6 @@ void Parser::readFont()
}
}
-
m_aFontMap[nFontID] = aResult;
aResult.size = nSize;
@@ -875,7 +889,8 @@ oslFileError readLine( oslFileHandle pFile, ::rtl::OStringBuffer& line )
static bool checkEncryption( const rtl::OUString& i_rPath,
const uno::Reference< task::XInteractionHandler >& i_xIHdl,
rtl::OUString& io_rPwd,
- bool& o_rIsEncrypted
+ bool& o_rIsEncrypted,
+ const rtl::OUString& i_rDocName
)
{
bool bSuccess = false;
@@ -908,7 +923,7 @@ static bool checkEncryption( const rtl::OUString&
bool bEntered = false;
do
{
- bEntered = getPassword( i_xIHdl, io_rPwd, ! bEntered );
+ bEntered = getPassword( i_xIHdl, io_rPwd, ! bEntered, i_rDocName );
rtl::OString aIsoPwd = rtl::OUStringToOString( io_rPwd,
RTL_TEXTENCODING_ISO_8859_1 );
bAuthenticated = pPDFFile->setupDecryptionData( aIsoPwd.getStr() );
@@ -937,11 +952,12 @@ bool xpdf_ImportFromFile( const ::rtl::OUString& rUR
::rtl::OUString aSysUPath;
if( osl_getSystemPathFromFileURL( rURL.pData, &aSysUPath.pData ) != osl_File_E_None )
return false;
+ rtl::OUString aDocName( rURL.copy( rURL.lastIndexOf( sal_Unicode('/') )+1 ) );
// check for encryption, if necessary get password
rtl::OUString aPwd( rPwd );
bool bIsEncrypted = false;
- if( checkEncryption( aSysUPath, xIHdl, aPwd, bIsEncrypted ) == false )
+ if( checkEncryption( aSysUPath, xIHdl, aPwd, bIsEncrypted, aDocName ) == false )
return false;
rtl::OUStringBuffer converterURL = rtl::OUString::createFromAscii("xpdfimport");