filter/source/graphicfilter/ieps/ieps.cxx | 15 ++++++-- include/sal/log-areas.dox | 1 include/svx/colorbox.hxx | 3 + include/svx/tbcontrl.hxx | 3 + svx/source/tbxctrls/tbcontrl.cxx | 51 +++++++++++++++++++++++------- 5 files changed, 56 insertions(+), 17 deletions(-)
New commits: commit e17a34e957c21a8cd2977b1b0e1c9a427c244aed Author: Caolán McNamara <[email protected]> Date: Thu Jan 26 21:01:06 2017 +0000 ofz: check if the stream is able to meet the eps len claim before reading Change-Id: I65407bffb67449e203b8ead23554a4e88387d214 diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index 912be13..090bc65 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -540,7 +540,7 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) Graphic aGraphic; bool bRetValue = false; bool bHasPreview = false; - sal_uInt32 nSignature, nPSStreamPos, nPSSize; + sal_uInt32 nSignature = 0, nPSStreamPos, nPSSize = 0; sal_uInt32 nSizeWMF = 0; sal_uInt32 nPosWMF = 0; sal_uInt32 nSizeTIFF = 0; @@ -585,13 +585,20 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) nPSStreamPos = nOrigPos; // no preview available _>so we must get the size manually nPSSize = rStream.Seek( STREAM_SEEK_TO_END ) - nOrigPos; } + std::unique_ptr<sal_uInt8[]> pHeader( new sal_uInt8[ 22 ] ); rStream.Seek( nPSStreamPos ); rStream.ReadBytes(pHeader.get(), 22); // check PostScript header - if ( ImplSearchEntry( pHeader.get(), reinterpret_cast<sal_uInt8 const *>("%!PS-Adobe"), 10, 10 ) && - ImplSearchEntry( &pHeader[ 15 ], reinterpret_cast<sal_uInt8 const *>("EPS"), 3, 3 ) ) + bool bOk = ImplSearchEntry(pHeader.get(), reinterpret_cast<sal_uInt8 const *>("%!PS-Adobe"), 10, 10) && + ImplSearchEntry(&pHeader[ 15 ], reinterpret_cast<sal_uInt8 const *>("EPS"), 3, 3); + if (bOk) + { + rStream.Seek(nPSStreamPos); + bOk = rStream.remainingSize() >= nPSSize; + SAL_WARN_IF(!bOk, "filter.eps", "eps claims to be: " << nPSSize << " in size, but only " << rStream.remainingSize() << " remains"); + } + if (bOk) { - rStream.Seek( nPSStreamPos ); std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nPSSize ] ); sal_uInt32 nBufStartPos = rStream.Tell(); diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index 386c52b..0afd32e 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -201,6 +201,7 @@ certain functionality. @section Filter @li @c filter.config +@li @c filter.eps @li @c filter.flash @li @c filter.ms - escher import/export @li @c filter.odfflatxml commit 9954a91eb841225950ef28a24be5a38abdcb42a9 Author: Caolán McNamara <[email protected]> Date: Thu Jan 26 15:45:59 2017 +0000 Related: tdf#104312 create palette on demand Change-Id: I741323c41231a08fe9561d72ca6079079e888e90 diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index 4b7f251..aa6f971 100644 --- a/include/svx/colorbox.hxx +++ b/include/svx/colorbox.hxx @@ -37,7 +37,7 @@ private: NamedColor m_aSelectedColor; sal_uInt16 m_nSlotId; bool m_bShowNoneButton; - PaletteManager m_aPaletteManager; + std::unique_ptr<PaletteManager> m_xPaletteManager; BorderColorStatus m_aBorderColorStatus; DECL_LINK(MenuActivateHdl, MenuButton *, void); @@ -68,6 +68,7 @@ public: void SetAutoDisplayColor(const Color &rColor) { m_aAutoDisplayColor = rColor; } void ShowPreview(const NamedColor &rColor); + void EnsurePaletteManager(); }; /** A wrapper for SvxColorListBox. */ diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx index aae7ea71..3bfde90 100644 --- a/include/svx/tbcontrl.hxx +++ b/include/svx/tbcontrl.hxx @@ -207,7 +207,7 @@ class SVX_DLLPUBLIC SvxColorToolBoxControl : public cppu::ImplInheritanceHelper< css::frame::XSubToolbarController > { std::unique_ptr<svx::ToolboxButtonColorUpdater> m_xBtnUpdater; - PaletteManager m_aPaletteManager; + std::unique_ptr<PaletteManager> m_xPaletteManager; BorderColorStatus m_aBorderColorStatus; bool m_bSplitButton; ColorSelectFunction m_aColorSelectFunction; @@ -230,6 +230,7 @@ public: virtual void SAL_CALL updateImage() override; void setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction); + void EnsurePaletteManager(); }; class SVX_DLLPUBLIC SvxSimpleUndoRedoController : public SfxToolBoxControl diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index e5a037c..7b4997f 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -2793,7 +2793,16 @@ SvxColorToolBoxControl::SvxColorToolBoxControl( rTbx.SetItemBits( nId, rTbx.GetItemBits( nId ) | ( m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) ); m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ) ); - m_aPaletteManager.SetBtnUpdater( m_xBtnUpdater.get() ); +} + +void SvxColorToolBoxControl::EnsurePaletteManager() +{ + if (!m_xPaletteManager) + { + m_xPaletteManager.reset(new PaletteManager); + m_xPaletteManager->SetBtnUpdater(m_xBtnUpdater.get()); + m_xPaletteManager->SetLastColor(m_xBtnUpdater->GetCurrentColor()); + } } SvxColorToolBoxControl::~SvxColorToolBoxControl() @@ -2803,14 +2812,17 @@ SvxColorToolBoxControl::~SvxColorToolBoxControl() void SvxColorToolBoxControl::setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction) { m_aColorSelectFunction = aColorSelectFunction; - m_aPaletteManager.SetColorSelectFunction(aColorSelectFunction); + if (m_xPaletteManager) + m_xPaletteManager->SetColorSelectFunction(aColorSelectFunction); } VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() { + EnsurePaletteManager(); + VclPtrInstance<SvxColorWindow> pColorWin( m_aCommandURL, - m_aPaletteManager, + *m_xPaletteManager, m_aBorderColorStatus, GetSlotId(), m_xFrame, @@ -2828,7 +2840,8 @@ VclPtr<SfxPopupWindow> SvxColorToolBoxControl::CreatePopupWindow() IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void) { m_xBtnUpdater->Update(rColor.first); - m_aPaletteManager.SetLastColor(rColor.first); + if (m_xPaletteManager) + m_xPaletteManager->SetLastColor(rColor.first); } void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent ) @@ -2852,7 +2865,8 @@ void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& aColor = nValue; } m_xBtnUpdater->Update( aColor ); - m_aPaletteManager.SetLastColor(aColor); + if (m_xPaletteManager) + m_xPaletteManager->SetLastColor(aColor); } else if ( rEvent.State >>= bValue ) GetToolBox().CheckItem( GetId(), bValue ); @@ -2882,8 +2896,10 @@ void SvxColorToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/) break; } + EnsurePaletteManager(); + auto aArgs( comphelper::InitPropertySequence( { - { m_aCommandURL.copy(5), css::uno::makeAny( m_aPaletteManager.GetLastColor().GetColor() ) } + { m_aCommandURL.copy(5), css::uno::makeAny( m_xPaletteManager->GetLastColor().GetColor() ) } } ) ); Dispatch( aCommand, aArgs ); } @@ -2902,7 +2918,8 @@ void SvxColorToolBoxControl::updateImage() if ( !!aImage ) { GetToolBox().SetItemImage( GetId(), aImage ); - m_xBtnUpdater->Update( m_aPaletteManager.GetLastColor(), true ); + EnsurePaletteManager(); + m_xBtnUpdater->Update(m_xPaletteManager->GetLastColor(), true); } } @@ -3191,9 +3208,18 @@ SvxColorListBox::SvxColorListBox(vcl::Window* pParent, WinBits nStyle) , m_bShowNoneButton(false) { LockWidthRequest(); - m_aPaletteManager.SetColorSelectFunction(m_aColorWrapper); SetActivateHdl(LINK(this, SvxColorListBox, MenuActivateHdl)); - SetNoSelection(); +} + +void SvxColorListBox::EnsurePaletteManager() +{ + if (!m_xPaletteManager) + { + m_xPaletteManager.reset(new PaletteManager); + m_xPaletteManager->SetColorSelectFunction(m_aColorWrapper); + m_xPaletteManager->SetLastColor(m_aSelectedColor.first); + SetNoSelection(); + } } void SvxColorListBox::SetSlotId(sal_uInt16 nSlotId, bool bShowNoneButton) @@ -3264,9 +3290,11 @@ void SvxColorListBox::createColorWindow() const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : nullptr; css::uno::Reference<css::frame::XFrame> xFrame(pFrame ? pFrame->GetFrameInterface() : uno::Reference<css::frame::XFrame>()); + EnsurePaletteManager(); + m_xColorWindow = VclPtr<SvxColorWindow>::Create( OUString() /*m_aCommandURL*/, - m_aPaletteManager, + *m_xPaletteManager, m_aBorderColorStatus, m_nSlotId, xFrame, @@ -3281,7 +3309,8 @@ void SvxColorListBox::createColorWindow() void SvxColorListBox::Selected(const NamedColor& rColor) { ShowPreview(rColor); - m_aPaletteManager.SetLastColor(rColor.first); + if (m_xPaletteManager) + m_xPaletteManager->SetLastColor(rColor.first); m_aSelectedColor = rColor; if (m_aSelectedLink.IsSet()) m_aSelectedLink.Call(*this);
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
