summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMert Tumer <mert.tumer@collabora.com>2019-10-24 12:11:21 +0300
committerAndras Timar <andras.timar@collabora.com>2019-11-27 21:13:44 +0100
commitb7e6a06a34f601dfb619e7c83800738643d14e96 (patch)
treefd256ae88d81fa809abc56a4377292a72a5e27a4
parent9812eeb3e506f6f16b339fa12a253381d8487eab (diff)
Added Orientation argument to LOKIT renderFont
method for rendering watermarks with angle Reviewed-on: https://gerrit.libreoffice.org/82404 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> (cherry picked from commit 1dd66357752b01fbf3f1aee9966a55d4a16038e4) Change-Id: Id422ed62e4f78390661e4e1efa45101af9ecfc23 Reviewed-on: https://gerrit.libreoffice.org/83937 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx7
-rw-r--r--desktop/source/lib/init.cxx33
-rw-r--r--filter/source/pdf/pdfexport.cxx36
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h8
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx8
5 files changed, 59 insertions, 33 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 46b2dcb431fc..cb42ab2d75b4 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -70,6 +70,7 @@ public:
virtual void setUp() override
{
UnoApiTest::setUp();
+
mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
SfxApplication::GetOrCreate();
};
@@ -77,6 +78,7 @@ public:
virtual void tearDown() override
{
closeDoc();
+
UnoApiTest::tearDown();
};
@@ -2769,9 +2771,12 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(49), offsetof(struct _LibreOfficeKitDocumentClass, selectPart));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(50), offsetof(struct _LibreOfficeKitDocumentClass, moveSelectedParts));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), offsetof(struct _LibreOfficeKitDocumentClass, renderFontOrientation));
+]
+
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(51), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(52), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 33b699d78c1b..f9bb73a1d0a0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -795,6 +795,12 @@ static int doc_getView(LibreOfficeKitDocument* pThis);
static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t nSize);
static void doc_setViewLanguage(LibreOfficeKitDocument* pThis, int nId, const char* language);
+static unsigned char* doc_renderFontOrientation(LibreOfficeKitDocument* pThis,
+ const char *pFontName,
+ const char *pChar,
+ int* pFontWidth,
+ int* pFontHeight,
+ int pOrientation);
static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
const char *pFontName,
const char *pChar,
@@ -811,7 +817,8 @@ static void doc_paintWindowDPI(LibreOfficeKitDocument* pThis, unsigned nLOKWindo
const int nWidth, const int nHeight,
const double fDPIScale);
-static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nAction, const char* pData);
+static void doc_postWindow(LibreOfficeKitDocument* pThis, unsigned
+ nLOKWindowId, int nAction, const char* pData);
static char* doc_getPartInfo(LibreOfficeKitDocument* pThis, int nPart);
@@ -879,6 +886,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->getViewIds = doc_getViewIds;
m_pDocumentClass->renderFont = doc_renderFont;
+ m_pDocumentClass->renderFontOrientation = doc_renderFontOrientation;
m_pDocumentClass->getPartHash = doc_getPartHash;
m_pDocumentClass->paintWindow = doc_paintWindow;
@@ -4013,12 +4021,24 @@ static void doc_setViewLanguage(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p
SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, RTL_TEXTENCODING_UTF8));
}
-unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/,
+
+
+unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
const char* pFontName,
const char* pChar,
int* pFontWidth,
int* pFontHeight)
{
+ return doc_renderFontOrientation(pThis, pFontName, pChar, pFontWidth, pFontHeight, 0);
+}
+
+unsigned char* doc_renderFontOrientation(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/,
+ const char* pFontName,
+ const char* pChar,
+ int* pFontWidth,
+ int* pFontHeight,
+ int pOrientation)
+{
comphelper::ProfileZone aZone("doc_renderFont");
SolarMutexGuard aGuard;
@@ -4053,6 +4073,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
::tools::Rectangle aRect;
vcl::Font aFont(rFontMetric);
aFont.SetFontSize(Size(0, nDefaultFontSize));
+ aFont.SetOrientation(pOrientation);
aDevice->SetFont(aFont);
aDevice->GetTextBoundRect(aRect, aText);
if (aRect.IsEmpty())
@@ -4066,8 +4087,8 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
if (*pFontWidth > 0 && *pFontHeight > 0)
{
- double fScaleX = *pFontWidth / static_cast<double>(nFontWidth);
- double fScaleY = *pFontHeight / static_cast<double>(nFontHeight);
+ double fScaleX = *pFontWidth / static_cast<double>(nFontWidth) / 1.5;
+ double fScaleY = *pFontHeight / static_cast<double>(nFontHeight) / 1.5;
double fScale = std::min(fScaleX, fScaleY);
@@ -4100,8 +4121,9 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
DrawTextFlags nStyle =
DrawTextFlags::Center
| DrawTextFlags::VCenter
+ | DrawTextFlags::Bottom
| DrawTextFlags::MultiLine
- | DrawTextFlags::WordBreakHyphenation;// | DrawTextFlags::WordBreak ;
+ | DrawTextFlags::WordBreak;// | DrawTextFlags::WordBreakHyphenation ;
aDevice->DrawText(aRect, aText, nStyle);
}
@@ -4120,6 +4142,7 @@ unsigned char* doc_renderFont(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pTh
return nullptr;
}
+
static void doc_paintWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId,
unsigned char* pBuffer,
const int nX, const int nY,
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 9013c63e2973..fa421b88e568 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -551,7 +551,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rFilterData[ nData ].Value >>= mnDefaultLinkAction;
else if ( rFilterData[ nData ].Name == "ConvertOOoTargetToPDFTarget" )
rFilterData[ nData ].Value >>= mbConvertOOoTargetToPDFTarget;
- else if ( rFilterData[ nData ].Name == "ExportBookmarksToPDFDestination" )
+ else if ( rFilterData[ nData ].Name == "ExportBookmarksToPDFDestination" )
rFilterData[ nData ].Value >>= mbExportBmkToDest;
else if ( rFilterData[ nData ].Name == "ExportBookmarks" )
rFilterData[ nData ].Value >>= mbExportBookmarks;
@@ -730,7 +730,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
}
// after this point we don't need the legacy clear passwords anymore
// however they are still inside the passed filter data sequence
- // which is sadly out out our control
+ // which is sadly out of our control
aPermissionPassword.clear();
aOpenPassword.clear();
@@ -1147,29 +1147,16 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi
void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rPageSize )
{
OUString watermark = msTiledWatermark;
- int watermarkLength = watermark.getLength();
// Maximum number of characters in one line.
// it is set to 21 to make it look like tiled watermaks as online in secure view
const int lineLength = 21;
- int lnIndex = lineLength;
- int lnCount = watermarkLength / lineLength;
-
- while(lnCount)
- {
- OUString tempstr = watermark;
- watermark = watermark.copy(0, lnIndex);
- watermark += OUString("\n");
- watermark += tempstr.copy(lnIndex);
- lnIndex += lineLength;
- lnCount--;
- }
-
- vcl::Font aFont( OUString( "Liberation Sans" ), Size( 0, 40 ) );
+ vcl::Font aFont( "Liberation Sans", Size( 0, 40 ) );
aFont.SetItalic( ITALIC_NONE );
aFont.SetWidthType( WIDTH_NORMAL );
aFont.SetWeight( WEIGHT_NORMAL );
aFont.SetAlignment( ALIGN_BOTTOM );
aFont.SetFontHeight(40);
+ aFont.SetOrientation(450);
OutputDevice* pDev = rWriter.GetReferenceDevice();
pDev->SetFont(aFont);
@@ -1204,22 +1191,21 @@ void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rP
rWriter.SetMapMode( MapMode( MapUnit::MapPoint ) );
rWriter.SetFont(aFont);
rWriter.SetTextColor( Color(19,20,22) );
- Point aTextPoint;
- tools::Rectangle aTextRect;
- //center watermarks horizontially
- aTextPoint = Point((rPageSize.Width()/2)-(((nTextWidth*(watermarkcount))+(watermarkcount-1)*(nTextWidth/2))/2), pDev->GetTextHeight());
+ // center watermarks horizontally
+ Point aTextPoint( (rPageSize.Width()/2) - (((nTextWidth*watermarkcount)+(watermarkcount-1)*nTextWidth)/2),
+ pDev->GetTextHeight());
for( int i = 0; i < watermarkcount; i ++)
{
- while(aTextPoint.getY()+pDev->GetTextHeight()*2 <= rPageSize.Height())
+ while(aTextPoint.getY()+pDev->GetTextHeight()*3 <= rPageSize.Height())
{
- aTextRect = tools::Rectangle(aTextPoint, Size(nTextWidth,pDev->GetTextHeight()*2));
+ tools::Rectangle aTextRect(aTextPoint, Size(nTextWidth*2,pDev->GetTextHeight()*4));
pDev->Push();
rWriter.SetClipRegion();
rWriter.BeginTransparencyGroup();
rWriter.SetTextColor( Color(19,20,22) );
- rWriter.DrawText(aTextRect, watermark, DrawTextFlags::MultiLine|DrawTextFlags::Center|DrawTextFlags::VCenter);
+ rWriter.DrawText(aTextRect, watermark, DrawTextFlags::MultiLine|DrawTextFlags::Center|DrawTextFlags::VCenter|DrawTextFlags::WordBreak|DrawTextFlags::Bottom);
rWriter.EndTransparencyGroup( aTextRect, 50 );
pDev->Pop();
@@ -1227,7 +1213,7 @@ void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rP
rWriter.SetClipRegion();
rWriter.BeginTransparencyGroup();
rWriter.SetTextColor( Color(236,235,233) );
- rWriter.DrawText(aTextRect, watermark, DrawTextFlags::MultiLine|DrawTextFlags::Center|DrawTextFlags::VCenter);
+ rWriter.DrawText(aTextRect, watermark, DrawTextFlags::MultiLine|DrawTextFlags::Center|DrawTextFlags::VCenter|DrawTextFlags::WordBreak|DrawTextFlags::Bottom);
rWriter.EndTransparencyGroup( aTextRect, 50 );
pDev->Pop();
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 7f7c0c24a457..78a452a84d5e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -366,6 +366,14 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::moveSelectedParts().
void (*moveSelectedParts) (LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate);
+ /// @see lok::Document::renderFontOrientation().
+ unsigned char* (*renderFontOrientation) (LibreOfficeKitDocument* pThis,
+ const char* pFontName,
+ const char* pChar,
+ int* pFontWidth,
+ int* pFontHeight,
+ int pOrientation);
+
#endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index da7c65b700e5..975cadbd7e5d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -495,9 +495,13 @@ public:
unsigned char* renderFont(const char *pFontName,
const char *pChar,
int *pFontWidth,
- int *pFontHeight)
+ int *pFontHeight,
+ int pOrientation=0)
{
- return mpDoc->pClass->renderFont(mpDoc, pFontName, pChar, pFontWidth, pFontHeight);
+ if (LIBREOFFICEKIT_DOCUMENT_HAS(mpDoc, renderFontOrientation))
+ return mpDoc->pClass->renderFontOrientation(mpDoc, pFontName, pChar, pFontWidth, pFontHeight, pOrientation);
+ else
+ return mpDoc->pClass->renderFont(mpDoc, pFontName, pChar, pFontWidth, pFontHeight);
}
/**