diff options
31 files changed, 439 insertions, 358 deletions
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index aa97613bf731..5d4aecb4329d 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -136,8 +136,8 @@ static RelationMap const aAsCharRelationMap[] = Anchored at page --------------------------------------------------------------------*/ -#define HORI_PAGE_REL (LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPageLeft| \ - LB::RelPageRight) +static constexpr auto HORI_PAGE_REL = LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPageLeft| + LB::RelPageRight; static FrmMap const aHPageMap[] = { @@ -171,8 +171,8 @@ static FrmMap const aVPageHtmlMap[] = Anchored at frame --------------------------------------------------------------------*/ -#define HORI_FRAME_REL (LB::FlyRelPageFrame|LB::FlyRelPagePrintArea| \ - LB::FlyRelPageLeft|LB::FlyRelPageRight) +static constexpr auto HORI_FRAME_REL = LB::FlyRelPageFrame|LB::FlyRelPagePrintArea| + LB::FlyRelPageLeft|LB::FlyRelPageRight; static FrmMap const aHFrameMap[] = { @@ -219,9 +219,9 @@ static FrmMap const aHMultiSelectionMap[] = Anchored at paragraph --------------------------------------------------------------------*/ -#define HORI_PARA_REL (LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| \ - LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| \ - LB::RelFrameRight) +static constexpr auto HORI_PARA_REL = LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| + LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| + LB::RelFrameRight; static FrmMap const aHParaMap[] = { @@ -246,8 +246,8 @@ static FrmMap const aHParaHtmlAbsMap[] = }; -#define VERT_PARA_REL (LB::VertFrame|LB::VertPrintArea| \ - LB::RelPageFrame|LB::RelPagePrintArea) +static constexpr auto VERT_PARA_REL = LB::VertFrame|LB::VertPrintArea| + LB::RelPageFrame|LB::RelPagePrintArea; static FrmMap const aVParaMap[] = { @@ -266,9 +266,9 @@ static FrmMap const aVParaHtmlMap[] = Anchored at character --------------------------------------------------------------------*/ -#define HORI_CHAR_REL (LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| \ - LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| \ - LB::RelFrameRight|LB::RelChar) +static constexpr auto HORI_CHAR_REL = LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| + LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| + LB::RelFrameRight|LB::RelChar; static FrmMap aHCharMap[] = { @@ -295,8 +295,8 @@ static FrmMap aHCharHtmlAbsMap[] = // #i18732# - allow vertical alignment at page areas // #i22341# - handle <LB::RelChar> on its own -#define VERT_CHAR_REL (LB::VertFrame|LB::VertPrintArea| \ - LB::RelPageFrame|LB::RelPagePrintArea) +static constexpr auto VERT_CHAR_REL = LB::VertFrame|LB::VertPrintArea| + LB::RelPageFrame|LB::RelPagePrintArea; static FrmMap aVCharMap[] = { diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx index 377913d832e7..59f0aa57a398 100644 --- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -29,8 +29,8 @@ namespace dbaui { -#define BROWSER_STANDARD_FLAGS BrowserMode::COLUMNSELECTION | BrowserMode::HLINES | BrowserMode::VLINES | \ - BrowserMode::HIDECURSOR | BrowserMode::HIDESELECT | BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL +static constexpr auto BROWSER_STANDARD_FLAGS = BrowserMode::COLUMNSELECTION | BrowserMode::HLINES | BrowserMode::VLINES | + BrowserMode::HIDECURSOR | BrowserMode::HIDESELECT | BrowserMode::AUTO_HSCROLL | BrowserMode::AUTO_VSCROLL; #define COLUMN_ID_FIELDNAME 1 #define COLUMN_ID_ORDER 2 diff --git a/i18npool/source/inputchecker/inputsequencechecker_hi.cxx b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx index 4e65a655ac7f..c560833a9020 100644 --- a/i18npool/source/inputchecker/inputsequencechecker_hi.cxx +++ b/i18npool/source/inputchecker/inputsequencechecker_hi.cxx @@ -101,8 +101,10 @@ bool const DEV_Composible[2][2] = { /* Mode 1 */ {false, true} // STRICT = 1 }; -#define getCharType(x) \ - ((x >= 0x0900 && x < 0x097f) ? devaCT[x - 0x0900] : ND_) +static constexpr sal_uInt16 getCharType(sal_Unicode x) +{ + return (x >= 0x0900 && x < 0x097f) ? devaCT[x - 0x0900] : ND_; +} sal_Bool SAL_CALL InputSequenceChecker_hi::checkInputSequence(const OUString& Text, diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 16201a96b22b..7df620731bb1 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -697,19 +697,23 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS } // const cast, otherwise it will be too inefficient/complicated -#define SET_LINECOLOR(dest,c) \ - if ((dest)) \ - { \ - const_cast<SvxBorderLine*>(dest)->SetColor((c)); \ +static void SetLineColor(SvxBorderLine const * dest, Color c) +{ + if (dest) + { + const_cast<SvxBorderLine*>(dest)->SetColor(c); } +} -#define SET_LINE(dest,src) \ - if ((dest)) \ - { \ - SvxBorderLine* pCast = const_cast<SvxBorderLine*>(dest); \ - pCast->SetBorderLineStyle( (src)->GetBorderLineStyle() ); \ - pCast->SetWidth( (src)->GetWidth( ) ); \ +static void SetLine(const SvxBorderLine* dest, const SvxBorderLine* src) +{ + if (dest) + { + SvxBorderLine* pCast = const_cast<SvxBorderLine*>(dest); + pCast->SetBorderLineStyle( src->GetBorderLineStyle() ); + pCast->SetWidth( src->GetWidth() ); } +} void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, const SvxBorderLine* pLine, bool bColorOnly ) @@ -773,29 +777,29 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, Color aColor( pLine->GetColor() ); if( pNewBoxItem ) { - SET_LINECOLOR( pNewBoxItem->GetTop(), aColor ); - SET_LINECOLOR( pNewBoxItem->GetBottom(), aColor ); - SET_LINECOLOR( pNewBoxItem->GetLeft(), aColor ); - SET_LINECOLOR( pNewBoxItem->GetRight(), aColor ); + SetLineColor( pNewBoxItem->GetTop(), aColor ); + SetLineColor( pNewBoxItem->GetBottom(), aColor ); + SetLineColor( pNewBoxItem->GetLeft(), aColor ); + SetLineColor( pNewBoxItem->GetRight(), aColor ); } if( pNewTLBRItem ) - SET_LINECOLOR( pNewTLBRItem->GetLine(), aColor ); + SetLineColor( pNewTLBRItem->GetLine(), aColor ); if( pNewBLTRItem ) - SET_LINECOLOR( pNewBLTRItem->GetLine(), aColor ); + SetLineColor( pNewBLTRItem->GetLine(), aColor ); } else { if( pNewBoxItem ) { - SET_LINE( pNewBoxItem->GetTop(), pLine ); - SET_LINE( pNewBoxItem->GetBottom(), pLine ); - SET_LINE( pNewBoxItem->GetLeft(), pLine ); - SET_LINE( pNewBoxItem->GetRight(), pLine ); + SetLine( pNewBoxItem->GetTop(), pLine ); + SetLine( pNewBoxItem->GetBottom(), pLine ); + SetLine( pNewBoxItem->GetLeft(), pLine ); + SetLine( pNewBoxItem->GetRight(), pLine ); } if( pNewTLBRItem ) - SET_LINE( pNewTLBRItem->GetLine(), pLine ); + SetLine( pNewTLBRItem->GetLine(), pLine ); if( pNewBLTRItem ) - SET_LINE( pNewBLTRItem->GetLine(), pLine ); + SetLine( pNewBLTRItem->GetLine(), pLine ); } } if( pNewBoxItem ) rNewSet.Put( *pNewBoxItem ); @@ -834,9 +838,6 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, } } -#undef SET_LINECOLOR -#undef SET_LINE - void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCache* pCache, ScEditDataArray* pDataArray, bool* const pIsChanged ) { #if DEBUG_SC_TESTATTRARRAY diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index 1344581737db..64239976d29f 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -42,9 +42,9 @@ #define IMPICNVIEW_ACC_RETURN 1 #define IMPICNVIEW_ACC_ESCAPE 2 -#define DRAWTEXT_FLAGS_ICON \ - ( DrawTextFlags::Center | DrawTextFlags::Top | DrawTextFlags::EndEllipsis | \ - DrawTextFlags::Clip | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak | DrawTextFlags::Mnemonic ) +static constexpr auto DRAWTEXT_FLAGS_ICON = + DrawTextFlags::Center | DrawTextFlags::Top | DrawTextFlags::EndEllipsis | + DrawTextFlags::Clip | DrawTextFlags::MultiLine | DrawTextFlags::WordBreak | DrawTextFlags::Mnemonic; #define DRAWTEXT_FLAGS_SMALLICON (DrawTextFlags::Left|DrawTextFlags::EndEllipsis|DrawTextFlags::Clip) diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index c9e6acc2df65..8fb4aef8d84a 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -33,8 +33,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::accessibility; -#define MYTABMASK \ - SvLBoxTabFlags( SvLBoxTabFlags::ADJUST_RIGHT | SvLBoxTabFlags::ADJUST_LEFT | SvLBoxTabFlags::ADJUST_CENTER | SvLBoxTabFlags::ADJUST_NUMERIC ) +static constexpr SvLBoxTabFlags MYTABMASK = + SvLBoxTabFlags::ADJUST_RIGHT | SvLBoxTabFlags::ADJUST_LEFT | SvLBoxTabFlags::ADJUST_CENTER | SvLBoxTabFlags::ADJUST_NUMERIC; // SvTreeListBox callback diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index dcdd6e913fbd..29664c00d673 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -79,14 +79,14 @@ using namespace com::sun::star::accessibility; #define ROWSTATUS(row) (!row.is() ? "NULL" : row->GetStatus() == GridRowStatus::Clean ? "CLEAN" : row->GetStatus() == GridRowStatus::Modified ? "MODIFIED" : row->GetStatus() == GridRowStatus::Deleted ? "DELETED" : "INVALID") -#define DEFAULT_BROWSE_MODE \ - BrowserMode::COLUMNSELECTION \ - | BrowserMode::MULTISELECTION \ - | BrowserMode::KEEPHIGHLIGHT \ - | BrowserMode::TRACKING_TIPS \ - | BrowserMode::HLINES \ - | BrowserMode::VLINES \ - | BrowserMode::HEADERBAR_NEW \ +static constexpr auto DEFAULT_BROWSE_MODE = + BrowserMode::COLUMNSELECTION + | BrowserMode::MULTISELECTION + | BrowserMode::KEEPHIGHLIGHT + | BrowserMode::TRACKING_TIPS + | BrowserMode::HLINES + | BrowserMode::VLINES + | BrowserMode::HEADERBAR_NEW; class RowSetEventListener : public ::cppu::WeakImplHelper<XRowsChangeListener> { diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 308f8714ca3b..cea0bdb9a591 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -711,13 +711,14 @@ bool SwNoTextFrame::GetCursorOfst(SwPosition* pPos, Point& , return true; } -#define CLEARCACHE {\ - SwFlyFrame* pFly = FindFlyFrame();\ - if( pFly && pFly->GetFormat()->GetSurround().IsContour() )\ - {\ - ClrContourCache( pFly->GetVirtDrawObj() );\ - pFly->NotifyBackground( FindPageFrame(), getFramePrintArea(), PREP_FLY_ATTR_CHG );\ - }\ +void SwNoTextFrame::ClearCache() +{ + SwFlyFrame* pFly = FindFlyFrame(); + if( pFly && pFly->GetFormat()->GetSurround().IsContour() ) + { + ClrContourCache( pFly->GetVirtDrawObj() ); + pFly->NotifyBackground( FindPageFrame(), getFramePrintArea(), PREP_FLY_ATTR_CHG ); + } } void SwNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) @@ -755,7 +756,7 @@ void SwNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) } SAL_FALLTHROUGH; case RES_FMT_CHG: - CLEARCACHE + ClearCache(); break; case RES_ATTRSET_CHG: @@ -765,7 +766,7 @@ void SwNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) if( SfxItemState::SET == static_cast<const SwAttrSetChg*>(pOld)->GetChgSet()-> GetItemState( n, false )) { - CLEARCACHE + ClearCache(); if(RES_GRFATR_ROTATION == n) { @@ -814,7 +815,7 @@ void SwNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) bComplete = false; SwGrfNode* pNd = static_cast<SwGrfNode*>( GetNode()); - CLEARCACHE + ClearCache(); SwRect aRect( getFrameArea() ); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index cc88b7e5bb2f..787db5fbecf7 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -331,12 +331,20 @@ bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj ) * for the nearest fly frame in the given direction. */ -#define LESS_X( aPt1, aPt2, bOld ) ( aPt1.getX() < aPt2.getX() || \ - ( aPt1.getX() == aPt2.getX() && ( aPt1.getY() < aPt2.getY() || \ - ( aPt1.getY() == aPt2.getY() && bOld ) ) ) ) -#define LESS_Y( aPt1, aPt2, bOld ) ( aPt1.getY() < aPt2.getY() || \ - ( aPt1.getY() == aPt2.getY() && ( aPt1.getX() < aPt2.getX() || \ - ( aPt1.getX() == aPt2.getX() && bOld ) ) ) ) +static bool LessX( Point const & aPt1, Point const & aPt2, bool bOld ) +{ + return aPt1.getX() < aPt2.getX() + || ( aPt1.getX() == aPt2.getX() + && ( aPt1.getY() < aPt2.getY() + || ( aPt1.getY() == aPt2.getY() && bOld ) ) ); +} +static bool LessY( Point const & aPt1, Point const & aPt2, bool bOld ) +{ + return aPt1.getY() < aPt2.getY() + || ( aPt1.getY() == aPt2.getY() + && ( aPt1.getX() < aPt2.getX() + || ( aPt1.getX() == aPt2.getX() && bOld ) ) ); +} bool SwFEShell::MoveAnchor( SwMove nDir ) { @@ -495,30 +503,30 @@ bool SwFEShell::MoveAnchor( SwMove nDir ) switch( nDir ) { case SwMove::RIGHT: { - bAccept = LESS_X( aCenter, aNew, bOld ) + bAccept = LessX( aCenter, aNew, bOld ) && ( !pNewFly || - LESS_X( aNew, aBest, false ) ); + LessX( aNew, aBest, false ) ); break; } case SwMove::LEFT: { - bAccept = LESS_X( aNew, aCenter, !bOld ) + bAccept = LessX( aNew, aCenter, !bOld ) && ( !pNewFly || - LESS_X( aBest, aNew, true ) ); + LessX( aBest, aNew, true ) ); break; } case SwMove::UP: { - bAccept = LESS_Y( aNew, aCenter, !bOld ) + bAccept = LessY( aNew, aCenter, !bOld ) && ( !pNewFly || - LESS_Y( aBest, aNew, true ) ); + LessY( aBest, aNew, true ) ); break; } case SwMove::DOWN: { - bAccept = LESS_Y( aCenter, aNew, bOld ) + bAccept = LessY( aCenter, aNew, bOld ) && ( !pNewFly || - LESS_Y( aNew, aBest, false ) ); + LessY( aNew, aBest, false ) ); break; } } diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx index eaa10653964b..fad416c27d8f 100644 --- a/sw/source/core/inc/notxtfrm.hxx +++ b/sw/source/core/inc/notxtfrm.hxx @@ -47,6 +47,8 @@ private: friend double getLocalFrameRotation_from_SwNoTextFrame(const SwNoTextFrame& rNoTextFrame); double getLocalFrameRotation() const; + void ClearCache(); + protected: virtual void MakeAll(vcl::RenderContext* pRenderContext) override; virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx index d30f3d3bf97e..91b70e918c0a 100644 --- a/sw/source/core/inc/txtfrm.hxx +++ b/sw/source/core/inc/txtfrm.hxx @@ -186,6 +186,7 @@ class SW_DLLPUBLIC SwTextFrame: public SwContentFrame // WidowsAndOrphans, AdjustFrame, AdjustFollow void FormatAdjust( SwTextFormatter &rLine, WidowsAndOrphans &rFrameBreak, TextFrameIndex nStrLen, const bool bDummy ); + void ChangeOffset( SwTextFrame* pFrame, TextFrameIndex nNew ); bool mbLocked : 1; // In the Format? bool mbWidow : 1; // Are we a Widow? diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index f7b96f94e3ea..bfb80dbd8de8 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -121,22 +121,6 @@ using std::make_pair; struct SwPaintProperties; -//other subsidiary lines enabled? -#define IS_SUBS (!gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && \ - !gProp.pSGlobalShell->GetViewOptions()->IsReadonly() && \ - !gProp.pSGlobalShell->GetViewOptions()->IsFormView() &&\ - !gProp.pSGlobalShell->GetViewOptions()->IsWhitespaceHidden() &&\ - SwViewOption::IsDocBoundaries()) -//subsidiary lines for sections -#define IS_SUBS_SECTION (!gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && \ - !gProp.pSGlobalShell->GetViewOptions()->IsReadonly()&&\ - !gProp.pSGlobalShell->GetViewOptions()->IsFormView() &&\ - SwViewOption::IsSectionBoundaries()) -#define IS_SUBS_FLYS (!gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && \ - !gProp.pSGlobalShell->GetViewOptions()->IsReadonly()&&\ - !gProp.pSGlobalShell->GetViewOptions()->IsFormView() &&\ - SwViewOption::IsObjectBoundaries()) - //Class declaration; here because they are only used in this file enum class SubColFlags { Page = 0x01, //Helplines of the page @@ -317,6 +301,32 @@ struct SwPaintProperties { static SwPaintProperties gProp; +static bool isSubsidiaryLinesFlysEnabled() +{ + return !gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && + !gProp.pSGlobalShell->GetViewOptions()->IsReadonly() && + !gProp.pSGlobalShell->GetViewOptions()->IsFormView() && + SwViewOption::IsObjectBoundaries(); +} +//other subsidiary lines enabled? +static bool isSubsidiaryLinesEnabled() +{ + return !gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && + !gProp.pSGlobalShell->GetViewOptions()->IsReadonly() && + !gProp.pSGlobalShell->GetViewOptions()->IsFormView() && + !gProp.pSGlobalShell->GetViewOptions()->IsWhitespaceHidden() && + SwViewOption::IsDocBoundaries(); +} +//subsidiary lines for sections +static bool isSubsidiaryLinesForSectionsEnabled() +{ + return !gProp.pSGlobalShell->GetViewOptions()->IsPagePreview() && + !gProp.pSGlobalShell->GetViewOptions()->IsReadonly() && + !gProp.pSGlobalShell->GetViewOptions()->IsFormView() && + SwViewOption::IsSectionBoundaries(); +} + + namespace { bool isTableBoundariesEnabled() @@ -6325,7 +6335,8 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP /// Refreshes all subsidiary lines of a page. void SwPageFrame::RefreshSubsidiary( const SwRect &rRect ) const { - if ( IS_SUBS || isTableBoundariesEnabled() || IS_SUBS_SECTION || IS_SUBS_FLYS ) + if ( isSubsidiaryLinesEnabled() || isTableBoundariesEnabled() + || isSubsidiaryLinesForSectionsEnabled() || isSubsidiaryLinesFlysEnabled() ) { if ( rRect.HasArea() ) { @@ -6359,7 +6370,7 @@ void SwPageFrame::RefreshSubsidiary( const SwRect &rRect ) const void SwLayoutFrame::RefreshLaySubsidiary( const SwPageFrame *pPage, const SwRect &rRect ) const { - const bool bSubsOpt = IS_SUBS; + const bool bSubsOpt = isSubsidiaryLinesEnabled(); if ( bSubsOpt ) PaintSubsidiaryLines( pPage, rRect ); diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index fd09c2632cfb..84d8785dc4d1 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -993,13 +993,13 @@ bool SwTextFrame::CalcPreps() } // We rewire the footnotes and the character bound objects -#define CHG_OFFSET( pFrame, nNew )\ - {\ - if( pFrame->GetOfst() < nNew )\ - pFrame->MoveFlyInCnt( this, TextFrameIndex(0), nNew );\ - else if( pFrame->GetOfst() > nNew )\ - MoveFlyInCnt( pFrame, nNew, TextFrameIndex(COMPLETE_STRING) );\ - } +void SwTextFrame::ChangeOffset( SwTextFrame* pFrame, TextFrameIndex nNew ) +{ + if( pFrame->GetOfst() < nNew ) + pFrame->MoveFlyInCnt( this, TextFrameIndex(0), nNew ); + else if( pFrame->GetOfst() > nNew ) + MoveFlyInCnt( pFrame, nNew, TextFrameIndex(COMPLETE_STRING) ); +} void SwTextFrame::FormatAdjust( SwTextFormatter &rLine, WidowsAndOrphans &rFrameBreak, @@ -1077,7 +1077,7 @@ void SwTextFrame::FormatAdjust( SwTextFormatter &rLine, { if( nNew && nOld < nEnd ) RemoveFootnote( nOld, nEnd - nOld ); - CHG_OFFSET( GetFollow(), nEnd ) + ChangeOffset( GetFollow(), nEnd ); if( !bDelta ) GetFollow()->ManipOfst( nEnd ); } @@ -1112,7 +1112,7 @@ void SwTextFrame::FormatAdjust( SwTextFormatter &rLine, // for the paragraph mark. nNew |= 1; } - CHG_OFFSET( GetFollow(), nEnd ) + ChangeOffset( GetFollow(), nEnd ); GetFollow()->ManipOfst( nEnd ); } else diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 76c5ce2be016..4a88c34dea9e 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -170,8 +170,8 @@ static RelationMap const aAsCharRelationMap[] = }; // site anchored -#define HORI_PAGE_REL (LB::RelPageFrame|LB::RelPagePrintArea|LB::RelPageLeft| \ - LB::RelPageRight) +static constexpr auto HORI_PAGE_REL = LB::RelPageFrame | LB::RelPagePrintArea | LB::RelPageLeft | + LB::RelPageRight; static FrameMap const aHPageMap[] = { @@ -202,8 +202,8 @@ static FrameMap const aVPageHtmlMap[] = }; // frame anchored -#define HORI_FRAME_REL (LB::FlyRelPageFrame|LB::FlyRelPagePrintArea| \ - LB::FlyRelPageLeft|LB::FlyRelPageRight) +static constexpr auto HORI_FRAME_REL = LB::FlyRelPageFrame | LB::FlyRelPagePrintArea | + LB::FlyRelPageLeft | LB::FlyRelPageRight; static FrameMap const aHFrameMap[] = { @@ -237,9 +237,9 @@ static FrameMap const aVFlyHtmlMap[] = }; // paragraph anchored -#define HORI_PARA_REL (LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| \ - LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| \ - LB::RelFrameRight) +static constexpr auto HORI_PARA_REL = LB::Frame | LB::PrintArea | LB::RelPageLeft | LB::RelPageRight | + LB::RelPageFrame | LB::RelPagePrintArea | LB::RelFrameLeft | + LB::RelFrameRight; static FrameMap const aHParaMap[] = { @@ -264,8 +264,8 @@ static FrameMap const aHParaHtmlAbsMap[] = }; // allow vertical alignment at page areas -#define VERT_PARA_REL (LB::VertFrame|LB::VertPrintArea| \ - LB::RelPageFrame|LB::RelPagePrintArea) +static constexpr auto VERT_PARA_REL = LB::VertFrame | LB::VertPrintArea | + LB::RelPageFrame | LB::RelPagePrintArea; static FrameMap const aVParaMap[] = { @@ -281,9 +281,9 @@ static FrameMap const aVParaHtmlMap[] = }; // anchored relative to the character -#define HORI_CHAR_REL (LB::Frame|LB::PrintArea|LB::RelPageLeft|LB::RelPageRight| \ - LB::RelPageFrame|LB::RelPagePrintArea|LB::RelFrameLeft| \ - LB::RelFrameRight|LB::RelChar) +static constexpr auto HORI_CHAR_REL = LB::Frame|LB::PrintArea | LB::RelPageLeft | LB::RelPageRight | + LB::RelPageFrame | LB::RelPagePrintArea | LB::RelFrameLeft | + LB::RelFrameRight | LB::RelChar; static FrameMap const aHCharMap[] = { @@ -309,8 +309,8 @@ static FrameMap const aHCharHtmlAbsMap[] = }; // allow vertical alignment at page areas -#define VERT_CHAR_REL (LB::VertFrame|LB::VertPrintArea| \ - LB::RelPageFrame|LB::RelPagePrintArea) +static constexpr auto VERT_CHAR_REL = LB::VertFrame | LB::VertPrintArea | + LB::RelPageFrame | LB::RelPagePrintArea; static FrameMap const aVCharMap[] = { diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index e7d21d950e39..818726b2a619 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -34,11 +34,13 @@ #include <comphelper/fileformat.h> -#define SWAPNIBBLES(c) \ -unsigned char nSwapTmp=c; \ -nSwapTmp <<= 4; \ -c >>= 4; \ -c |= nSwapTmp; +static void swapNibbles(unsigned char &c) +{ + unsigned char nSwapTmp=c; + nSwapTmp <<= 4; + c >>= 4; + c |= nSwapTmp; +} #include <tools/debug.hxx> #include <tools/stream.hxx> @@ -1488,7 +1490,7 @@ std::size_t SvStream::CryptAndWriteBuffer( const void* pStart, std::size_t nLen) { unsigned char aCh = rn; aCh ^= nMask; - SWAPNIBBLES(aCh) + swapNibbles(aCh); rn = aCh; } // ************************* @@ -1507,7 +1509,7 @@ void SvStream::EncryptBuffer(void* pStart, std::size_t nLen) const for ( std::size_t n=0; n < nLen; n++, pTemp++ ) { unsigned char aCh = *pTemp; - SWAPNIBBLES(aCh) + swapNibbles(aCh); aCh ^= nMask; *pTemp = aCh; } diff --git a/ucb/source/cacher/cachedcontentresultsetstub.cxx b/ucb/source/cacher/cachedcontentresultsetstub.cxx index 8642e53a7cfa..b9085f7ac323 100644 --- a/ucb/source/cacher/cachedcontentresultsetstub.cxx +++ b/ucb/source/cacher/cachedcontentresultsetstub.cxx @@ -179,125 +179,131 @@ css::uno::Sequence< OUString > SAL_CALL CachedContentResultSetStub::getSupported // XFetchProvider methods. -#define FETCH_XXX( impl_loadRow, loadInterface ) \ -impl_EnsureNotDisposed(); \ -if( !m_xResultSetOrigin.is() ) \ -{ \ - OSL_FAIL( "broadcaster was disposed already" ); \ - throw RuntimeException(); \ -} \ -impl_propagateFetchSizeAndDirection( nRowCount, bDirection ); \ -FetchResult aRet; \ -aRet.StartIndex = nRowStartPosition; \ -aRet.Orientation = bDirection; \ -aRet.FetchError = FetchError::SUCCESS; /*ENDOFDATA, EXCEPTION*/ \ -sal_Int32 nOldOriginal_Pos = m_xResultSetOrigin->getRow(); \ -if( impl_isForwardOnly() ) \ -{ \ - if( nOldOriginal_Pos != nRowStartPosition ) \ - { \ - /*@todo*/ \ - aRet.FetchError = FetchError::EXCEPTION; \ - return aRet; \ - } \ - if( nRowCount != 1 ) \ - aRet.FetchError = FetchError::EXCEPTION; \ - \ - aRet.Rows.realloc( 1 ); \ - \ - try \ - { \ - impl_loadRow( aRet.Rows[0], loadInterface ); \ - } \ - catch( SQLException& ) \ - { \ - aRet.Rows.realloc( 0 ); \ - aRet.FetchError = FetchError::EXCEPTION; \ - return aRet; \ - } \ - return aRet; \ -} \ -aRet.Rows.realloc( nRowCount ); \ -bool bOldOriginal_AfterLast = false; \ -if( !nOldOriginal_Pos ) \ - bOldOriginal_AfterLast = m_xResultSetOrigin->isAfterLast(); \ -sal_Int32 nN = 1; \ -bool bValidNewPos = false; \ -try \ -{ \ - try \ - { \ - /*if( nOldOriginal_Pos != nRowStartPosition )*/ \ - bValidNewPos = m_xResultSetOrigin->absolute( nRowStartPosition ); \ - } \ - catch( SQLException& ) \ - { \ - aRet.Rows.realloc( 0 ); \ - aRet.FetchError = FetchError::EXCEPTION; \ - return aRet; \ - } \ - if( !bValidNewPos ) \ - { \ - aRet.Rows.realloc( 0 ); \ - aRet.FetchError = FetchError::EXCEPTION; \ - \ - /*restore old position*/ \ - if( nOldOriginal_Pos ) \ - m_xResultSetOrigin->absolute( nOldOriginal_Pos ); \ - else if( bOldOriginal_AfterLast ) \ - m_xResultSetOrigin->afterLast(); \ - else \ - m_xResultSetOrigin->beforeFirst(); \ - \ - return aRet; \ - } \ - for( ; nN <= nRowCount; ) \ - { \ - impl_loadRow( aRet.Rows[nN-1], loadInterface ); \ - nN++; \ - if( nN <= nRowCount ) \ - { \ - if( bDirection ) \ - { \ - if( !m_xResultSetOrigin->next() ) \ - { \ - aRet.Rows.realloc( nN-1 ); \ - aRet.FetchError = FetchError::ENDOFDATA; \ - break; \ - } \ - } \ - else \ - { \ - if( !m_xResultSetOrigin->previous() ) \ - { \ - aRet.Rows.realloc( nN-1 ); \ - aRet.FetchError = FetchError::ENDOFDATA; \ - break; \ - } \ - } \ - } \ - } \ -} \ -catch( SQLException& ) \ -{ \ - aRet.Rows.realloc( nN-1 ); \ - aRet.FetchError = FetchError::EXCEPTION; \ -} \ -/*restore old position*/ \ -if( nOldOriginal_Pos ) \ - m_xResultSetOrigin->absolute( nOldOriginal_Pos ); \ -else if( bOldOriginal_AfterLast ) \ - m_xResultSetOrigin->afterLast(); \ -else \ - m_xResultSetOrigin->beforeFirst(); \ -return aRet; +FetchResult CachedContentResultSetStub::impl_fetchHelper( + sal_Int32 nRowStartPosition, sal_Int32 nRowCount, bool bDirection, + std::function<void( css::uno::Any& rRowContent)> impl_loadRow) +{ + impl_EnsureNotDisposed(); + if( !m_xResultSetOrigin.is() ) + { + OSL_FAIL( "broadcaster was disposed already" ); + throw RuntimeException(); + } + impl_propagateFetchSizeAndDirection( nRowCount, bDirection ); + FetchResult aRet; + aRet.StartIndex = nRowStartPosition; + aRet.Orientation = bDirection; + aRet.FetchError = FetchError::SUCCESS; /*ENDOFDATA, EXCEPTION*/ + sal_Int32 nOldOriginal_Pos = m_xResultSetOrigin->getRow(); + if( impl_isForwardOnly() ) + { + if( nOldOriginal_Pos != nRowStartPosition ) + { + /*@todo*/ + aRet.FetchError = FetchError::EXCEPTION; + return aRet; + } + if( nRowCount != 1 ) + aRet.FetchError = FetchError::EXCEPTION; + + aRet.Rows.realloc( 1 ); + + try + { + impl_loadRow( aRet.Rows[0] ); + } + catch( SQLException& ) + { + aRet.Rows.realloc( 0 ); + aRet.FetchError = FetchError::EXCEPTION; + return aRet; + } + return aRet; + } + aRet.Rows.realloc( nRowCount ); + bool bOldOriginal_AfterLast = false; + if( !nOldOriginal_Pos ) + bOldOriginal_AfterLast = m_xResultSetOrigin->isAfterLast(); + sal_Int32 nN = 1; + bool bValidNewPos = false; + try + { + try + { + /*if( nOldOriginal_Pos != nRowStartPosition )*/ + bValidNewPos = m_xResultSetOrigin->absolute( nRowStartPosition ); + } + catch( SQLException& ) + { + aRet.Rows.realloc( 0 ); + aRet.FetchError = FetchError::EXCEPTION; + return aRet; + } + if( !bValidNewPos ) + { + aRet.Rows.realloc( 0 ); + aRet.FetchError = FetchError::EXCEPTION; + + /*restore old position*/ + if( nOldOriginal_Pos ) + m_xResultSetOrigin->absolute( nOldOriginal_Pos ); + else if( bOldOriginal_AfterLast ) + m_xResultSetOrigin->afterLast(); + else + m_xResultSetOrigin->beforeFirst(); + + return aRet; + } + for( ; nN <= nRowCount; ) + { + impl_loadRow( aRet.Rows[nN-1] ); + nN++; + if( nN <= nRowCount ) + { + if( bDirection ) + { + if( !m_xResultSetOrigin->next() ) + { + aRet.Rows.realloc( nN-1 ); + aRet.FetchError = FetchError::ENDOFDATA; + break; + } + } + else + { + if( !m_xResultSetOrigin->previous() ) + { + aRet.Rows.realloc( nN-1 ); + aRet.FetchError = FetchError::ENDOFDATA; + break; + } + } + } + } + } + catch( SQLException& ) + { + aRet.Rows.realloc( nN-1 ); + aRet.FetchError = FetchError::EXCEPTION; + } + /*restore old position*/ + if( nOldOriginal_Pos ) + m_xResultSetOrigin->absolute( nOldOriginal_Pos ); + else if( bOldOriginal_AfterLast ) + m_xResultSetOrigin->afterLast(); + else + m_xResultSetOrigin->beforeFirst(); + return aRet; +} FetchResult SAL_CALL CachedContentResultSetStub ::fetch( sal_Int32 nRowStartPosition , sal_Int32 nRowCount, sal_Bool bDirection ) { impl_init_xRowOrigin(); - FETCH_XXX( impl_getCurrentRowContent, m_xRowOrigin ); + return impl_fetchHelper( nRowStartPosition, nRowCount, bDirection, + [&](css::uno::Any& rRowContent) + { return impl_getCurrentRowContent(rRowContent, m_xRowOrigin); }); } sal_Int32 CachedContentResultSetStub @@ -460,7 +466,9 @@ FetchResult SAL_CALL CachedContentResultSetStub , sal_Int32 nRowCount, sal_Bool bDirection ) { impl_init_xContentAccessOrigin(); - FETCH_XXX( impl_getCurrentContentIdentifierString, m_xContentAccessOrigin ); + return impl_fetchHelper( nRowStartPosition, nRowCount, bDirection, + [&](css::uno::Any& rRowContent) + { return impl_getCurrentContentIdentifierString(rRowContent, m_xContentAccessOrigin); }); } //virtual @@ -469,7 +477,9 @@ FetchResult SAL_CALL CachedContentResultSetStub , sal_Int32 nRowCount, sal_Bool bDirection ) { impl_init_xContentAccessOrigin(); - FETCH_XXX( impl_getCurrentContentIdentifier, m_xContentAccessOrigin ); + return impl_fetchHelper( nRowStartPosition, nRowCount, bDirection, + [&](css::uno::Any& rRowContent) + { return impl_getCurrentContentIdentifier(rRowContent, m_xContentAccessOrigin); }); } //virtual @@ -478,7 +488,9 @@ FetchResult SAL_CALL CachedContentResultSetStub , sal_Int32 nRowCount, sal_Bool bDirection ) { impl_init_xContentAccessOrigin(); - FETCH_XXX( impl_getCurrentContent, m_xContentAccessOrigin ); + return impl_fetchHelper( nRowStartPosition, nRowCount, bDirection, + [&](css::uno::Any& rRowContent) + { return impl_getCurrentContent(rRowContent, m_xContentAccessOrigin); }); } diff --git a/ucb/source/cacher/cachedcontentresultsetstub.hxx b/ucb/source/cacher/cachedcontentresultsetstub.hxx index 65f120086604..c4ba74410680 100644 --- a/ucb/source/cacher/cachedcontentresultsetstub.hxx +++ b/ucb/source/cacher/cachedcontentresultsetstub.hxx @@ -82,6 +82,9 @@ private: void impl_propagateFetchSizeAndDirection( sal_Int32 nFetchSize, bool bFetchDirection ); + css::ucb::FetchResult impl_fetchHelper(sal_Int32 nRowStartPosition, sal_Int32 nRowCount, bool bDirection, + std::function<void(css::uno::Any& rRowContent)> impl_loadRow); + public: CachedContentResultSetStub( css::uno::Reference< css::sdbc::XResultSet > const & xOrigin ); diff --git a/ucb/source/cacher/contentresultsetwrapper.cxx b/ucb/source/cacher/contentresultsetwrapper.cxx index 8cf5c5b07f8c..be35593388c0 100644 --- a/ucb/source/cacher/contentresultsetwrapper.cxx +++ b/ucb/source/cacher/contentresultsetwrapper.cxx @@ -1055,15 +1055,16 @@ Reference< XInterface > SAL_CALL ContentResultSetWrapper::getStatement() // XRow methods. -#define XROW_GETXXX( getXXX ) \ -impl_EnsureNotDisposed(); \ -impl_init_xRowOrigin(); \ -if( !m_xRowOrigin.is() ) \ -{ \ - OSL_FAIL( "broadcaster was disposed already" );\ - throw RuntimeException(); \ -} \ -return m_xRowOrigin->getXXX( columnIndex ); +void ContentResultSetWrapper::verifyGet() +{ + impl_EnsureNotDisposed(); + impl_init_xRowOrigin(); + if( !m_xRowOrigin.is() ) + { + OSL_FAIL( "broadcaster was disposed already" ); + throw RuntimeException(); + } +} //virtual sal_Bool SAL_CALL ContentResultSetWrapper::wasNull() @@ -1081,85 +1082,99 @@ sal_Bool SAL_CALL ContentResultSetWrapper::wasNull() //virtual OUString SAL_CALL ContentResultSetWrapper::getString( sal_Int32 columnIndex ) { - XROW_GETXXX( getString ); + verifyGet(); + return m_xRowOrigin->getString( columnIndex ); } //virtual sal_Bool SAL_CALL ContentResultSetWrapper::getBoolean( sal_Int32 columnIndex ) { - XROW_GETXXX( getBoolean ); + verifyGet(); + return m_xRowOrigin->getBoolean( columnIndex ); } //virtual sal_Int8 SAL_CALL ContentResultSetWrapper::getByte( sal_Int32 columnIndex ) { - XROW_GETXXX( getByte ); + verifyGet(); + return m_xRowOrigin->getByte( columnIndex ); } //virtual sal_Int16 SAL_CALL ContentResultSetWrapper::getShort( sal_Int32 columnIndex ) { - XROW_GETXXX( getShort ); + verifyGet(); + return m_xRowOrigin->getShort( columnIndex ); } //virtual sal_Int32 SAL_CALL ContentResultSetWrapper::getInt( sal_Int32 columnIndex ) { - XROW_GETXXX( getInt ); + verifyGet(); + return m_xRowOrigin->getInt( columnIndex ); } //virtual sal_Int64 SAL_CALL ContentResultSetWrapper::getLong( sal_Int32 columnIndex ) { - XROW_GETXXX( getLong ); + verifyGet(); + return m_xRowOrigin->getLong( columnIndex ); } //virtual float SAL_CALL ContentResultSetWrapper::getFloat( sal_Int32 columnIndex ) { - XROW_GETXXX( getFloat ); + verifyGet(); + return m_xRowOrigin->getFloat( columnIndex ); } //virtual double SAL_CALL ContentResultSetWrapper::getDouble( sal_Int32 columnIndex ) { - XROW_GETXXX( getDouble ); + verifyGet(); + return m_xRowOrigin->getDouble( columnIndex ); } //virtual Sequence< sal_Int8 > SAL_CALL ContentResultSetWrapper::getBytes( sal_Int32 columnIndex ) { - XROW_GETXXX( getBytes ); + verifyGet(); + return m_xRowOrigin->getBytes( columnIndex ); } //virtual Date SAL_CALL ContentResultSetWrapper::getDate( sal_Int32 columnIndex ) { - XROW_GETXXX( getDate ); + verifyGet(); + return m_xRowOrigin->getDate( columnIndex ); } //virtual Time SAL_CALL ContentResultSetWrapper::getTime( sal_Int32 columnIndex ) { - XROW_GETXXX( getTime ); + verifyGet(); + return m_xRowOrigin->getTime( columnIndex ); } //virtual DateTime SAL_CALL ContentResultSetWrapper::getTimestamp( sal_Int32 columnIndex ) { - XROW_GETXXX( getTimestamp ); + verifyGet(); + return m_xRowOrigin->getTimestamp( columnIndex ); } //virtual Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getBinaryStream( sal_Int32 columnIndex ) { - XROW_GETXXX( getBinaryStream ); + verifyGet(); + return m_xRowOrigin->getBinaryStream( columnIndex ); } //virtual Reference< css::io::XInputStream > SAL_CALL ContentResultSetWrapper::getCharacterStream( sal_Int32 columnIndex ) { - XROW_GETXXX( getCharacterStream ); + verifyGet(); + return m_xRowOrigin->getCharacterStream( columnIndex ); } //virtual @@ -1181,25 +1196,29 @@ Any SAL_CALL ContentResultSetWrapper::getObject( sal_Int32 columnIndex, const Re //virtual Reference< XRef > SAL_CALL ContentResultSetWrapper::getRef( sal_Int32 columnIndex ) { - XROW_GETXXX( getRef ); + verifyGet(); + return m_xRowOrigin->getRef( columnIndex ); } //virtual Reference< XBlob > SAL_CALL ContentResultSetWrapper::getBlob( sal_Int32 columnIndex ) { - XROW_GETXXX( getBlob ); + verifyGet(); + return m_xRowOrigin->getBlob( columnIndex ); } //virtual Reference< XClob > SAL_CALL ContentResultSetWrapper::getClob( sal_Int32 columnIndex ) { - XROW_GETXXX( getClob ); + verifyGet(); + return m_xRowOrigin->getClob( columnIndex ); } //virtual Reference< XArray > SAL_CALL ContentResultSetWrapper::getArray( sal_Int32 columnIndex ) { - XROW_GETXXX( getArray ); + verifyGet(); + return m_xRowOrigin->getArray( columnIndex ); } diff --git a/ucb/source/cacher/contentresultsetwrapper.hxx b/ucb/source/cacher/contentresultsetwrapper.hxx index 1dff70d00935..458524566195 100644 --- a/ucb/source/cacher/contentresultsetwrapper.hxx +++ b/ucb/source/cacher/contentresultsetwrapper.hxx @@ -104,6 +104,8 @@ private: void impl_getVetoableChangeListenerContainer(); + void verifyGet(); + protected: diff --git a/ucb/source/ucp/ftp/ftpurl.cxx b/ucb/source/ucp/ftp/ftpurl.cxx index 01c2eb292860..a72a153d5eac 100644 --- a/ucb/source/ucp/ftp/ftpurl.cxx +++ b/ucb/source/ucp/ftp/ftpurl.cxx @@ -374,13 +374,15 @@ namespace ftp { &control) -#define SET_URL(url) \ - OString urlParAscii(url.getStr(), \ - url.getLength(), \ - RTL_TEXTENCODING_UTF8); \ - curl_easy_setopt(curl, \ - CURLOPT_URL, \ +static void setCurlUrl(CURL* curl, OUString const & url) +{ + OString urlParAscii(url.getStr(), + url.getLength(), + RTL_TEXTENCODING_UTF8); + curl_easy_setopt(curl, + CURLOPT_URL, urlParAscii.getStr()); +}; oslFileHandle FTPURL::open() { @@ -391,7 +393,7 @@ oslFileHandle FTPURL::open() SET_CONTROL_CONTAINER; OUString url(ident(false,true)); - SET_URL(url); + setCurlUrl(curl, url); oslFileHandle res( nullptr ); if ( osl_createTempFile( nullptr, &res, nullptr ) == osl_File_E_None ) @@ -432,7 +434,7 @@ std::vector<FTPDirentry> FTPURL::list( curl_easy_setopt(curl,CURLOPT_WRITEDATA,&data); OUString url(ident(true,true)); - SET_URL(url); + setCurlUrl(curl, url); curl_easy_setopt(curl,CURLOPT_POSTQUOTE,0); CURLcode err = curl_easy_perform(curl); @@ -528,7 +530,7 @@ OUString FTPURL::net_title() const else if(!try_more && url.endsWith("/")) url = url.copy(0,url.getLength()-1); // remove end-slash - SET_URL(url); + setCurlUrl(curl, url); err = curl_easy_perform(curl); if(err == CURLE_OK) { // get the title from the server @@ -650,7 +652,7 @@ void FTPURL::insert(bool replaceExisting,void* stream) const curl_easy_setopt(curl, CURLOPT_UPLOAD,1); OUString url(ident(false,true)); - SET_URL(url); + setCurlUrl(curl, url); CURLcode err = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_UPLOAD,false); @@ -700,7 +702,7 @@ void FTPURL::mkdir(bool ReplaceExisting) const OUString url(parent(true)); if(!url.endsWith("/")) url += "/"; - SET_URL(url); + setCurlUrl(curl, url); CURLcode err = curl_easy_perform(curl); curl_slist_free_all(slist); @@ -739,7 +741,7 @@ OUString FTPURL::ren(const OUString& NewTitle) OUString url(parent(true)); if(!url.endsWith("/")) url += "/"; - SET_URL(url); + setCurlUrl(curl, url); CURLcode err = curl_easy_perform(curl); curl_slist_free_all(slist); @@ -789,7 +791,7 @@ void FTPURL::del() const OUString url(parent(true)); if(!url.endsWith("/")) url += "/"; - SET_URL(url); + setCurlUrl(curl, url); CURLcode err = curl_easy_perform(curl); curl_slist_free_all(slist); diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx index e636b46514ac..0888941b0687 100644 --- a/vcl/headless/svpframe.cxx +++ b/vcl/headless/svpframe.cxx @@ -302,9 +302,9 @@ SalFrame* SvpSalFrame::GetParent() const return m_pParent; } -#define FRAMESTATE_MASK_GEOMETRY \ - (WindowStateMask::X | WindowStateMask::Y | \ - WindowStateMask::Width | WindowStateMask::Height) +static constexpr auto FRAMESTATE_MASK_GEOMETRY = + WindowStateMask::X | WindowStateMask::Y | + WindowStateMask::Width | WindowStateMask::Height; void SvpSalFrame::SetWindowState( const SalFrameState *pState ) { diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index aab80d801b00..92d8b8227aaa 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -50,21 +50,21 @@ using namespace css; -#define PUSHBUTTON_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_WORDBREAK | WB_NOLABEL | \ - WB_DEFBUTTON | WB_NOLIGHTBORDER | \ - WB_RECTSTYLE | WB_SMALLSTYLE | \ - WB_TOGGLE ) -#define RADIOBUTTON_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_WORDBREAK | WB_NOLABEL) -#define CHECKBOX_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_WORDBREAK | WB_NOLABEL) +static constexpr auto PUSHBUTTON_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_WORDBREAK | WB_NOLABEL | + WB_DEFBUTTON | WB_NOLIGHTBORDER | + WB_RECTSTYLE | WB_SMALLSTYLE | + WB_TOGGLE; +static constexpr auto RADIOBUTTON_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_WORDBREAK | WB_NOLABEL; +static constexpr auto CHECKBOX_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_WORDBREAK | WB_NOLABEL; #define STYLE_RADIOBUTTON_MONO (sal_uInt16(0x0001)) // legacy #define STYLE_CHECKBOX_MONO (sal_uInt16(0x0001)) // legacy diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index b22a779ce0a9..435c0b6a6a67 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -32,20 +32,20 @@ #define FIXEDLINE_TEXT_BORDER 4 -#define FIXEDTEXT_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_WORDBREAK | WB_NOLABEL | \ - WB_PATHELLIPSIS) -#define FIXEDLINE_VIEW_STYLE (WB_3DLOOK | WB_NOLABEL) -#define FIXEDBITMAP_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_SCALE) -#define FIXEDIMAGE_VIEW_STYLE (WB_3DLOOK | \ - WB_LEFT | WB_CENTER | WB_RIGHT | \ - WB_TOP | WB_VCENTER | WB_BOTTOM | \ - WB_SCALE) +static constexpr auto FIXEDTEXT_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_WORDBREAK | WB_NOLABEL | + WB_PATHELLIPSIS; +static constexpr auto FIXEDLINE_VIEW_STYLE = WB_3DLOOK | WB_NOLABEL; +static constexpr auto FIXEDBITMAP_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_SCALE; +static constexpr auto FIXEDIMAGE_VIEW_STYLE = WB_3DLOOK | + WB_LEFT | WB_CENTER | WB_RIGHT | + WB_TOP | WB_VCENTER | WB_BOTTOM | + WB_SCALE; static Point ImplCalcPos( WinBits nStyle, const Point& rPos, const Size& rObjSize, const Size& rWinSize ) diff --git a/vcl/source/gdi/impvect.cxx b/vcl/source/gdi/impvect.cxx index 4a027134402b..c9b51f575918 100644 --- a/vcl/source/gdi/impvect.cxx +++ b/vcl/source/gdi/impvect.cxx @@ -42,11 +42,20 @@ #define VECT_POLY_OUTLINE_INNER 4UL #define VECT_POLY_OUTLINE_OUTER 8UL -#define VECT_MAP( _def_pIn, _def_pOut, _def_nVal ) _def_pOut[_def_nVal]=(_def_pIn[_def_nVal]=((_def_nVal)*4)+1)+5; -#define BACK_MAP( _def_nVal ) ((((_def_nVal)+2)>>2)-1) -#define VECT_PROGRESS( _def_pProgress, _def_nVal ) \ - if(_def_pProgress) \ - (_def_pProgress->Call(_def_nVal)); +static void VECT_MAP( std::unique_ptr<long []> & pMapIn, std::unique_ptr<long []>& pMapOut, long nVal ) +{ + pMapIn[nVal] = (nVal * 4) + 1; + pMapOut[nVal] = pMapIn[nVal] + 5; +} +static constexpr long BACK_MAP( long _def_nVal ) +{ + return ((_def_nVal + 2) >> 2) - 1; +} +static void VECT_PROGRESS( const Link<long, void>* pProgress, long _def_nVal ) +{ + if(pProgress) + pProgress->Call(_def_nVal); +} class ImplVectMap; class ImplChain; diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx index f1dbc388162c..c105dc82fc76 100644 --- a/vcl/source/window/decoview.cxx +++ b/vcl/source/window/decoview.cxx @@ -23,10 +23,10 @@ #include <vcl/window.hxx> #include <vcl/ctrl.hxx> -#define BUTTON_DRAW_FLATTEST (DrawButtonFlags::Flat | \ - DrawButtonFlags::Pressed | \ - DrawButtonFlags::Checked | \ - DrawButtonFlags::Highlight) +static constexpr auto BUTTON_DRAW_FLATTEST = DrawButtonFlags::Flat | + DrawButtonFlags::Pressed | + DrawButtonFlags::Checked | + DrawButtonFlags::Highlight; using namespace std; diff --git a/vcl/unx/generic/app/i18n_xkb.cxx b/vcl/unx/generic/app/i18n_xkb.cxx index cb5f29709671..ddb8414ba106 100644 --- a/vcl/unx/generic/app/i18n_xkb.cxx +++ b/vcl/unx/generic/app/i18n_xkb.cxx @@ -64,8 +64,8 @@ SalI18N_KeyboardExtension::SalI18N_KeyboardExtension( Display* pDisplay ) // query notification for changes of the keyboard group if ( mbUseExtension ) { - #define XkbGroupMask ( XkbGroupStateMask | XkbGroupBaseMask \ - | XkbGroupLatchMask | XkbGroupLockMask ) + constexpr auto XkbGroupMask = XkbGroupStateMask | XkbGroupBaseMask + | XkbGroupLatchMask | XkbGroupLockMask; mbUseExtension = XkbSelectEventDetails( pDisplay, XkbUseCoreKbd, XkbStateNotify, XkbGroupMask, XkbGroupMask ); diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx index b77e542f7807..1282881f442b 100644 --- a/vcl/unx/generic/dtrans/X11_selection.cxx +++ b/vcl/unx/generic/dtrans/X11_selection.cxx @@ -73,11 +73,11 @@ #include <cppuhelper/supportsservice.hxx> #include <algorithm> -#define DRAG_EVENT_MASK ButtonPressMask |\ - ButtonReleaseMask |\ - PointerMotionMask |\ - EnterWindowMask |\ - LeaveWindowMask +static constexpr auto DRAG_EVENT_MASK = ButtonPressMask | + ButtonReleaseMask | + PointerMotionMask | + EnterWindowMask | + LeaveWindowMask; using namespace com::sun::star::datatransfer; using namespace com::sun::star::datatransfer::dnd; diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index c1f29cf47bc7..ab0700e948e2 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -84,20 +84,20 @@ using namespace vcl_sal; -#define CLIENT_EVENTS StructureNotifyMask \ - | SubstructureNotifyMask \ - | KeyPressMask \ - | KeyReleaseMask \ - | ButtonPressMask \ - | ButtonReleaseMask \ - | PointerMotionMask \ - | EnterWindowMask \ - | LeaveWindowMask \ - | FocusChangeMask \ - | ExposureMask \ - | VisibilityChangeMask \ - | PropertyChangeMask \ - | ColormapChangeMask +static constexpr auto CLIENT_EVENTS = StructureNotifyMask + | SubstructureNotifyMask + | KeyPressMask + | KeyReleaseMask + | ButtonPressMask + | ButtonReleaseMask + | PointerMotionMask + | EnterWindowMask + | LeaveWindowMask + | FocusChangeMask + | ExposureMask + | VisibilityChangeMask + | PropertyChangeMask + | ColormapChangeMask; static ::Window hPresentationWindow = None, hPresFocusWindow = None; static ::std::list< ::Window > aPresentationReparentList; @@ -1653,12 +1653,12 @@ void X11SalFrame::SetAlwaysOnTop( bool bOnTop ) } } -#define FRAMESTATE_MASK_GEOMETRY \ - (WindowStateMask::X | WindowStateMask::Y | \ - WindowStateMask::Width | WindowStateMask::Height) -#define FRAMESTATE_MASK_MAXIMIZED_GEOMETRY \ - (WindowStateMask::MaximizedX | WindowStateMask::MaximizedY | \ - WindowStateMask::MaximizedWidth | WindowStateMask::MaximizedHeight) +static constexpr auto FRAMESTATE_MASK_GEOMETRY = + WindowStateMask::X | WindowStateMask::Y | + WindowStateMask::Width | WindowStateMask::Height; +static constexpr auto FRAMESTATE_MASK_MAXIMIZED_GEOMETRY = + WindowStateMask::MaximizedX | WindowStateMask::MaximizedY | + WindowStateMask::MaximizedWidth | WindowStateMask::MaximizedHeight; void X11SalFrame::SetWindowState( const SalFrameState *pState ) { diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx index aa171ba8a199..869955aead67 100644 --- a/writerperfect/source/common/DocumentHandler.cxx +++ b/writerperfect/source/common/DocumentHandler.cxx @@ -31,8 +31,10 @@ static const unsigned char librvng_utf8_skip_data[256] 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1 }; -#define librvng_utf8_next_char(p) \ - ((p) + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const*>(p)]) +static const char* librvng_utf8_next_char(const char* p) +{ + return p + librvng_utf8_skip_data[*reinterpret_cast<unsigned char const*>(p)]; +} static void unescapeXML(const char* s, const unsigned long sz, librevenge::RVNGString& res) { diff --git a/xmloff/source/transform/OOo2Oasis.cxx b/xmloff/source/transform/OOo2Oasis.cxx index 9d0a361a3ca0..6e8aad50b037 100644 --- a/xmloff/source/transform/OOo2Oasis.cxx +++ b/xmloff/source/transform/OOo2Oasis.cxx @@ -90,8 +90,10 @@ enum XMLUserDefinedTransformerAction // BM: a macro to put two tokens into one sal_Int32 for the action // XML_ATACTION_RENAME_ATTRIBUTE -#define RENAME_ENTRY( f, s ) \ - (static_cast< sal_Int32 >(f) | (static_cast< sal_Int32 >(s) << 16)) +static constexpr sal_Int32 RENAME_ENTRY( XMLTokenEnum f, XMLTokenEnum s ) +{ + return static_cast< sal_Int32 >(f) | (static_cast< sal_Int32 >(s) << 16); +} static XMLTransformerActionInit const aActionTable[] = { diff --git a/xmloff/source/transform/Oasis2OOo.cxx b/xmloff/source/transform/Oasis2OOo.cxx index f555e35c1db0..5d0931f48935 100644 --- a/xmloff/source/transform/Oasis2OOo.cxx +++ b/xmloff/source/transform/Oasis2OOo.cxx @@ -98,8 +98,10 @@ enum XMLUserDefinedTransformerAction // a macro to put two tokens into one sal_Int32 for the action // XML_ATACTION_RENAME_ATTRIBUTE -#define RENAME_ENTRY( f, s ) \ - (static_cast< sal_Int32 >(f) | (static_cast< sal_Int32 >(s) << 16)) +static constexpr sal_Int32 RENAME_ENTRY( XMLTokenEnum f, XMLTokenEnum s ) +{ + return static_cast< sal_Int32 >(f) | (static_cast< sal_Int32 >(s) << 16); +} static XMLTransformerActionInit const aActionTable[] = { |