diff options
author | Noel Grandin <noel@peralex.com> | 2015-05-18 13:36:39 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-05-20 09:52:08 +0200 |
commit | 25a47c5cd54c73e754de988bde8ec8a202d27717 (patch) | |
tree | 479c07ba52f718f03770fba60121d2a0ef3a3b08 /vcl/source/gdi | |
parent | 7a0af37989d1f1b508a61f28e785c5b1f27d58af (diff) |
convert TEXT_DRAW constants to scoped enum
Change-Id: Ic0f7f8fa236bb478b3598ae3fd3c1b30ebbf1a01
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/metaact.cxx | 10 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 84 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/textlayout.cxx | 6 |
5 files changed, 55 insertions, 53 deletions
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 9395dabdb0e9..887bf7f621db 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1422,14 +1422,14 @@ void MetaStretchTextAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) MetaTextRectAction::MetaTextRectAction() : MetaAction ( MetaActionType::TEXTRECT ), - mnStyle ( 0 ) + mnStyle ( DrawTextFlags::NONE ) {} MetaTextRectAction::~MetaTextRectAction() {} MetaTextRectAction::MetaTextRectAction( const Rectangle& rRect, - const OUString& rStr, sal_uInt16 nStyle ) : + const OUString& rStr, DrawTextFlags nStyle ) : MetaAction ( MetaActionType::TEXTRECT ), maRect ( rRect ), maStr ( rStr ), @@ -1471,7 +1471,7 @@ void MetaTextRectAction::Write( SvStream& rOStm, ImplMetaWriteData* pData ) VersionCompat aCompat(rOStm, StreamMode::WRITE, 2); WriteRectangle( rOStm, maRect ); rOStm.WriteUniOrByteString( maStr, pData->meActualCharSet ); - rOStm.WriteUInt16( mnStyle ); + rOStm.WriteUInt16( static_cast<sal_uInt16>(mnStyle) ); write_uInt16_lenPrefixed_uInt16s_FromOUString(rOStm, maStr); // version 2 } @@ -1481,7 +1481,9 @@ void MetaTextRectAction::Read( SvStream& rIStm, ImplMetaReadData* pData ) VersionCompat aCompat(rIStm, StreamMode::READ); ReadRectangle( rIStm, maRect ); maStr = rIStm.ReadUniOrByteString(pData->meActualCharSet); - rIStm .ReadUInt16( mnStyle ); + sal_uInt16 nTmp; + rIStm .ReadUInt16( nTmp ); + mnStyle = static_cast<DrawTextFlags>(nTmp); if ( aCompat.GetVersion() >= 2 ) // Version 2 maStr = read_uInt16_lenPrefixed_uInt16s_ToOUString(rIStm); diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index 4701eded681f..85fae2d4b181 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -101,7 +101,7 @@ void PDFWriter::DrawStretchText( void PDFWriter::DrawText( const Rectangle& rRect, const OUString& rStr, - sal_uInt16 nStyle ) + DrawTextFlags nStyle ) { xImplementation->drawText( rRect, rStr, nStyle ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4848bf5d99d6..f995b78f1583 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -209,7 +209,7 @@ void doTestCode() aWriter.SetStructureAttribute( PDFWriter::TextDecorationType, PDFWriter::Underline ); aWriter.DrawText( Rectangle( Point( 4500, 10000 ), Size( 12000, 6000 ) ), "It was the best of PDF, it was the worst of PDF ... or so. This is a pretty nonsensical text to denote a paragraph. I suggest you stop reading it. Because if you read on you might get bored. So continue on your on risk. Hey, you're still here ? Why do you continue to read this as it is of no use at all ? OK, it's your time, but still... . Woah, i even get bored writing this, so let's end this here and now.", - TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK + DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); aWriter.SetActualText( "It was the best of PDF, it was the worst of PDF ... or so. This is a pretty nonsensical text to denote a paragraph. I suggest you stop reading it. Because if you read on you might get bored. So continue on your on risk. Hey, you're still here ? Why do you continue to read this as it is of no use at all ? OK, it's your time, but still... . Woah, i even get bored writing this, so let's end this here and now." ); aWriter.SetAlternateText( "This paragraph contains some lengthy nonsense to test structural element emission of PDFWriter." ); @@ -218,7 +218,7 @@ void doTestCode() aWriter.SetStructureAttribute( PDFWriter::WritingMode, PDFWriter::LrTb ); aWriter.DrawText( Rectangle( Point( 4500, 19000 ), Size( 12000, 1000 ) ), "This paragraph is nothing special either but ends on the next page structurewise", - TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK + DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); aWriter.NewPage( 595, 842 ); @@ -231,7 +231,7 @@ void doTestCode() aWriter.SetFont( Font( OUString( "Times" ), Size( 0, 500 ) ) ); aWriter.DrawText( Rectangle( Point( 4500, 1500 ), Size( 12000, 3000 ) ), "Here's where all things come to an end ... well at least the paragraph from the last page.", - TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK + DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); aWriter.EndStructureElement(); @@ -287,7 +287,7 @@ void doTestCode() aWriter.SetTextColor( Color( COL_LIGHTBLUE ) ); aWriter.DrawText( aTranspRect, "Some transparent text", - TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); + DrawTextFlags::Center | DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); aWriter.EndTransparencyGroup( aTranspRect, 50 ); @@ -311,7 +311,7 @@ void doTestCode() aWriter.SetTextColor( Color( COL_LIGHTBLUE ) ); aWriter.DrawText( aTranspRect, "Some transparent text", - TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); + DrawTextFlags::Center | DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); aTranspRect = Rectangle( Point( 1500, 16500 ), Size( 4800, 3000 ) ); aWriter.SetFillColor( Color( COL_LIGHTRED ) ); aWriter.DrawRect( aTranspRect ); @@ -449,7 +449,7 @@ void doTestCode() aEditBox.Name = "testEdit"; aEditBox.Description = "A test edit field"; aEditBox.Text = "A little test text"; - aEditBox.TextStyle = TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER; + aEditBox.TextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter; aEditBox.Location = Rectangle( Point( 10000, 18000 ), Size( 5000, 1500 ) ); aEditBox.MaxLen = 100; aEditBox.Border = aEditBox.Background = true; @@ -5586,9 +5586,9 @@ bool PDFWriterImpl::emitWidgetAnnotations() aLine.append( "/DA" ); appendLiteralStringEncrypt( rWidget.m_aDAString, rWidget.m_nObject, aLine ); aLine.append( "\n" ); - if( rWidget.m_nTextStyle & TEXT_DRAW_CENTER ) + if( rWidget.m_nTextStyle & DrawTextFlags::Center ) aLine.append( "/Q 1\n" ); - else if( rWidget.m_nTextStyle & TEXT_DRAW_RIGHT ) + else if( rWidget.m_nTextStyle & DrawTextFlags::Right ) aLine.append( "/Q 2\n" ); } // appearance charactristics for terminal fields @@ -9343,7 +9343,7 @@ void PDFWriterImpl::drawStretchText( const Point& rPos, sal_uLong nWidth, const } } -void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, sal_uInt16 nStyle, bool bTextLines ) +void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, DrawTextFlags nStyle, bool bTextLines ) { long nWidth = rRect.GetWidth(); long nHeight = rRect.GetHeight(); @@ -9370,11 +9370,11 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, sal_Int32 nMnemonicPos = -1; OUString aStr = rOrigStr; - if ( nStyle & TEXT_DRAW_MNEMONIC ) + if ( nStyle & DrawTextFlags::Mnemonic ) aStr = OutputDevice::GetNonMnemonicString( aStr, nMnemonicPos ); // multiline text - if ( nStyle & TEXT_DRAW_MULTILINE ) + if ( nStyle & DrawTextFlags::MultiLine ) { OUString aLastLine; ImplMultiTextLineInfo aMultiLineInfo; @@ -9393,7 +9393,7 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, nLines = 1; if ( nFormatLines > nLines ) { - if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) + if ( nStyle & DrawTextFlags::EndEllipsis ) { // handle last line nFormatLines = nLines-1; @@ -9403,24 +9403,24 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, // replace line feed by space aLastLine = aLastLine.replace('\n', ' '); aLastLine = m_pReferenceDevice->GetEllipsisString( aLastLine, nWidth, nStyle ); - nStyle &= ~(TEXT_DRAW_VCENTER | TEXT_DRAW_BOTTOM); - nStyle |= TEXT_DRAW_TOP; + nStyle &= ~DrawTextFlags(DrawTextFlags::VCenter | DrawTextFlags::Bottom); + nStyle |= DrawTextFlags::Top; } } // vertical alignment - if ( nStyle & TEXT_DRAW_BOTTOM ) + if ( nStyle & DrawTextFlags::Bottom ) aPos.Y() += nHeight-(nFormatLines*nTextHeight); - else if ( nStyle & TEXT_DRAW_VCENTER ) + else if ( nStyle & DrawTextFlags::VCenter ) aPos.Y() += (nHeight-(nFormatLines*nTextHeight))/2; // draw all lines excluding the last for ( i = 0; i < nFormatLines; i++ ) { pLineInfo = aMultiLineInfo.GetLine( i ); - if ( nStyle & TEXT_DRAW_RIGHT ) + if ( nStyle & DrawTextFlags::Right ) aPos.X() += nWidth-pLineInfo->GetWidth(); - else if ( nStyle & TEXT_DRAW_CENTER ) + else if ( nStyle & DrawTextFlags::Center ) aPos.X() += (nWidth-pLineInfo->GetWidth())/2; sal_Int32 nIndex = pLineInfo->GetIndex(); sal_Int32 nLineLen = pLineInfo->GetLen(); @@ -9443,24 +9443,24 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, // Evt. Text kuerzen if ( nTextWidth > nWidth ) { - if ( nStyle & (TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_PATHELLIPSIS | TEXT_DRAW_NEWSELLIPSIS) ) + if ( nStyle & (DrawTextFlags::EndEllipsis | DrawTextFlags::PathEllipsis | DrawTextFlags::NewsEllipsis) ) { aStr = m_pReferenceDevice->GetEllipsisString( aStr, nWidth, nStyle ); - nStyle &= ~(TEXT_DRAW_CENTER | TEXT_DRAW_RIGHT); - nStyle |= TEXT_DRAW_LEFT; + nStyle &= ~DrawTextFlags(DrawTextFlags::Center | DrawTextFlags::Right); + nStyle |= DrawTextFlags::Left; nTextWidth = m_pReferenceDevice->GetTextWidth( aStr ); } } // vertical alignment - if ( nStyle & TEXT_DRAW_RIGHT ) + if ( nStyle & DrawTextFlags::Right ) aPos.X() += nWidth-nTextWidth; - else if ( nStyle & TEXT_DRAW_CENTER ) + else if ( nStyle & DrawTextFlags::Center ) aPos.X() += (nWidth-nTextWidth)/2; - if ( nStyle & TEXT_DRAW_BOTTOM ) + if ( nStyle & DrawTextFlags::Bottom ) aPos.Y() += nHeight-nTextHeight; - else if ( nStyle & TEXT_DRAW_VCENTER ) + else if ( nStyle & DrawTextFlags::VCenter ) aPos.Y() += (nHeight-nTextHeight)/2; // mnemonics should be inserted here if the need arises @@ -13312,9 +13312,9 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa rNewWidget.m_aDescription = rControl.Description; rNewWidget.m_aText = rControl.Text; rNewWidget.m_nTextStyle = rControl.TextStyle & - ( TEXT_DRAW_LEFT | TEXT_DRAW_CENTER | TEXT_DRAW_RIGHT | TEXT_DRAW_TOP | - TEXT_DRAW_VCENTER | TEXT_DRAW_BOTTOM | - TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK ); + ( DrawTextFlags::Left | DrawTextFlags::Center | DrawTextFlags::Right | DrawTextFlags::Top | + DrawTextFlags::VCenter | DrawTextFlags::Bottom | + DrawTextFlags::MultiLine | DrawTextFlags::WordBreak ); rNewWidget.m_nTabOrder = rControl.TabOrder; // various properties are set via the flags (/Ff) property of the field dict @@ -13323,10 +13323,10 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa if( rControl.getType() == PDFWriter::PushButton ) { const PDFWriter::PushButtonWidget& rBtn = static_cast<const PDFWriter::PushButtonWidget&>(rControl); - if( rNewWidget.m_nTextStyle == 0 ) + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) rNewWidget.m_nTextStyle = - TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER | - TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK; + DrawTextFlags::Center | DrawTextFlags::VCenter | + DrawTextFlags::MultiLine | DrawTextFlags::WordBreak; rNewWidget.m_nFlags |= 0x00010000; if( !rBtn.URL.isEmpty() ) @@ -13339,9 +13339,9 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa else if( rControl.getType() == PDFWriter::RadioButton ) { const PDFWriter::RadioButtonWidget& rBtn = static_cast<const PDFWriter::RadioButtonWidget&>(rControl); - if( rNewWidget.m_nTextStyle == 0 ) + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) rNewWidget.m_nTextStyle = - TEXT_DRAW_VCENTER | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK; + DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak; /* PDF sees a RadioButton group as one radio button with * children which are in turn check boxes * @@ -13375,9 +13375,9 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa else if( rControl.getType() == PDFWriter::CheckBox ) { const PDFWriter::CheckBoxWidget& rBox = static_cast<const PDFWriter::CheckBoxWidget&>(rControl); - if( rNewWidget.m_nTextStyle == 0 ) + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) rNewWidget.m_nTextStyle = - TEXT_DRAW_VCENTER | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK; + DrawTextFlags::VCenter | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak; rNewWidget.m_aValue = rBox.Checked ? OUString("Yes") : OUString("Off" ); // create default appearance before m_aRect gets transformed @@ -13385,8 +13385,8 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa } else if( rControl.getType() == PDFWriter::ListBox ) { - if( rNewWidget.m_nTextStyle == 0 ) - rNewWidget.m_nTextStyle = TEXT_DRAW_VCENTER; + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) + rNewWidget.m_nTextStyle = DrawTextFlags::VCenter; const PDFWriter::ListBoxWidget& rLstBox = static_cast<const PDFWriter::ListBoxWidget&>(rControl); rNewWidget.m_aListEntries = rLstBox.Entries; @@ -13403,8 +13403,8 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa } else if( rControl.getType() == PDFWriter::ComboBox ) { - if( rNewWidget.m_nTextStyle == 0 ) - rNewWidget.m_nTextStyle = TEXT_DRAW_VCENTER; + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) + rNewWidget.m_nTextStyle = DrawTextFlags::VCenter; const PDFWriter::ComboBoxWidget& rBox = static_cast<const PDFWriter::ComboBoxWidget&>(rControl); rNewWidget.m_aValue = rBox.Text; @@ -13434,14 +13434,14 @@ sal_Int32 PDFWriterImpl::createControl( const PDFWriter::AnyWidget& rControl, sa } else if( rControl.getType() == PDFWriter::Edit ) { - if( rNewWidget.m_nTextStyle == 0 ) - rNewWidget.m_nTextStyle = TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER; + if( rNewWidget.m_nTextStyle == DrawTextFlags::NONE ) + rNewWidget.m_nTextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter; const PDFWriter::EditWidget& rEdit = static_cast<const PDFWriter::EditWidget&>(rControl); if( rEdit.MultiLine ) { rNewWidget.m_nFlags |= 0x00001000; - rNewWidget.m_nTextStyle |= TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK; + rNewWidget.m_nTextStyle |= DrawTextFlags::MultiLine | DrawTextFlags::WordBreak; } if( rEdit.Password ) rNewWidget.m_nFlags |= 0x00002000; diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 60e12f58786b..ccd8ada7ce18 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -446,7 +446,7 @@ public: OString m_aName; OUString m_aDescription; OUString m_aText; - sal_uInt16 m_nTextStyle; + DrawTextFlags m_nTextStyle; OUString m_aValue; OString m_aDAString; OString m_aDRDict; @@ -472,7 +472,7 @@ public: PDFAppearanceMap m_aAppearances; PDFWidget() : m_eType( PDFWriter::PushButton ), - m_nTextStyle( 0 ), + m_nTextStyle( DrawTextFlags::NONE ), m_nFlags( 0 ), m_nParent( 0 ), m_nTabOrder( 0 ), @@ -1206,7 +1206,7 @@ public: void drawStretchText( const Point& rPos, sal_uLong nWidth, const OUString& rText, sal_Int32 nIndex, sal_Int32 nLen, bool bTextLines = true ); - void drawText( const Rectangle& rRect, const OUString& rOrigStr, sal_uInt16 nStyle, bool bTextLines = true ); + void drawText( const Rectangle& rRect, const OUString& rOrigStr, DrawTextFlags nStyle, bool bTextLines = true ); void drawTextLine( const Point& rPos, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, bool bUnderlineAbove ); void drawWaveTextLine( OStringBuffer& aLine, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove ); void drawStraightTextLine( OStringBuffer& aLine, long nWidth, FontUnderline eTextLine, Color aColor, bool bIsAbove ); diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx index f6a054518550..5b369b6f218b 100644 --- a/vcl/source/gdi/textlayout.cxx +++ b/vcl/source/gdi/textlayout.cxx @@ -88,7 +88,7 @@ namespace vcl public: // equivalents to the respective OutputDevice methods, which take the reference device into account long GetTextArray( const OUString& _rText, long* _pDXAry, sal_Int32 _nStartIndex, sal_Int32 _nLength ) const; - Rectangle DrawText( const Rectangle& _rRect, const OUString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText ); + Rectangle DrawText( const Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, MetricVector* _pVector, OUString* _pDisplayText ); protected: void onBeginDrawText() @@ -258,7 +258,7 @@ namespace vcl return true; } - Rectangle ReferenceDeviceTextLayout::DrawText( const Rectangle& _rRect, const OUString& _rText, sal_uInt16 _nStyle, MetricVector* _pVector, OUString* _pDisplayText ) + Rectangle ReferenceDeviceTextLayout::DrawText( const Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, MetricVector* _pVector, OUString* _pDisplayText ) { if ( _rText.isEmpty() ) return Rectangle(); @@ -317,7 +317,7 @@ namespace vcl { } - Rectangle ControlTextRenderer::DrawText( const Rectangle& _rRect, const OUString& _rText, sal_uInt16 _nStyle, + Rectangle ControlTextRenderer::DrawText( const Rectangle& _rRect, const OUString& _rText, DrawTextFlags _nStyle, MetricVector* _pVector, OUString* _pDisplayText ) { return m_pImpl->DrawText( _rRect, _rText, _nStyle, _pVector, _pDisplayText ); |