cui/source/inc/swpossizetabpage.hxx | 5 +- cui/source/tabpages/swpossizetabpage.cxx | 57 ++++++++++++++--------------- include/svx/swframeexample.hxx | 11 ++--- include/svx/swframetypes.hxx | 50 ++++++++++++++++++++++++++ include/svx/swframevalidation.hxx | 6 +-- svx/source/dialog/swframeexample.cxx | 49 ++++++++++++------------- sw/inc/swtypes.hxx | 25 ------------- sw/source/filter/ww8/ww8scan.cxx | 5 ++ sw/source/ui/frmdlg/frmpage.cxx | 8 ++-- sw/source/ui/frmdlg/wrap.cxx | 4 +- sw/source/uibase/frmdlg/frmmgr.cxx | 2 - sw/source/uibase/shells/drwbassh.cxx | 2 - unotools/source/config/fontcfg.cxx | 59 +++++++++++++------------------ 13 files changed, 151 insertions(+), 132 deletions(-)
New commits: commit d30fb62f4f1022ae6294e246974d0018596cf8ec Author: Caolán McNamara <caol...@redhat.com> Date: Tue Apr 4 12:31:04 2017 +0100 ofz: guard against bogus sprm len Change-Id: I9b4074e1024753549f468f427afbfdf9cd01b674 diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index fc441fdee489..19bd84fb6c90 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -4886,6 +4886,11 @@ void WW8PLCFMan::GetSprmStart( short nIdx, WW8PLCFManResult* pRes ) const { // Length of actual sprm pRes->nMemLen = maSprmParser.GetSprmSize(pRes->nSprmId, pRes->pMemPos); + if (pRes->nMemLen > p->nSprmsLen) + { + SAL_WARN("sw.ww8", "Short sprm, len " << pRes->nMemLen << " claimed, max possible is " << p->nSprmsLen); + pRes->nMemLen = p->nSprmsLen; + } } } commit 0f89d964b272c2087dbc865bc0a60edfdde8551f Author: Caolán McNamara <caol...@redhat.com> Date: Tue Apr 4 09:37:08 2017 +0100 coverity#1403732 Mixing enum types and coverity#1403735 Mixing enum types coverity#1403737 Mixing enum types Change-Id: I278b7d5116d4157e6aa4483d8eef42325e4bc03b diff --git a/cui/source/inc/swpossizetabpage.hxx b/cui/source/inc/swpossizetabpage.hxx index c11050f778d5..865539625e46 100644 --- a/cui/source/inc/swpossizetabpage.hxx +++ b/cui/source/inc/swpossizetabpage.hxx @@ -26,7 +26,6 @@ #include <vcl/lstbox.hxx> #include <svx/swframeposstrings.hxx> #include <svx/swframeexample.hxx> -#include <com/sun/star/text/TextContentAnchorType.hpp> // SvxSwPosSizeTabPage - position and size page for Writer drawing objects struct FrmMap; @@ -110,13 +109,13 @@ class SvxSwPosSizeTabPage : public SfxTabPage DECL_LINK( ModifyHdl, Edit&, void ); DECL_LINK(ProtectHdl, Button*, void); - void InitPos(css::text::TextContentAnchorType nAnchorType, sal_uInt16 nH, sal_uInt16 nHRel, + void InitPos(RndStdIds nAnchorType, sal_uInt16 nH, sal_uInt16 nHRel, sal_uInt16 nV, sal_uInt16 nVRel, long nX, long nY); sal_uInt16 GetMapPos(FrmMap *pMap, ListBox &rAlignLB); static short GetAlignment(FrmMap *pMap, sal_uInt16 nMapPos, ListBox &rAlignLB, ListBox &rRelationLB); static short GetRelation(FrmMap *pMap, ListBox &rRelationLB); - css::text::TextContentAnchorType GetAnchorType(bool* pbHasChanged = nullptr); + RndStdIds GetAnchorType(bool* pbHasChanged = nullptr); void FillRelLB(FrmMap *pMap, sal_uInt16 nLBSelPos, sal_uInt16 nAlign, sal_uInt16 nRel, ListBox &rLB, FixedText &rFT); sal_uInt16 FillPosLB(FrmMap *pMap, sal_uInt16 nAlign, const sal_uInt16 _nRel, ListBox &rLB); diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx index fc6c0e3f4b3f..53d8836888e6 100644 --- a/cui/source/tabpages/swpossizetabpage.cxx +++ b/cui/source/tabpages/swpossizetabpage.cxx @@ -771,7 +771,7 @@ const sal_uInt16* SvxSwPosSizeTabPage::GetRanges() bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) { bool bAnchorChanged = false; - css::text::TextContentAnchorType nAnchor = GetAnchorType(&bAnchorChanged); + RndStdIds nAnchor = GetAnchorType(&bAnchorChanged); bool bModified = false; if(bAnchorChanged) { @@ -875,7 +875,7 @@ bool SvxSwPosSizeTabPage::FillItemSet( SfxItemSet* rSet) // as-character anchored objects long nVertByPos = static_cast<long>(m_pVertByMF->Denormalize(m_pVertByMF->GetValue(FUNIT_TWIP))); - if ( GetAnchorType() == TextContentAnchorType_AS_CHARACTER ) + if (GetAnchorType() == RndStdIds::FLY_AS_CHAR) { nVertByPos *= -1; } @@ -925,17 +925,17 @@ void SvxSwPosSizeTabPage::Reset( const SfxItemSet* rSet) { const SfxPoolItem* pItem = GetItem( *rSet, SID_ATTR_TRANSFORM_ANCHOR ); bool bInvalidateAnchor = false; - TextContentAnchorType nAnchorType = TextContentAnchorType_AT_PARAGRAPH; + RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA; if(pItem) { - nAnchorType = (TextContentAnchorType) static_cast<const SfxInt16Item*>(pItem)->GetValue(); + nAnchorType = (RndStdIds) static_cast<const SfxInt16Item*>(pItem)->GetValue(); switch(nAnchorType) { - case TextContentAnchorType_AT_PAGE: m_pToPageRB->Check(); break; - case TextContentAnchorType_AT_PARAGRAPH: m_pToParaRB->Check(); break; - case TextContentAnchorType_AT_CHARACTER: m_pToCharRB->Check(); break; - case TextContentAnchorType_AS_CHARACTER: m_pAsCharRB->Check(); break; - case TextContentAnchorType_AT_FRAME: m_pToFrameRB->Check(); break; + case RndStdIds::FLY_AT_PAGE: m_pToPageRB->Check(); break; + case RndStdIds::FLY_AT_PARA: m_pToParaRB->Check(); break; + case RndStdIds::FLY_AT_CHAR: m_pToCharRB->Check(); break; + case RndStdIds::FLY_AS_CHAR: m_pAsCharRB->Check(); break; + case RndStdIds::FLY_AT_FLY: m_pToFrameRB->Check(); break; default : bInvalidateAnchor = true; } m_pToPageRB->SaveValue(); @@ -1101,35 +1101,35 @@ void SvxSwPosSizeTabPage::EnableAnchorTypes(SvxAnchorIds nAnchorEnable) m_pToPageRB->Enable(false); } -TextContentAnchorType SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) +RndStdIds SvxSwPosSizeTabPage::GetAnchorType(bool* pbHasChanged) { - TextContentAnchorType nRet = (TextContentAnchorType)-1; + RndStdIds nRet = RndStdIds::UNKNOWN; RadioButton* pCheckedButton = nullptr; if(m_pToParaRB->IsEnabled()) { if(m_pToPageRB->IsChecked()) { - nRet = TextContentAnchorType_AT_PAGE; + nRet = RndStdIds::FLY_AT_PAGE; pCheckedButton = m_pToPageRB; } else if(m_pToParaRB->IsChecked()) { - nRet = TextContentAnchorType_AT_PARAGRAPH; + nRet = RndStdIds::FLY_AT_PARA; pCheckedButton = m_pToParaRB; } else if(m_pToCharRB->IsChecked()) { - nRet = TextContentAnchorType_AT_CHARACTER; + nRet = RndStdIds::FLY_AT_CHAR; pCheckedButton = m_pToCharRB; } else if(m_pAsCharRB->IsChecked()) { - nRet = TextContentAnchorType_AS_CHARACTER; + nRet = RndStdIds::FLY_AS_CHAR; pCheckedButton = m_pAsCharRB; } else if(m_pToFrameRB->IsChecked()) { - nRet = TextContentAnchorType_AT_FRAME; + nRet = RndStdIds::FLY_AT_FLY; pCheckedButton = m_pToFrameRB; } } @@ -1234,7 +1234,7 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, Button*, void) // type to-paragraph' and to-character m_pFollowCB->Enable( m_pToParaRB->IsChecked() || m_pToCharRB->IsChecked() ); - TextContentAnchorType nId = GetAnchorType(); + RndStdIds nId = GetAnchorType(); InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); RangeModifyHdl(*m_pWidthMF); @@ -1248,7 +1248,7 @@ IMPL_LINK_NOARG(SvxSwPosSizeTabPage, AnchorTypeHdl, Button*, void) IMPL_LINK_NOARG(SvxSwPosSizeTabPage, MirrorHdl, Button*, void) { - TextContentAnchorType nId = GetAnchorType(); + RndStdIds nId = GetAnchorType(); InitPos( nId, USHRT_MAX, 0, USHRT_MAX, 0, LONG_MAX, LONG_MAX); } @@ -1263,7 +1263,7 @@ IMPL_LINK( SvxSwPosSizeTabPage, RelHdl, ListBox&, rLB, void ) else m_bAtVertPosModified = true; - if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) // again special treatment + if (m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType()) // again special treatment { if(bHori) { @@ -1327,7 +1327,7 @@ IMPL_LINK( SvxSwPosSizeTabPage, PosHdl, ListBox&, rLB, void ) m_bAtVertPosModified = true; // special treatment for HTML-Mode with horz-vert-dependencies - if(m_bHtmlMode && TextContentAnchorType_AT_CHARACTER == GetAnchorType()) + if (m_bHtmlMode && RndStdIds::FLY_AT_CHAR == GetAnchorType()) { bool bSet = false; if(bHori) @@ -1490,7 +1490,7 @@ sal_uInt16 SvxSwPosSizeTabPage::GetMapPos(FrmMap *pMap, ListBox &rAlignLB) return nMapPos; } -void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, +void SvxSwPosSizeTabPage::InitPos(RndStdIds nAnchor, sal_uInt16 nH, sal_uInt16 nHRel, sal_uInt16 nV, @@ -1523,19 +1523,19 @@ void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, m_pVMap = aVMultiSelectionMap; m_pHMap = aHMultiSelectionMap; } - else if( nAnchor == TextContentAnchorType_AT_PAGE ) + else if (nAnchor == RndStdIds::FLY_AT_PAGE) { m_pVMap = m_bHtmlMode ? aVPageHtmlMap : aVPageMap; m_pHMap = m_bHtmlMode ? aHPageHtmlMap : aHPageMap; } - else if ( nAnchor == TextContentAnchorType_AT_FRAME ) + else if (nAnchor == RndStdIds::FLY_AT_FLY) { // #i18732# - own vertical alignment map for to frame // anchored objects. m_pVMap = m_bHtmlMode ? aVFlyHtmlMap : aVFrameMap; m_pHMap = m_bHtmlMode ? aHFlyHtmlMap : aHFrameMap; } - else if ( nAnchor == TextContentAnchorType_AT_PARAGRAPH ) + else if (nAnchor == RndStdIds::FLY_AT_PARA) { if(m_bHtmlMode) { @@ -1548,7 +1548,7 @@ void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, m_pHMap = aHParaMap; } } - else if ( nAnchor == TextContentAnchorType_AT_CHARACTER ) + else if (nAnchor == RndStdIds::FLY_AT_CHAR) { if(m_bHtmlMode) { @@ -1561,7 +1561,7 @@ void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, m_pHMap = aHCharMap; } } - else if ( nAnchor == TextContentAnchorType_AS_CHARACTER ) + else if (nAnchor == RndStdIds::FLY_AS_CHAR) { m_pVMap = m_bHtmlMode ? aVAsCharHtmlMap : aVAsCharMap; m_pHMap = nullptr; @@ -1592,8 +1592,7 @@ void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, FillRelLB(m_pVMap, nMapPos, nV, nVRel, *m_pVertToLB, *m_pVertToFT); // Edits init - bEnable = nH == HoriOrientation::NONE && - nAnchor != TextContentAnchorType_AS_CHARACTER;//#61359# why not in formats&& !bFormat; + bEnable = nH == HoriOrientation::NONE && nAnchor != RndStdIds::FLY_AS_CHAR; //#61359# why not in formats&& !bFormat; if (!bEnable) { m_pHoriByMF->SetValue( 0, FUNIT_TWIP ); @@ -1625,7 +1624,7 @@ void SvxSwPosSizeTabPage::InitPos(TextContentAnchorType nAnchor, } else { - if ( nAnchor == TextContentAnchorType_AS_CHARACTER ) + if (nAnchor == RndStdIds::FLY_AS_CHAR) { if ( nY == LONG_MAX ) nY = 0; diff --git a/include/svx/swframeexample.hxx b/include/svx/swframeexample.hxx index a780f5770add..0453c252c637 100644 --- a/include/svx/swframeexample.hxx +++ b/include/svx/swframeexample.hxx @@ -1,4 +1,3 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * @@ -24,7 +23,7 @@ #include <tools/color.hxx> #include <tools/gen.hxx> #include <svx/svxdllapi.h> -#include <com/sun/star/text/TextContentAnchorType.hpp> +#include <svx/swframetypes.hxx> #include <com/sun/star/text/WrapTextMode.hpp> // class SwFrmPagePreview ------------------------------------------------------- @@ -57,10 +56,8 @@ class SVX_DLLPUBLIC SvxSwFrameExample : public vcl::Window short nVAlign; short nVRel; - css::text::WrapTextMode - nWrap; - css::text::TextContentAnchorType - nAnchor; + css::text::WrapTextMode nWrap; + RndStdIds nAnchor; bool bTrans; Point aRelPos; @@ -87,7 +84,7 @@ public: void SetVertRel(short nR) { nVRel = nR; } void SetTransparent(bool bT) { bTrans = bT; } - void SetAnchor(css::text::TextContentAnchorType nA) { nAnchor = nA; } + void SetAnchor(RndStdIds nA) { nAnchor = nA; } void SetRelPos(const Point& rP); }; diff --git a/include/svx/swframetypes.hxx b/include/svx/swframetypes.hxx new file mode 100644 index 000000000000..9aa2f8189b8a --- /dev/null +++ b/include/svx/swframetypes.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SVX_INC_SWFRAMETYPES_HXX +#define INCLUDED_SVX_INC_SWFRAMETYPES_HXX + +#include <com/sun/star/text/TextContentAnchorType.hpp> + +// The former Rendezvous-IDs live on: +// There are IDs for the anchors (SwFormatAnchor) and some others +// that are only of importance for interfaces (SwDoc). +enum class RndStdIds +{ + UNKNOWN = -1, // return value used by SwFEShell::GetAnchorId + + // the following 5 values are deliberately the same as the values in css::text::TextContentAnchorType + FLY_AT_PARA = (int)css::text::TextContentAnchorType_AT_PARAGRAPH, // Anchored at paragraph. + FLY_AS_CHAR = (int)css::text::TextContentAnchorType_AS_CHARACTER, // Anchored as character. + FLY_AT_PAGE = (int)css::text::TextContentAnchorType_AT_PAGE, // Anchored at page. + FLY_AT_FLY = (int)css::text::TextContentAnchorType_AT_FRAME, // Anchored at frame. + FLY_AT_CHAR = (int)css::text::TextContentAnchorType_AT_CHARACTER, // Anchored at character. + + HEADER, + FOOTER, + HEADERL, + HEADERR, + FOOTERL, + FOOTERR, + + DRAW_OBJECT // A draw-Object! For the SwDoc-interface only! +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/swframevalidation.hxx b/include/svx/swframevalidation.hxx index cb75145937c8..ab112e3fcee7 100644 --- a/include/svx/swframevalidation.hxx +++ b/include/svx/swframevalidation.hxx @@ -22,14 +22,14 @@ #include <sal/types.h> #include <tools/gen.hxx> #include <limits.h> -#include <com/sun/star/text/TextContentAnchorType.hpp> +#include <svx/swframetypes.hxx> /* struct to determine min/max values for fly frame positioning in Writer */ struct SvxSwFrameValidation { - css::text::TextContentAnchorType nAnchorType; + RndStdIds nAnchorType; sal_Int16 nHoriOrient; //css::text::HoriOrientation sal_Int16 nVertOrient; //css::text::VertOrientation sal_Int16 nHRelOrient; //css::text::RelOrientation @@ -58,7 +58,7 @@ struct SvxSwFrameValidation Size aPercentSize; // Size for 100% value SvxSwFrameValidation() : - nAnchorType(css::text::TextContentAnchorType_AT_PARAGRAPH), + nAnchorType(RndStdIds::FLY_AT_PARA), nHoriOrient(0), nVertOrient(0), nHRelOrient(0), diff --git a/svx/source/dialog/swframeexample.cxx b/svx/source/dialog/swframeexample.cxx index 46f8db0778f1..46303069cb86 100644 --- a/svx/source/dialog/swframeexample.cxx +++ b/svx/source/dialog/swframeexample.cxx @@ -24,7 +24,6 @@ #include <vcl/settings.hxx> #include <svtools/colorcfg.hxx> #include <svx/swframeexample.hxx> -#include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/HoriOrientation.hpp> #include <com/sun/star/text/VertOrientation.hpp> #include <com/sun/star/text/RelOrientation.hpp> @@ -55,7 +54,7 @@ SvxSwFrameExample::SvxSwFrameExample( vcl::Window *pParent, WinBits nStyle ) : nVAlign (VertOrientation::TOP), nVRel (RelOrientation::PRINT_AREA), nWrap (WrapTextMode_NONE), - nAnchor (TextContentAnchorType_AT_PAGE), + nAnchor (RndStdIds::FLY_AT_PAGE), bTrans (false), aRelPos (Point(0,0)) { @@ -115,7 +114,7 @@ void SvxSwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext) sal_uInt32 nTTxtBorder; sal_uInt32 nBTxtBorder; - if (nAnchor != TextContentAnchorType_AS_CHARACTER) + if (nAnchor != RndStdIds::FLY_AS_CHAR) { nLBorder = 14; nRBorder = 10; @@ -163,7 +162,7 @@ void SvxSwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext) aParaPrtArea.Top() += nTTxtBorder; aParaPrtArea.Bottom() -= nBTxtBorder; - if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER) + if (nAnchor == RndStdIds::FLY_AS_CHAR || nAnchor == RndStdIds::FLY_AT_CHAR) { vcl::Font aFont = OutputDevice::GetDefaultFont( DefaultFontType::LATIN_TEXT, Application::GetSettings().GetLanguageTag().getLanguageType(), @@ -172,7 +171,7 @@ void SvxSwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext) aFont.SetFillColor( m_aBgCol ); aFont.SetWeight(WEIGHT_NORMAL); - if (nAnchor == TextContentAnchorType_AS_CHARACTER) + if (nAnchor == RndStdIds::FLY_AS_CHAR) { aFont.SetFontSize(Size(0, aParaPrtArea.GetHeight() - 2)); SetFont(aFont); @@ -196,10 +195,10 @@ void SvxSwFrameExample::InitAllRects_Impl(vcl::RenderContext& rRenderContext) aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5)); // Size of the frame to be positioned - if (nAnchor != TextContentAnchorType_AS_CHARACTER) + if (nAnchor != RndStdIds::FLY_AS_CHAR) { - sal_uInt32 nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder; - sal_uInt32 nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder; + sal_uInt32 nLFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nLBorder : nLTxtBorder; + sal_uInt32 nRFBorder = nAnchor == RndStdIds::FLY_AT_PAGE ? nRBorder : nRTxtBorder; switch (nHRel) { @@ -235,7 +234,7 @@ void SvxSwFrameExample::CalcBoundRect_Impl(tools::Rectangle &rRect) { switch (nAnchor) { - case TextContentAnchorType_AT_PAGE: + case RndStdIds::FLY_AT_PAGE: { switch (nHRel) { @@ -279,7 +278,7 @@ void SvxSwFrameExample::CalcBoundRect_Impl(tools::Rectangle &rRect) } break; - case TextContentAnchorType_AT_FRAME: + case RndStdIds::FLY_AT_FLY: { switch (nHRel) { @@ -322,8 +321,8 @@ void SvxSwFrameExample::CalcBoundRect_Impl(tools::Rectangle &rRect) } } break; - case TextContentAnchorType_AT_PARAGRAPH: - case TextContentAnchorType_AT_CHARACTER: + case RndStdIds::FLY_AT_PARA: + case RndStdIds::FLY_AT_CHAR: { switch (nHRel) { @@ -402,7 +401,7 @@ void SvxSwFrameExample::CalcBoundRect_Impl(tools::Rectangle &rRect) } break; - case TextContentAnchorType_AS_CHARACTER: + case RndStdIds::FLY_AS_CHAR: rRect.Left() = aParaPrtArea.Left(); rRect.Right() = aParaPrtArea.Right(); @@ -452,7 +451,7 @@ tools::Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(vcl::RenderContext& rRen tools::Rectangle aRect(rRect); // aPagePrtArea = Default CalcBoundRect_Impl(aRect); - if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea) + if (nAnchor == RndStdIds::FLY_AT_FLY && &rRect == &aPagePrtArea) { // Testabsatz zeichnen tools::Rectangle aTxt(aTextLine); @@ -483,14 +482,14 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R // Draw PrintArea tools::Rectangle aRect = DrawInnerFrame_Impl(rRenderContext, aPagePrtArea, m_aTransColor, m_aPrintAreaCol); - if (nAnchor == TextContentAnchorType_AT_FRAME) + if (nAnchor == RndStdIds::FLY_AT_FLY) aRect = DrawInnerFrame_Impl(rRenderContext, aFrameAtFrame, m_aBgCol, m_aBorderCol); long lXPos = 0; long lYPos = 0; // Horizontal alignment - if (nAnchor != TextContentAnchorType_AS_CHARACTER) + if (nAnchor != RndStdIds::FLY_AS_CHAR) { switch (nHAlign) { @@ -521,7 +520,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R } // Vertical Alignment - if (nAnchor != TextContentAnchorType_AS_CHARACTER) + if (nAnchor != RndStdIds::FLY_AS_CHAR) { switch (nVAlign) { @@ -593,7 +592,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R tools::Rectangle* pOuterFrame = &aPage; - if (nAnchor == TextContentAnchorType_AT_FRAME) + if (nAnchor == RndStdIds::FLY_AT_FLY) pOuterFrame = &aFrameAtFrame; if (aFrmRect.Left() < pOuterFrame->Left()) @@ -612,7 +611,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R sal_Int32 nStep; sal_uInt16 nLines; - if (nAnchor == TextContentAnchorType_AT_FRAME) + if (nAnchor == RndStdIds::FLY_AT_FLY) { aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER; aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER; @@ -629,14 +628,14 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R nLines = (sal_uInt16)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2)); } - if (nAnchor != TextContentAnchorType_AS_CHARACTER) + if (nAnchor != RndStdIds::FLY_AS_CHAR) { // Simulate text const long nOldR = aTxt.Right(); const long nOldL = aTxt.Left(); // #i22341# - const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER && + const bool bIgnoreWrap = nAnchor == RndStdIds::FLY_AT_CHAR && ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR || nVRel == RelOrientation::TEXT_LINE ); @@ -645,7 +644,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R if (i == (nLines - 1)) aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight())); - if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap) + if (aTxt.IsOver(aFrmRect) && nAnchor != RndStdIds::FLY_AS_CHAR && !bIgnoreWrap) { switch(nWrap) { @@ -673,7 +672,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R } aTxt.Move(0, -nStep); - if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom()) + if (nAnchor != RndStdIds::FLY_AT_FLY && aTxt.Bottom() > aParaPrtArea.Bottom()) { // Text has been replaced by frame, so adjust parameters height sal_uInt32 nDiff = aTxt.Bottom() - aParaPrtArea.Bottom(); @@ -685,7 +684,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R aParaPrtArea.Bottom() -= nDiff; aPara.Bottom() -= nDiff; } - if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap) + if (nAnchor == RndStdIds::FLY_AT_CHAR && bIgnoreWrap) rRenderContext.DrawText(aAutoCharFrame, OUString('A')); } else @@ -698,7 +697,7 @@ void SvxSwFrameExample::Paint(vcl::RenderContext& rRenderContext, const tools::R DrawRect_Impl(rRenderContext, aRect, m_aTransColor, m_aAlignColor); // Frame View - bool bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) || bTrans; + bool bDontFill = (nAnchor == RndStdIds::FLY_AT_CHAR && aFrmRect.IsOver(aAutoCharFrame)) || bTrans; DrawRect_Impl(rRenderContext, aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor); } diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 0e986947c28f..b1aadec9bebd 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -28,6 +28,7 @@ #include "swdllapi.h" #include <i18nlangtag/languagetag.hxx> #include <o3tl/typed_flags_set.hxx> +#include <svx/swframetypes.hxx> namespace com { namespace sun { namespace star { namespace linguistic2{ @@ -133,30 +134,6 @@ const short lOutlineMinTextDistance = 216; // 0.15 inch = 0.38 cm // fields before INIT_FLDTYPES. #define INIT_SEQ_FLDTYPES 4 -// The former Rendezvous-IDs live on: -// There are IDs for the anchors (SwFormatAnchor) and some others -// that are only of importance for interfaces (SwDoc). -enum class RndStdIds -{ - UNKNOWN = -1, // return value used by SwFEShell::GetAnchorId - - // the following 5 values are deliberately the same as the values in css::text::TextContentAnchorType - FLY_AT_PARA = 0, // Anchored at paragraph. - FLY_AS_CHAR, // Anchored as character. - FLY_AT_PAGE, // Anchored at page. - FLY_AT_FLY, // Anchored at frame. - FLY_AT_CHAR, // Anchored at character. - - HEADER, - FOOTER, - HEADERL, - HEADERR, - FOOTERL, - FOOTERR, - - DRAW_OBJECT // A draw-Object! For the SwDoc-interface only! -}; - extern ResMgr* pSwResMgr; // defined in sw/source/uibase/app/swmodule.cxx for the sw library and in // sw/source/ui/dialog/swdialmgr.cxx for the swui library diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index f79265c3f34b..b220f872144b 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -1814,7 +1814,7 @@ void SwFramePage::RangeModifyHdl() SwFlyFrameAttrMgr aMgr( m_bNew, pSh, static_cast<const SwAttrSet&>(GetItemSet()) ); SvxSwFrameValidation aVal; - aVal.nAnchorType = (css::text::TextContentAnchorType)GetAnchor(); + aVal.nAnchorType = GetAnchor(); aVal.bAutoHeight = m_pAutoHeightCB->IsChecked(); aVal.bAutoWidth = m_pAutoWidthCB->IsChecked(); aVal.bMirror = m_pMirrorPagesCB->IsChecked(); @@ -1911,9 +1911,9 @@ void SwFramePage::RangeModifyHdl() if ( aVal.nHPos != nAtHorzPosVal ) m_pAtHorzPosED->SetValue(m_pAtHorzPosED->Normalize(aVal.nHPos), FUNIT_TWIP); - const SwTwips nUpperOffset = (aVal.nAnchorType == css::text::TextContentAnchorType_AS_CHARACTER) + const SwTwips nUpperOffset = (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR) ? m_nUpperBorder : 0; - const SwTwips nLowerOffset = (aVal.nAnchorType == css::text::TextContentAnchorType_AS_CHARACTER) + const SwTwips nLowerOffset = (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR) ? m_nLowerBorder : 0; m_pAtVertPosED->SetMin(m_pAtVertPosED->Normalize(aVal.nMinVPos + nLowerOffset + nUpperOffset), FUNIT_TWIP); @@ -2144,7 +2144,7 @@ void SwFramePage::UpdateExample() long nYPos = static_cast< long >(m_pAtVertPosED->Denormalize(m_pAtVertPosED->GetValue(FUNIT_TWIP))); m_pExampleWN->SetRelPos(Point(nXPos, nYPos)); - m_pExampleWN->SetAnchor( (css::text::TextContentAnchorType)GetAnchor() ); + m_pExampleWN->SetAnchor(GetAnchor()); m_pExampleWN->Invalidate(); } diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx index 2f10d4a566e9..5d2cf4a3bdfc 100644 --- a/sw/source/ui/frmdlg/wrap.cxx +++ b/sw/source/ui/frmdlg/wrap.cxx @@ -422,7 +422,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) const SwFormatHoriOrient& rHori = static_cast<const SwFormatHoriOrient&>(rSet.Get(RES_HORI_ORIENT)); const SwFormatVertOrient& rVert = static_cast<const SwFormatVertOrient&>(rSet.Get(RES_VERT_ORIENT)); - aVal.nAnchorType = static_cast< css::text::TextContentAnchorType >(m_nAnchorId); + aVal.nAnchorType = m_nAnchorId; aVal.bAutoHeight = rFrameSize.GetHeightSizeType() == ATT_MIN_SIZE; aVal.bAutoWidth = rFrameSize.GetWidthSizeType() == ATT_MIN_SIZE; aVal.bMirror = rHori.IsPosToggle(); @@ -461,7 +461,7 @@ void SwWrapTabPage::ActivatePage(const SfxItemSet& rSet) nBottom = aVal.nMaxHeight - aVal.nHeight; { - if (aVal.nAnchorType == css::text::TextContentAnchorType_AS_CHARACTER) + if (aVal.nAnchorType == RndStdIds::FLY_AS_CHAR) { nLeft = nRight; diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index 7d32a309cf82..a710350cae40 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -247,7 +247,7 @@ void SwFlyFrameAttrMgr::ValidateMetrics( SvxSwFrameValidation& rVal, // OD 18.09.2003 #i18732# - adjustment for allowing vertical position // aligned to page for fly frame anchored to paragraph or to character. - const RndStdIds eAnchorType = static_cast<RndStdIds >(rVal.nAnchorType); + const RndStdIds eAnchorType = rVal.nAnchorType; const SwFormatFrameSize& rSize = static_cast<const SwFormatFrameSize&>(m_aSet.Get(RES_FRM_SIZE)); m_pOwnSh->CalcBoundRect( aBoundRect, eAnchorType, rVal.nHRelOrient, diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx index 361d69bf81fa..ee7412daf952 100644 --- a/sw/source/uibase/shells/drwbassh.cxx +++ b/sw/source/uibase/shells/drwbassh.cxx @@ -772,7 +772,7 @@ IMPL_LINK(SwDrawBaseShell, ValidatePosition, SvxSwFrameValidation&, rValidation, // OD 18.09.2003 #i18732# - adjustment for allowing vertical position // aligned to page for fly frame anchored to paragraph or to character. - const RndStdIds eAnchorType = static_cast<RndStdIds >(rValidation.nAnchorType); + const RndStdIds eAnchorType = rValidation.nAnchorType; const SwPosition* pContentPos = nullptr; SdrView* pSdrView = pSh->GetDrawView(); const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); commit c4dba436df42cef4f0048994c38dc137266ebaf9 Author: Caolán McNamara <caol...@redhat.com> Date: Tue Apr 4 10:32:51 2017 +0100 just use one try/catch level Change-Id: I298f84df5431f0f77144db95bf2305f49e7f9302 diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 022c90509ced..495d082609d2 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -97,48 +97,41 @@ DefaultFontConfiguration& DefaultFontConfiguration::get() DefaultFontConfiguration::DefaultFontConfiguration() { + // create configuration hierarchical access name try { // get service provider - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - // create configuration hierarchical access name - try + m_xConfigProvider = theDefaultProvider::get(comphelper::getProcessComponentContext()); + Sequence< Any > aArgs(1); + PropertyValue aVal; + aVal.Name = "nodepath"; + aVal.Value <<= OUString( "/org.openoffice.VCL/DefaultFonts" ); + aArgs.getArray()[0] <<= aVal; + m_xConfigAccess = + Reference< XNameAccess >( + m_xConfigProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", + aArgs ), + UNO_QUERY ); + if( m_xConfigAccess.is() ) { - m_xConfigProvider = theDefaultProvider::get( xContext ); - Sequence< Any > aArgs(1); - PropertyValue aVal; - aVal.Name = "nodepath"; - aVal.Value <<= OUString( "/org.openoffice.VCL/DefaultFonts" ); - aArgs.getArray()[0] <<= aVal; - m_xConfigAccess = - Reference< XNameAccess >( - m_xConfigProvider->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", - aArgs ), - UNO_QUERY ); - if( m_xConfigAccess.is() ) + Sequence< OUString > aLocales = m_xConfigAccess->getElementNames(); + // fill config hash with empty interfaces + int nLocales = aLocales.getLength(); + const OUString* pLocaleStrings = aLocales.getConstArray(); + for( int i = 0; i < nLocales; i++ ) { - Sequence< OUString > aLocales = m_xConfigAccess->getElementNames(); - // fill config hash with empty interfaces - int nLocales = aLocales.getLength(); - const OUString* pLocaleStrings = aLocales.getConstArray(); - for( int i = 0; i < nLocales; i++ ) - { - // Feed through LanguageTag for casing. - OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false)); - m_aConfig[ aLoc ] = LocaleAccess(); - m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i]; - } + // Feed through LanguageTag for casing. + OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false)); + m_aConfig[ aLoc ] = LocaleAccess(); + m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i]; } } - catch (const Exception&) - { - // configuration is awry - m_xConfigProvider.clear(); - m_xConfigAccess.clear(); - } } - catch (const WrappedTargetException&) + catch (const Exception&) { + // configuration is awry + m_xConfigProvider.clear(); + m_xConfigAccess.clear(); } SAL_INFO("unotools.config", "config provider: " << static_cast<bool>(m_xConfigProvider.is()) << ", config access: " << static_cast<bool>(m_xConfigAccess.is()));
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits